This repository was archived by the owner on Jul 22, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -138,6 +138,11 @@ type Slice struct {
138138 Vbar []string
139139}
140140
141+ type SliceOfByte struct {
142+ Vfoo string
143+ Vbar []byte
144+ }
145+
141146type SliceOfAlias struct {
142147 Vfoo string
143148 Vbar SliceAlias
@@ -1654,6 +1659,34 @@ func TestSlice(t *testing.T) {
16541659 testSliceInput (t , inputStringSlicePointer , outputStringSlice )
16551660}
16561661
1662+ func TestNotEmptyByteSlice (t * testing.T ) {
1663+ t .Parallel ()
1664+
1665+ inputByteSlice := map [string ]interface {}{
1666+ "vfoo" : "foo" ,
1667+ "vbar" : []byte (`{"bar": "bar"}` ),
1668+ }
1669+
1670+ result := SliceOfByte {
1671+ Vfoo : "another foo" ,
1672+ Vbar : []byte (`{"bar": "bar bar bar bar bar bar bar bar"}` ),
1673+ }
1674+
1675+ err := Decode (inputByteSlice , & result )
1676+ if err != nil {
1677+ t .Fatalf ("got unexpected error: %s" , err )
1678+ }
1679+
1680+ expected := SliceOfByte {
1681+ Vfoo : "foo" ,
1682+ Vbar : []byte (`{"bar": "bar"}` ),
1683+ }
1684+
1685+ if ! reflect .DeepEqual (result , expected ) {
1686+ t .Errorf ("bad: %#v" , result )
1687+ }
1688+ }
1689+
16571690func TestInvalidSlice (t * testing.T ) {
16581691 t .Parallel ()
16591692
You can’t perform that action at this time.
0 commit comments