mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-03 15:17:04 -05:00
38 lines
561 B
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")
|
|
}
|
|
}
|
|
}
|