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/internal/testtext"
18 func TestTables(t *testing.T) {
19 testtext.SkipIfNotLong(t)
21 runes := map[rune]Kind{}
22 getWidthData(func(r rune, tag elem, _ rune) {
25 for r := rune(0); r < 0x10FFFF; r++ {
26 if loSurrogate <= r && r <= hiSurrogate {
30 if got, want := p.Kind(), runes[r]; got != want {
31 t.Errorf("Kind of %U was %s; want %s.", r, got, want)
33 want, mapped := foldRune(r)
34 if got := p.Folded(); (got == 0) == mapped || got != 0 && got != want {
35 t.Errorf("Folded(%U) = %U; want %U", r, got, want)
37 want, mapped = widenRune(r)
38 if got := p.Wide(); (got == 0) == mapped || got != 0 && got != want {
39 t.Errorf("Wide(%U) = %U; want %U", r, got, want)
41 want, mapped = narrowRune(r)
42 if got := p.Narrow(); (got == 0) == mapped || got != 0 && got != want {
43 t.Errorf("Narrow(%U) = %U; want %U", r, got, want)
48 // TestAmbiguous verifies that that ambiguous runes with a mapping always map to
50 func TestAmbiguous(t *testing.T) {
51 for r, m := range mapRunes {
52 if m.e != tagAmbiguous {
55 if k := mapRunes[m.r].e.kind(); k != EastAsianHalfwidth {
56 t.Errorf("Rune %U is ambiguous and maps to a rune of type %v", r, k)