...
1
2
3
4
5 package cases
6
7 import (
8 "testing"
9
10 "golang.org/x/text/internal/testtext"
11 )
12
13 var foldTestCases = []string{
14 "βß\u13f8",
15 "ab\u13fc\uab7aꭰ",
16 "affifflast",
17 "Iİiı\u0345",
18 "µµΜΜςσΣΣ",
19 }
20
21 func TestFold(t *testing.T) {
22 for _, tc := range foldTestCases {
23 testEntry := func(name string, c Caser, m func(r rune) string) {
24 want := ""
25 for _, r := range tc {
26 want += m(r)
27 }
28 if got := c.String(tc); got != want {
29 t.Errorf("%s(%s) = %+q; want %+q", name, tc, got, want)
30 }
31 dst := make([]byte, 256)
32 src := []byte(tc)
33 v := testtext.AllocsPerRun(20, func() {
34 c.Transform(dst, src, true)
35 })
36 if v > 0 {
37 t.Errorf("%s(%s): number of allocs was %f; want 0", name, tc, v)
38 }
39 }
40 testEntry("FullFold", Fold(), func(r rune) string {
41 return runeFoldData(r).full
42 })
43
44
45
46
47
48
49
50 }
51 }
52
View as plain text