OSDN Git Service

new repo
[bytom/vapor.git] / vendor / golang.org / x / text / unicode / norm / forminfo_test.go
1 // Copyright 2013 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 // +build test
6
7 package norm
8
9 import "testing"
10
11 func TestProperties(t *testing.T) {
12         var d runeData
13         CK := [2]string{"C", "K"}
14         for k, r := 1, rune(0); r < 0x2ffff; r++ {
15                 if k < len(testData) && r == testData[k].r {
16                         d = testData[k]
17                         k++
18                 }
19                 s := string(r)
20                 for j, p := range []Properties{NFC.PropertiesString(s), NFKC.PropertiesString(s)} {
21                         f := d.f[j]
22                         if p.CCC() != d.ccc {
23                                 t.Errorf("%U: ccc(%s): was %d; want %d %X", r, CK[j], p.CCC(), d.ccc, p.index)
24                         }
25                         if p.isYesC() != (f.qc == Yes) {
26                                 t.Errorf("%U: YesC(%s): was %v; want %v", r, CK[j], p.isYesC(), f.qc == Yes)
27                         }
28                         if p.combinesBackward() != (f.qc == Maybe) {
29                                 t.Errorf("%U: combines backwards(%s): was %v; want %v", r, CK[j], p.combinesBackward(), f.qc == Maybe)
30                         }
31                         if p.nLeadingNonStarters() != d.nLead {
32                                 t.Errorf("%U: nLead(%s): was %d; want %d %#v %#v", r, CK[j], p.nLeadingNonStarters(), d.nLead, p, d)
33                         }
34                         if p.nTrailingNonStarters() != d.nTrail {
35                                 t.Errorf("%U: nTrail(%s): was %d; want %d %#v %#v", r, CK[j], p.nTrailingNonStarters(), d.nTrail, p, d)
36                         }
37                         if p.combinesForward() != f.combinesForward {
38                                 t.Errorf("%U: combines forward(%s): was %v; want %v %#v", r, CK[j], p.combinesForward(), f.combinesForward, p)
39                         }
40                         // Skip Hangul as it is algorithmically computed.
41                         if r >= hangulBase && r < hangulEnd {
42                                 continue
43                         }
44                         if p.hasDecomposition() {
45                                 if has := f.decomposition != ""; !has {
46                                         t.Errorf("%U: hasDecomposition(%s): was %v; want %v", r, CK[j], p.hasDecomposition(), has)
47                                 }
48                                 if string(p.Decomposition()) != f.decomposition {
49                                         t.Errorf("%U: decomp(%s): was %+q; want %+q", r, CK[j], p.Decomposition(), f.decomposition)
50                                 }
51                         }
52                 }
53         }
54 }