22 lines
588 B
Go
22 lines
588 B
Go
package geoip
|
|
|
|
import "testing"
|
|
|
|
func TestBuildRegion(t *testing.T) {
|
|
got := buildRegion(Location{Country: "中国", Province: "广东省", City: "深圳市"})
|
|
if got != "中国 广东省 深圳市" {
|
|
t.Fatalf("buildRegion=%q", got)
|
|
}
|
|
got = buildRegion(Location{Country: "中国", Province: "中国", City: ""})
|
|
if got != "中国" {
|
|
t.Fatalf("重复地区应去重: %q", got)
|
|
}
|
|
}
|
|
|
|
func TestLocalizedNamePrefersChinese(t *testing.T) {
|
|
got := localizedName(map[string]string{"en": "China", "zh-CN": "中国"})
|
|
if got != "中国" {
|
|
t.Fatalf("应优先中文名: %q", got)
|
|
}
|
|
}
|