Skip to content

Commit ef1fc26

Browse files
committed
Add zstring abbreviations decoding test
1 parent 4cc0ff3 commit ef1fc26

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

gork/zmemory_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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
1014
var readTestData []byte = []byte{42, 73, 96, 7, 28, 1, 2, 3}
1115
var writeTestData []byte = []byte{3, 2, 1, 28, 7, 96, 73, 42}
1216
var 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
}
1621
var zstringsExpected []string = []string{
1722
"zork",
1823
"cyclop",
24+
"zork",
1925
}
2026

2127
var 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] {
205211
t.Fail()
206212
}
207-
208-
// TODO test zstring with abbreviations :)
209213
}
210214
}
211215

@@ -214,15 +218,13 @@ func TestZStringDecode(t *testing.T) {
214218
mem := ZMemory(zstring)
215219
seq := mem.GetSequential(0)
216220

217-
if mem.DecodeZStringAt(0, nil) != seq.DecodeZString(nil) ||
221+
if mem.DecodeZStringAt(0, header) != seq.DecodeZString(header) ||
218222
seq.pos > uint32(len(zstringsExpected[i])) {
219223
// cannot be sure where seq.pos will be, just do the best
220224
// we can
221225

222226
t.Fail()
223227
}
224-
225-
// TODO test zstring with abbreviations :)
226228
}
227229
}
228230

0 commit comments

Comments
 (0)