summaryrefslogtreecommitdiff
path: root/src/strings/strings_test.go
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2019-04-09 08:32:22 +0200
committerTobias Klauser <tobias.klauser@gmail.com>2019-04-09 14:14:41 +0000
commit016625c26591d375a4bfcf83532ff8407860612a (patch)
tree0600a95ca5726f6eef94a3d0473a8f078ccd9d77 /src/strings/strings_test.go
parent78175474c4a93c2b18516d2127a160b83926c143 (diff)
downloadgo-git-016625c26591d375a4bfcf83532ff8407860612a.tar.gz
strings: add TestIndexByte
Add TestIndexByte to package strings similar to the already existing TestIndexByte in package bytes. Change-Id: Ib60695cb326156a4fe48138c66393ebbd11e4a25 Reviewed-on: https://go-review.googlesource.com/c/go/+/171197 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/strings/strings_test.go')
-rw-r--r--src/strings/strings_test.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/strings/strings_test.go b/src/strings/strings_test.go
index 8f0a7a1a0a..9766521615 100644
--- a/src/strings/strings_test.go
+++ b/src/strings/strings_test.go
@@ -199,6 +199,18 @@ func TestLastIndex(t *testing.T) { runIndexTests(t, LastIndex, "LastIndex", l
func TestIndexAny(t *testing.T) { runIndexTests(t, IndexAny, "IndexAny", indexAnyTests) }
func TestLastIndexAny(t *testing.T) { runIndexTests(t, LastIndexAny, "LastIndexAny", lastIndexAnyTests) }
+func TestIndexByte(t *testing.T) {
+ for _, tt := range indexTests {
+ if len(tt.sep) != 1 {
+ continue
+ }
+ pos := IndexByte(tt.s, tt.sep[0])
+ if pos != tt.out {
+ t.Errorf(`IndexByte(%q, %q) = %v; want %v`, tt.s, tt.sep[0], pos, tt.out)
+ }
+ }
+}
+
func TestLastIndexByte(t *testing.T) {
testCases := []IndexTest{
{"", "q", -1},