Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey committed Dec 25, 2024
1 parent 4fca19f commit 00f8185
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion mfd/dict_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package mfd

import "testing"
import (
"encoding/xml"
"testing"
)

func TestTranslate(t *testing.T) {
var testCases = []struct {
Expand All @@ -24,3 +27,55 @@ func TestTranslate(t *testing.T) {
}
}
}

func TestAddedCustomTranslations(t *testing.T) {
var testCases = []struct {
name string
in string
dict *Dict
want string
}{
{
"with updated word",
"user",
&Dict{
Entries: []Entry{
{XMLName: xml.Name{Local: "user"}, Value: "Пользователь (Обновленный)"},
},
},
"Пользователь (Обновленный)",
},
{
"with new word",
"newKey",
&Dict{
Entries: []Entry{
{XMLName: xml.Name{Local: "newKey"}, Value: "Изображение (Обновленное)"},
},
},
"Изображение (Обновленное)",
},
{
"with empty dict",
"",
&Dict{
Entries: []Entry{},
},
"",
},
{
"with nil dict",
"",
nil,
"",
},
}
for _, tt := range testCases {
old := Translate(RuLang, tt.in)
AddedCustomTranslations(tt.dict)
updated := Translate(RuLang, tt.in)
if updated != tt.want {
t.Errorf("%v: got %q, want %q", tt.in, old, tt.want)
}
}
}

0 comments on commit 00f8185

Please sign in to comment.