1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2025-02-13 12:06:31 -05:00
OpenDiablo2/d2common/d2fileformats/d2tbl/text_dictionary_test.go

38 lines
561 B
Go
Raw Normal View History

package d2tbl
import (
"testing"
)
func exampleData() *TextDictionary {
result := &TextDictionary{
"abc": "def",
"someStr": "Some long string",
"teststring": "TeSt",
2021-02-25 05:58:32 -05:00
}
return result
}
func TestTBL_Marshal(t *testing.T) {
tbl := exampleData()
data := tbl.Marshal()
2021-02-25 06:03:00 -05:00
2021-02-25 05:58:32 -05:00
newTbl, err := LoadTextDictionary(data)
if err != nil {
t.Error(err)
}
2021-02-25 06:03:00 -05:00
for key, value := range *tbl {
newValue, ok := newTbl[key]
2021-02-25 06:08:02 -05:00
2021-02-25 06:03:00 -05:00
if !ok {
t.Fatal("string wasn't encoded to table")
}
2021-02-25 06:08:02 -05:00
2021-02-25 06:03:00 -05:00
if newValue != value {
t.Fatal("unexpected value set")
}
}
}