1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-19 02:46:35 -05:00

tbl: completed test

This commit is contained in:
M. Sz 2021-02-25 12:03:00 +01:00
parent 522f749cfc
commit 91b3290322
2 changed files with 11 additions and 4 deletions

View File

@ -227,7 +227,7 @@ func (td *TextDictionary) Marshal() []byte {
sw.PushUint32(uint32(dataPos))
dataPos += len(value) + 1
sw.PushUint16(uint16(len(value) + 0))
sw.PushUint16(uint16(len(value) + 1))
}
// data stream: put all data in appropiate order

View File

@ -19,13 +19,20 @@ func exampleData() *TextDictionary {
func TestTBL_Marshal(t *testing.T) {
tbl := exampleData()
data := tbl.Marshal()
newTbl, err := LoadTextDictionary(data)
if err != nil {
t.Error(err)
}
_, ok := newTbl["lolstring"]
for key, value := range *tbl {
newValue, ok := newTbl[key]
fmt.Println(newValue, value)
if !ok {
t.Fatal("no string found")
t.Fatal("string wasn't encoded to table")
}
if newValue != value {
t.Fatal("unexpected value set")
}
}
}