-
Notifications
You must be signed in to change notification settings - Fork 7
/
locale_test.go
39 lines (36 loc) · 956 Bytes
/
locale_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package lingo
import (
"testing"
)
func TestLocale(t *testing.T) {
l0 := supportedLocales("ja-JP;q")
if len(l0) != 1 {
t.Errorf("Expected number of locales \"1\", got %d", len(l0))
t.Fail()
}
l1 := supportedLocales("en,de-AT; q=0.8,de;q=0.6,bg; q=0.4,en-US;q=0.2,sr;q=0.2")
if len(l1) != 6 {
t.Errorf("Expected number of locales \"6\", got %d", len(l1))
t.Fail()
}
l2 := supportedLocales("en")
if len(l2) != 1 {
t.Errorf("Expected number of locales \"1\", got %d", len(l2))
t.Fail()
}
l3 := supportedLocales("")
if len(l3) != 0 {
t.Errorf("Expected number of locales \"0\", got %d", len(l3))
t.Fail()
}
l4 := ParseLocale("en_US")
if l4.Lang != "en" || l4.Country != "US" {
t.Errorf("Expected \"en\" and \"US\", got %s and %s", l4.Lang, l4.Country)
t.Fail()
}
l5 := ParseLocale("en")
if l5.Lang != "en" || l5.Country != "" {
t.Errorf("Expected \"en\" and \"\", got %s and %s", l5.Lang, l5.Country)
t.Fail()
}
}