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.
11 func TestProperties(t *testing.T) {
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 {
20 for j, p := range []Properties{NFC.PropertiesString(s), NFKC.PropertiesString(s)} {
23 t.Errorf("%U: ccc(%s): was %d; want %d %X", r, CK[j], p.CCC(), d.ccc, p.index)
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)
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)
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)
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)
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)
40 // Skip Hangul as it is algorithmically computed.
41 if r >= hangulBase && r < hangulEnd {
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)
48 if string(p.Decomposition()) != f.decomposition {
49 t.Errorf("%U: decomp(%s): was %+q; want %+q", r, CK[j], p.Decomposition(), f.decomposition)