OSDN Git Service

new repo
[bytom/vapor.git] / vendor / golang.org / x / text / unicode / runenames / runenames_test.go
1 // Copyright 2016 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 runenames
6
7 import (
8         "strings"
9         "testing"
10         "unicode"
11
12         "golang.org/x/text/internal/gen"
13         "golang.org/x/text/internal/testtext"
14         "golang.org/x/text/internal/ucd"
15 )
16
17 func TestName(t *testing.T) {
18         testtext.SkipIfNotLong(t)
19
20         wants := make([]string, 1+unicode.MaxRune)
21         ucd.Parse(gen.OpenUCDFile("UnicodeData.txt"), func(p *ucd.Parser) {
22                 r, s := p.Rune(0), p.String(ucd.Name)
23                 if s == "" {
24                         return
25                 }
26                 if s[0] == '<' {
27                         const first = ", First>"
28                         if i := strings.Index(s, first); i >= 0 {
29                                 s = s[:i] + ">"
30                         }
31                 }
32                 wants[r] = s
33         })
34
35         nErrors := 0
36         for r, want := range wants {
37                 got := Name(rune(r))
38                 if got != want {
39                         t.Errorf("r=%#08x: got %q, want %q", r, got, want)
40                         nErrors++
41                         if nErrors == 100 {
42                                 t.Fatal("too many errors")
43                         }
44                 }
45         }
46 }