From 36114a35dc5af32181ba34add6a3110a6c5ca5c8 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Mon, 3 May 2010 10:59:00 -0700 Subject: 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 --- src/pkg/bytes/bytes_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/pkg/bytes/bytes_test.go') 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 { -- cgit v1.2.3