1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-09-27 21:56:19 -04:00
OpenDiablo2/d2common/d2fileformats/d2tbl/text_dictionary_test.go

39 lines
594 B
Go
Raw Normal View History

package d2tbl
import (
2021-02-25 05:58:32 -05:00
"fmt"
"testing"
)
func exampleData() *TextDictionary {
result := &TextDictionary{
2021-02-25 05:58:32 -05:00
"abc": "def",
"someStr": "Some long string",
"lolstring": "lol",
}
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]
fmt.Println(newValue, value)
if !ok {
t.Fatal("string wasn't encoded to table")
}
if newValue != value {
t.Fatal("unexpected value set")
}
}
}