github.com/go-xe2/third@v1.0.3/golang.org/x/text/internal/gen_test.go (about) 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. 4 5 package internal 6 7 import ( 8 "testing" 9 10 "github.com/go-xe2/third/golang.org/x/text/language" 11 ) 12 13 func TestParents(t *testing.T) { 14 testCases := []struct { 15 tag, parent string 16 }{ 17 {"af", "und"}, 18 {"en", "und"}, 19 {"en-001", "en"}, 20 {"en-AU", "en-001"}, 21 {"en-US", "en"}, 22 {"en-US-u-va-posix", "en-US"}, 23 {"ca-ES-valencia", "ca-ES"}, 24 } 25 for _, tc := range testCases { 26 tag, ok := language.CompactIndex(language.MustParse(tc.tag)) 27 if !ok { 28 t.Fatalf("Could not get index of flag %s", tc.tag) 29 } 30 want, ok := language.CompactIndex(language.MustParse(tc.parent)) 31 if !ok { 32 t.Fatalf("Could not get index of parent %s of tag %s", tc.parent, tc.tag) 33 } 34 if got := int(Parent[tag]); got != want { 35 t.Errorf("Parent[%s] = %d; want %d (%s)", tc.tag, got, want, tc.parent) 36 } 37 } 38 }