@@ -39,7 +39,7 @@ func TestStreamKind(t *testing.T) {
3939 s := NewStream (bytes .NewReader (unhex (test .input )))
4040 kind , len , err := s .Kind ()
4141 if err != nil {
42- t .Errorf ("test %d: Type returned error: %v" , i , err )
42+ t .Errorf ("test %d: Kind returned error: %v" , i , err )
4343 continue
4444 }
4545 if kind != test .wantKind {
@@ -93,6 +93,23 @@ func TestStreamErrors(t *testing.T) {
9393 {"C3C2010201" , calls {"List" , "List" , "Uint" , "Uint" , "ListEnd" , "Uint" }, EOL },
9494 {"00" , calls {"ListEnd" }, errNotInList },
9595 {"C40102" , calls {"List" , "Uint" , "ListEnd" }, errNotAtEOL },
96+
97+ // This test verifies that the input position is advanced
98+ // correctly when calling Bytes for empty strings. Kind can be called
99+ // any number of times in between and doesn't advance.
100+ {"C3808080" , calls {
101+ "List" , // enter the list
102+ "Bytes" , // past first element
103+
104+ "Kind" , "Kind" , "Kind" , // this shouldn't advance
105+
106+ "Bytes" , // past second element
107+
108+ "Kind" , "Kind" , // can't hurt to try
109+
110+ "Bytes" , // past final element
111+ "Bytes" , // this one should fail
112+ }, EOL },
96113 }
97114
98115testfor:
@@ -314,6 +331,9 @@ var decodeTests = []decodeTest{
314331 {input : "C109" , ptr : new (* []uint ), value : & []uint {9 }},
315332 {input : "C58403030303" , ptr : new (* [][]byte ), value : & [][]byte {{3 , 3 , 3 , 3 }}},
316333
334+ // check that input position is advanced also empty values.
335+ {input : "C3808005" , ptr : new ([]* uint ), value : []* uint {nil , nil , uintp (5 )}},
336+
317337 // pointer should be reset to nil
318338 {input : "05" , ptr : sharedPtr , value : uintp (5 )},
319339 {input : "80" , ptr : sharedPtr , value : (* uint )(nil )},
0 commit comments