diff options
Diffstat (limited to 'libgo/go/strings/strings_test.go')
-rw-r--r-- | libgo/go/strings/strings_test.go | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/libgo/go/strings/strings_test.go b/libgo/go/strings/strings_test.go index 657c8e89064..734fdd33daa 100644 --- a/libgo/go/strings/strings_test.go +++ b/libgo/go/strings/strings_test.go @@ -86,6 +86,19 @@ var indexAnyTests = []IndexTest{ {"aRegExp*", ".(|)*+?^$[]", 7}, {dots + dots + dots, " ", -1}, } +var lastIndexAnyTests = []IndexTest{ + {"", "", -1}, + {"", "a", -1}, + {"", "abc", -1}, + {"a", "", -1}, + {"a", "a", 0}, + {"aaa", "a", 2}, + {"abc", "xyz", -1}, + {"abc", "ab", 1}, + {"a☺b☻c☹d", "uvw☻xyz", 2 + len("☺")}, + {"a.RegExp*", ".(|)*+?^$[]", 8}, + {dots + dots + dots, " ", -1}, +} // Execute f on each test case. funcName should be the name of f; it's used // in failure reports. @@ -98,9 +111,10 @@ func runIndexTests(t *testing.T, f func(s, sep string) 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 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 TestLastIndexAny(t *testing.T) { runIndexTests(t, LastIndexAny, "LastIndexAny", lastIndexAnyTests) } type ExplodeTest struct { s string |