OpenDiablo2/d2common/d2fileformats/d2tbl/text_dictionary_test.go

38 lines
561 B
Go

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