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.
12 "golang.org/x/text/runes"
13 "golang.org/x/text/unicode/rangetable"
16 type tableTest struct {
17 rangeTable *unicode.RangeTable
21 var exceptions = runes.Predicate(func(r rune) bool {
23 case 0x00DF, 0x03C2, 0x06FD, 0x06FE, 0x0F0B, 0x3007, 0x00B7, 0x0375, 0x05F3,
24 0x05F4, 0x30FB, 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666,
25 0x0667, 0x0668, 0x0669, 0x06F0, 0x06F1, 0x06F2, 0x06F3, 0x06F4, 0x06F5,
26 0x06F6, 0x06F7, 0x06F8, 0x06F9, 0x0640, 0x07FA, 0x302E, 0x302F, 0x3031,
27 0x3032, 0x3033, 0x3034, 0x3035, 0x303B:
34 // Ensure that certain properties were generated correctly.
35 func TestTable(t *testing.T) {
39 unicode.Lt, unicode.Nl, unicode.No, // Other letter digits
40 unicode.Me, // Modifiers
42 unicode.So, // Symbols
43 unicode.Pi, unicode.Pf, // Punctuation
48 rangetable.New(0x30000, 0x30101, 0xDFFFF),
53 assigned := rangetable.Assigned(UnicodeVersion)
55 for _, test := range tests {
56 rangetable.Visit(test.rangeTable, func(r rune) {
57 if !unicode.In(r, assigned) {
61 n := utf8.EncodeRune(b, r)
62 trieval, _ := dpTrie.lookup(b[:n])
63 p := entry(trieval).property()
64 if p != test.prop && !exceptions.Contains(r) {
65 t.Errorf("%U: got %+x; want %+x", r, test.prop, p)