1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-19 21:55:24 +00: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 10:58:32 +00:00
}
return result
}
func TestTBL_Marshal(t *testing.T) {
tbl := exampleData()
data := tbl.Marshal()
2021-02-25 11:03:00 +00:00
2021-02-25 10:58:32 +00:00
newTbl, err := LoadTextDictionary(data)
if err != nil {
t.Error(err)
}
2021-02-25 11:03:00 +00:00
for key, value := range *tbl {
newValue, ok := newTbl[key]
2021-02-25 11:08:02 +00:00
2021-02-25 11:03:00 +00:00
if !ok {
t.Fatal("string wasn't encoded to table")
}
2021-02-25 11:08:02 +00:00
2021-02-25 11:03:00 +00:00
if newValue != value {
t.Fatal("unexpected value set")
}
}
}