1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
10 "golang.org/x/text/language"
13 func TestParents(t *testing.T) {
14 testCases := []struct {
22 {"en-US-u-va-posix", "en-US"},
23 {"ca-ES-valencia", "ca-ES"},
25 for _, tc := range testCases {
26 tag, ok := language.CompactIndex(language.MustParse(tc.tag))
28 t.Fatalf("Could not get index of flag %s", tc.tag)
30 want, ok := language.CompactIndex(language.MustParse(tc.parent))
32 t.Fatalf("Could not get index of parent %s of tag %s", tc.parent, tc.tag)
34 if got := int(Parent[tag]); got != want {
35 t.Errorf("Parent[%s] = %d; want %d (%s)", tc.tag, got, want, tc.parent)