diff options
| author | Ondřej Surý <ondrej@sury.org> | 2011-09-13 13:13:44 +0200 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2011-09-13 13:13:44 +0200 |
| commit | 9464a0c36318f8a801c07d6874bd0cea40f12504 (patch) | |
| tree | f0178491c19d4f1ebc7b92eede86690998466480 /src/pkg/index/suffixarray/suffixarray_test.go | |
| parent | ba9fda6068cfadd42db0b152fdca7e8b67aaf77d (diff) | |
| parent | 5ff4c17907d5b19510a62e08fd8d3b11e62b431d (diff) | |
| download | golang-9464a0c36318f8a801c07d6874bd0cea40f12504.tar.gz | |
Merge commit 'upstream/60' into debian-sid
Diffstat (limited to 'src/pkg/index/suffixarray/suffixarray_test.go')
| -rw-r--r-- | src/pkg/index/suffixarray/suffixarray_test.go | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/src/pkg/index/suffixarray/suffixarray_test.go b/src/pkg/index/suffixarray/suffixarray_test.go index 385ff0e56..023748500 100644 --- a/src/pkg/index/suffixarray/suffixarray_test.go +++ b/src/pkg/index/suffixarray/suffixarray_test.go @@ -6,21 +6,18 @@ package suffixarray import ( "bytes" - "container/vector" "regexp" "sort" "strings" "testing" ) - type testCase struct { name string // name of test case source string // source to index patterns []string // patterns to lookup } - var testCases = []testCase{ { "empty string", @@ -107,10 +104,9 @@ var testCases = []testCase{ }, } - // find all occurrences of s in source; report at most n occurrences func find(src, s string, n int) []int { - var res vector.IntVector + var res []int if s != "" && n != 0 { // find at most n occurrences of s in src for i := -1; n < 0 || len(res) < n; { @@ -119,13 +115,12 @@ func find(src, s string, n int) []int { break } i += j + 1 - res.Push(i) + res = append(res, i) } } return res } - func testLookup(t *testing.T, tc *testCase, x *Index, s string, n int) { res := x.Lookup([]byte(s), n) exp := find(tc.source, s, n) @@ -164,7 +159,6 @@ func testLookup(t *testing.T, tc *testCase, x *Index, s string, n int) { } } - func testFindAllIndex(t *testing.T, tc *testCase, x *Index, rx *regexp.Regexp, n int) { res := x.FindAllIndex(rx, n) exp := rx.FindAllStringIndex(tc.source, n) @@ -200,7 +194,6 @@ func testFindAllIndex(t *testing.T, tc *testCase, x *Index, rx *regexp.Regexp, n } } - func testLookups(t *testing.T, tc *testCase, x *Index, n int) { for _, pat := range tc.patterns { testLookup(t, tc, x, pat, n) @@ -210,7 +203,6 @@ func testLookups(t *testing.T, tc *testCase, x *Index, n int) { } } - // index is used to hide the sort.Interface type index Index @@ -219,14 +211,12 @@ func (x *index) Less(i, j int) bool { return bytes.Compare(x.at(i), x.at(j)) < 0 func (x *index) Swap(i, j int) { x.sa[i], x.sa[j] = x.sa[j], x.sa[i] } func (a *index) at(i int) []byte { return a.data[a.sa[i]:] } - func testConstruction(t *testing.T, tc *testCase, x *Index) { if !sort.IsSorted((*index)(x)) { t.Errorf("testConstruction failed %s", tc.name) } } - func TestIndex(t *testing.T) { for _, tc := range testCases { x := New([]byte(tc.source)) |
