Home | History | Annotate | Download | only in suffixarray

Lines Matching refs:tc

125 func testLookup(t *testing.T, tc *testCase, x *Index, s string, n int) {
127 exp := find(tc.source, s, n)
131 t.Errorf("test %q, lookup %q (n = %d): expected %d results; got %d", tc.name, s, n, len(exp), len(res))
142 if r < 0 || len(tc.source) <= r {
143 t.Errorf("test %q, lookup %q, result %d (n = %d): index %d out of range [0, %d[", tc.name, s, i, n, r, len(tc.source))
144 } else if !strings.HasPrefix(tc.source[r:], s) {
145 t.Errorf("test %q, lookup %q, result %d (n = %d): index %d not a match", tc.name, s, i, n, r)
148 t.Errorf("test %q, lookup %q, result %d (n = %d): found duplicate index %d", tc.name, s, i, n, r)
157 t.Errorf("test %q, lookup %q, result %d: expected index %d; got %d", tc.name, s, i, e, r)
163 func testFindAllIndex(t *testing.T, tc *testCase, x *Index, rx *regexp.Regexp, n int) {
165 exp := rx.FindAllStringIndex(tc.source, n)
169 t.Errorf("test %q, FindAllIndex %q (n = %d): expected %d results; got %d", tc.name, rx, n, len(exp), len(res))
179 if r[0] < 0 || r[0] > r[1] || len(tc.source) < r[1] {
180 t.Errorf("test %q, FindAllIndex %q, result %d (n == %d): illegal match [%d, %d]", tc.name, rx, i, n, r[0], r[1])
181 } else if !rx.MatchString(tc.source[r[0]:r[1]]) {
182 t.Errorf("test %q, FindAllIndex %q, result %d (n = %d): [%d, %d] not a match", tc.name, rx, i, n, r[0], r[1])
192 tc.name, rx, i, e[0], e[1], r[0], r[1])
198 func testLookups(t *testing.T, tc *testCase, x *Index, n int) {
199 for _, pat := range tc.patterns {
200 testLookup(t, tc, x, pat, n)
202 testFindAllIndex(t, tc, x, rx, n)
215 func testConstruction(t *testing.T, tc *testCase, x *Index) {
217 t.Errorf("failed testConstruction %s", tc.name)
234 func testSaveRestore(t *testing.T, tc *testCase, x *Index) int {
237 t.Errorf("failed writing index %s (%s)", tc.name, err)
242 t.Errorf("failed reading index %s (%s)", tc.name, err)
245 t.Errorf("restored index doesn't match saved index %s", tc.name)
251 for _, tc := range testCases {
252 x := New([]byte(tc.source))
253 testConstruction(t, &tc, x)
254 testSaveRestore(t, &tc, x)
255 testLookups(t, &tc, x, 0)
256 testLookups(t, &tc, x, 1)
257 testLookups(t, &tc, x, 10)
258 testLookups(t, &tc, x, 2e9)
259 testLookups(t, &tc, x, -1)