1 // Copyright 2015 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 TestDoNorm(t *testing.T) {
12 const div = -1 // The insertion point of the next block.
19 in: []int{4, div, 3, 3, 3},
20 out: []int{3, 3, 3, 4},
22 in: []int{0, 4, div, 3},
25 in: []int{0, 0, 4, 5, div, 3, 3},
26 out: []int{0, 0, 3, 3, 4, 5},
28 in: []int{0, 0, 1, 4, 5, div, 3, 3},
29 out: []int{0, 0, 1, 3, 3, 4, 5},
31 in: []int{0, 0, 1, 4, 5, div, 4, 4},
32 out: []int{0, 0, 1, 4, 4, 4, 5},
35 for j, tt := range tests {
38 for k, cc := range tt.in {
45 i.Elems = append(i.Elems, makeCE([]int{w, defaultSecondary, 2, cc}))
47 i.doNorm(p, i.Elems[p].CCC())
48 if len(i.Elems) != len(tt.out) {
49 t.Errorf("%d: length was %d; want %d", j, len(i.Elems), len(tt.out))
52 for k, ce := range i.Elems {
53 if int(ce.CCC()) != tt.out[k] {
54 t.Errorf("%d:%d: unexpected CCC. Was %d; want %d", j, k, ce.CCC(), tt.out[k])
56 if k > 0 && ce.CCC() == prevCCC && i.Elems[k-1].Primary() > ce.Primary() {
57 t.Errorf("%d:%d: normalization crossed across CCC boundary.", j, k)
62 // Combining rune overflow is tested in search/pattern_test.go.