diff options
| author | Rob Pike <r@golang.org> | 2010-05-03 10:59:00 -0700 |
|---|---|---|
| committer | Rob Pike <r@golang.org> | 2010-05-03 10:59:00 -0700 |
| commit | e1d20d0a514289db48edfcadba3ae39f96f52335 (patch) | |
| tree | 21d0326d5000454ba28aab53885cca1dc82ba6c8 /src/pkg/bytes/bytes_test.go | |
| parent | 249c49ed3c3a24268600baa0fbd9680bde6de475 (diff) | |
| download | go-e1d20d0a514289db48edfcadba3ae39f96f52335.tar.xz | |
bytes: Change IndexAny to look for UTF-8 encoded characters.
Also improve the implementations of Equals and Compare.
R=rsc
CC=golang-dev
https://golang.org/cl/969047
Diffstat (limited to 'src/pkg/bytes/bytes_test.go')
| -rw-r--r-- | src/pkg/bytes/bytes_test.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/pkg/bytes/bytes_test.go b/src/pkg/bytes/bytes_test.go index df55ce3ccd..1394044214 100644 --- a/src/pkg/bytes/bytes_test.go +++ b/src/pkg/bytes/bytes_test.go @@ -119,6 +119,7 @@ var indexAnyTests = []BinOpTest{ BinOpTest{"aaa", "a", 0}, BinOpTest{"abc", "xyz", -1}, BinOpTest{"abc", "xcz", 2}, + BinOpTest{"ab☺c", "x☺yz", 2}, BinOpTest{"aRegExp*", ".(|)*+?^$[]", 7}, BinOpTest{dots + dots + dots, " ", -1}, } @@ -138,7 +139,15 @@ func runIndexTests(t *testing.T, f func(s, sep []byte) int, funcName string, tes func TestIndex(t *testing.T) { runIndexTests(t, Index, "Index", indexTests) } func TestLastIndex(t *testing.T) { runIndexTests(t, LastIndex, "LastIndex", lastIndexTests) } -func TestIndexAny(t *testing.T) { runIndexTests(t, IndexAny, "IndexAny", indexAnyTests) } +func TestIndexAny(t *testing.T) { + for _, test := range indexAnyTests { + a := []byte(test.a) + actual := IndexAny(a, test.b) + if actual != test.i { + t.Errorf("IndexAny(%q,%q) = %v; want %v", a, test.b, actual, test.i) + } + } +} func TestIndexByte(t *testing.T) { for _, tt := range indexTests { |
