mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-11-19 02:46:35 -05:00
tbl: completed test
This commit is contained in:
parent
522f749cfc
commit
91b3290322
@ -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
|
||||
|
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user