diff options
Diffstat (limited to 'libgo/go/regexp/find_test.go')
-rw-r--r-- | libgo/go/regexp/find_test.go | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/libgo/go/regexp/find_test.go b/libgo/go/regexp/find_test.go index e07eb7d5c05..87c49b074fa 100644 --- a/libgo/go/regexp/find_test.go +++ b/libgo/go/regexp/find_test.go @@ -161,6 +161,9 @@ func TestFind(t *testing.T) { t.Errorf("expected match; got none: %s", test) case test.matches != nil && result != nil: expect := test.text[test.matches[0][0]:test.matches[0][1]] + if len(result) != cap(result) { + t.Errorf("expected capacity %d got %d: %s", len(result), cap(result), test) + } if expect != string(result) { t.Errorf("expected %q got %q: %s", expect, result, test) } @@ -242,9 +245,13 @@ func TestFindAll(t *testing.T) { continue } for k, e := range test.matches { + got := result[k] + if len(got) != cap(got) { + t.Errorf("match %d: expected capacity %d got %d: %s", k, len(got), cap(got), test) + } expect := test.text[e[0]:e[1]] - if expect != string(result[k]) { - t.Errorf("match %d: expected %q got %q: %s", k, expect, result[k], test) + if expect != string(got) { + t.Errorf("match %d: expected %q got %q: %s", k, expect, got, test) } } } @@ -323,9 +330,14 @@ func testSubmatchBytes(test *FindTest, n int, submatches []int, result [][]byte, } continue } + got := result[k/2] + if len(got) != cap(got) { + t.Errorf("match %d: expected capacity %d got %d: %s", n, len(got), cap(got), test) + return + } expect := test.text[submatches[k]:submatches[k+1]] - if expect != string(result[k/2]) { - t.Errorf("match %d: expected %q got %q: %s", n, expect, result, test) + if expect != string(got) { + t.Errorf("match %d: expected %q got %q: %s", n, expect, got, test) return } } |