summaryrefslogtreecommitdiff
path: root/src/pkg/bytes/bytes_test.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2010-05-03 10:59:00 -0700
committerRob Pike <r@golang.org>2010-05-03 10:59:00 -0700
commit36114a35dc5af32181ba34add6a3110a6c5ca5c8 (patch)
treef4a8efc81b30ff621ca0c168989bdd3ecac7020f /src/pkg/bytes/bytes_test.go
parent033fd9bff8d1cab5b7a6e7c9cebdf4caa7950b0e (diff)
downloadgolang-36114a35dc5af32181ba34add6a3110a6c5ca5c8.tar.gz
bytes: Change IndexAny to look for UTF-8 encoded characters.
Also improve the implementations of Equals and Compare. R=rsc CC=golang-dev http://codereview.appspot.com/969047
Diffstat (limited to 'src/pkg/bytes/bytes_test.go')
-rw-r--r--src/pkg/bytes/bytes_test.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/pkg/bytes/bytes_test.go b/src/pkg/bytes/bytes_test.go
index df55ce3cc..139404421 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 {