From b43da8f083690b32aab89b43ac522dfeec0ae7e4 Mon Sep 17 00:00:00 2001 From: "M. Sz" Date: Sun, 28 Feb 2021 20:35:35 +0100 Subject: [PATCH] text dictionary: added no-named string check as separated test function --- .../d2tbl/text_dictionary_test.go | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/d2common/d2fileformats/d2tbl/text_dictionary_test.go b/d2common/d2fileformats/d2tbl/text_dictionary_test.go index 142ff14c..aea1f7d2 100644 --- a/d2common/d2fileformats/d2tbl/text_dictionary_test.go +++ b/d2common/d2fileformats/d2tbl/text_dictionary_test.go @@ -1,8 +1,6 @@ package d2tbl import ( - "fmt" - "testing" ) @@ -25,7 +23,30 @@ func TestTBL_Marshal(t *testing.T) { t.Error(err) } - fmt.Println(newTbl) + for key, value := range *tbl { + newValue, ok := newTbl[key] + + if !ok { + t.Fatalf("string %s wasn't encoded to table", key) + } + + if newValue != value { + t.Fatal("unexpected value set") + } + } +} + +func TestTBL_MarshalNoNameString(t *testing.T) { + tbl := &TextDictionary{ + "#0": "OKEY", + } + + data := tbl.Marshal() + + newTbl, err := LoadTextDictionary(data) + if err != nil { + t.Error(err) + } for key, value := range *tbl { newValue, ok := newTbl[key]