@@ -6,16 +6,22 @@ import (
66"testing"
77)
88
9+ var header * ZHeader = & ZHeader {
10+ abbrTblPos : 2 ,
11+ }
12+
913// len must be multiple of 4
1014var readTestData []byte = []byte {42 , 73 , 96 , 7 , 28 , 1 , 2 , 3 }
1115var writeTestData []byte = []byte {3 , 2 , 1 , 28 , 7 , 96 , 73 , 42 }
1216var zstrings [][]byte = [][]byte {
1317[]byte {0x7E , 0x97 , 0xC0 , 0xA5 },
1418[]byte {0x23 , 0xC8 , 0xC6 , 0x95 },
19+ []byte {0x84 , 0x05 , 0x00 , 0x02 , 0x7E , 0x97 , 0xC0 , 0xA5 },
1520}
1621var zstringsExpected []string = []string {
1722"zork" ,
1823"cyclop" ,
24+ "zork" ,
1925}
2026
2127var encodedZstrings []string = []string {
@@ -201,11 +207,9 @@ func TestZStringDecodeAt(t *testing.T) {
201207
202208// in this case zstring doesn't have abbreviations,
203209// so don't pass the header
204- if mem .DecodeZStringAt (0 , nil ) != zstringsExpected [i ] {
210+ if mem .DecodeZStringAt (0 , header ) != zstringsExpected [i ] {
205211t .Fail ()
206212}
207-
208- // TODO test zstring with abbreviations :)
209213}
210214}
211215
@@ -214,15 +218,13 @@ func TestZStringDecode(t *testing.T) {
214218mem := ZMemory (zstring )
215219seq := mem .GetSequential (0 )
216220
217- if mem .DecodeZStringAt (0 , nil ) != seq .DecodeZString (nil ) ||
221+ if mem .DecodeZStringAt (0 , header ) != seq .DecodeZString (header ) ||
218222seq .pos > uint32 (len (zstringsExpected [i ])) {
219223// cannot be sure where seq.pos will be, just do the best
220224// we can
221225
222226t .Fail ()
223227}
224-
225- // TODO test zstring with abbreviations :)
226228}
227229}
228230
0 commit comments