25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

55 satır
1.8 KiB

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