-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutil_test.go
45 lines (34 loc) · 841 Bytes
/
util_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
40
41
42
43
44
45
//go:build !android
package locale
import (
"testing"
"github.com/stretchr/testify/assert"
)
var (
globalLanguage string
globalRegion string
)
func BenchmarkSplitLocale(b *testing.B) {
language := ""
region := ""
b.ReportAllocs()
for i := 0; i < b.N; i++ {
language, region = splitLocale("en_US.UTF-8")
}
globalLanguage = language
globalRegion = region
}
func TestSplitLocale(t *testing.T) {
language, region := splitLocale("en_US.UTF-8")
assert.Equal(t, "en", language)
assert.Equal(t, "US", region)
language, region = splitLocale("fr-FR")
assert.Equal(t, "fr", language)
assert.Equal(t, "FR", region)
language, region = splitLocale("ja")
assert.Equal(t, "ja", language)
assert.Equal(t, "", region)
language, region = splitLocale("test")
assert.Equal(t, "test", language)
assert.Equal(t, "", region)
}