11
"golang.org/x/text/internal/tag"
12
var strdata = []string{
23
func strtests() map[string]int {
24
return map[string]int{
39
func TestSearch(t *testing.T) {
40
for k, v := range strtests() {
41
if i := search(strings.Join(strdata, ""), []byte(k)); i != v {
42
t.Errorf("%s: found %d; want %d", k, i, v)
47
func TestIndex(t *testing.T) {
48
strtests := strtests()
52
for k, v := range strtests {
53
if i := index(strings.Join(strdata, ""), []byte(k)); i != v {
54
t.Errorf("%s: found %d; want %d", k, i, v)
59
14
func b(s string) []byte {
63
func TestFixCase(t *testing.T) {
65
"aaaa", "AbCD", "abcd",
66
"Zzzz", "AbCD", "Abcd",
67
"Zzzz", "AbC", "Zzzz",
73
for i := 0; i+3 < len(tests); i += 3 {
76
b := buf[:copy(buf[:], tt[1])]
77
res := fixCase(tt[0], b)
78
if res && cmp(tt[2], b) != 0 || !res && tt[0] != tt[2] {
79
t.Errorf("%s+%s: found %q; want %q", tt[0], tt[1], b, tt[2])
84
18
func TestLangID(t *testing.T) {
85
19
tests := []struct {
86
20
id, bcp47, iso3, norm string
176
111
// Grandfathered tags with no modern replacement will be converted as follows:
177
112
{"cel-gaulish", "xtg-x-cel-gaulish"},
178
113
{"en-GB-oed", "en-GB-x-oed"},
114
{"en-gb-oed", "en-GB-x-oed"},
179
115
{"i-default", "en-x-i-default"},
180
116
{"i-enochian", "und-x-i-enochian"},
181
117
{"i-mingo", "see-x-i-mingo"},
182
118
{"zh-min", "nan-x-zh-min"},
121
{"en_US_POSIX", "en-US-u-va-posix"},
122
{"en_us_posix", "en-US-u-va-posix"},
123
{"en-us-posix", "en-US-u-va-posix"},
184
125
got := Raw.Make(tt.in)
185
126
want := Raw.MustParse(tt.out)
456
397
func TestCurrency(t *testing.T) {
457
idx := strings.Join([]string{
398
idx := tag.Index(strings.Join([]string{
459
400
"BBB" + mkCurrencyInfo(5, 2),
463
404
"\xff\xff\xff\xff",
465
406
tests := []struct {