Skip to content

Commit 325f38a

Browse files
committed
add test code
1 parent e6097d4 commit 325f38a

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

modules/translation/i18n/i18n_test.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/stretchr/testify/assert"
1111
)
1212

13-
func Test_Tr(t *testing.T) {
13+
func TestLocaleStore(t *testing.T) {
1414
testData1 := []byte(`
1515
.dot.name = Dot Name
1616
fmt = %[1]s %[2]s
@@ -28,8 +28,8 @@ sub = Changed Sub String
2828
`)
2929

3030
ls := NewLocaleStore()
31-
assert.NoError(t, ls.AddLocaleByIni("lang1", "Lang1", testData1))
32-
assert.NoError(t, ls.AddLocaleByIni("lang2", "Lang2", testData2))
31+
assert.NoError(t, ls.AddLocaleByIni("lang1", "Lang1", testData1, nil))
32+
assert.NoError(t, ls.AddLocaleByIni("lang2", "Lang2", testData2, nil))
3333
ls.SetDefaultLang("lang1")
3434

3535
result := ls.Tr("lang1", "fmt", "a", "b")
@@ -58,3 +58,21 @@ sub = Changed Sub String
5858
assert.False(t, found)
5959
assert.NoError(t, ls.Close())
6060
}
61+
62+
func TestLocaleStoreMoreSource(t *testing.T) {
63+
testData1 := []byte(`
64+
a=11
65+
b=12
66+
`)
67+
68+
testData2 := []byte(`
69+
b=21
70+
c=22
71+
`)
72+
73+
ls := NewLocaleStore()
74+
assert.NoError(t, ls.AddLocaleByIni("lang1", "Lang1", testData1, testData2))
75+
assert.Equal(t, "11", ls.Tr("lang1", "a"))
76+
assert.Equal(t, "21", ls.Tr("lang1", "b"))
77+
assert.Equal(t, "22", ls.Tr("lang1", "c"))
78+
}

0 commit comments

Comments
 (0)