summaryrefslogtreecommitdiff
path: root/libgo/go/bytes/bytes_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/bytes/bytes_test.go')
-rw-r--r--libgo/go/bytes/bytes_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/libgo/go/bytes/bytes_test.go b/libgo/go/bytes/bytes_test.go
index 980c41d754d..6245e481805 100644
--- a/libgo/go/bytes/bytes_test.go
+++ b/libgo/go/bytes/bytes_test.go
@@ -265,6 +265,23 @@ func TestIndexByte(t *testing.T) {
}
}
+func TestLastIndexByte(t *testing.T) {
+ testCases := []BinOpTest{
+ {"", "q", -1},
+ {"abcdef", "q", -1},
+ {"abcdefabcdef", "a", len("abcdef")}, // something in the middle
+ {"abcdefabcdef", "f", len("abcdefabcde")}, // last byte
+ {"zabcdefabcdef", "z", 0}, // first byte
+ {"a☺b☻c☹d", "b", len("a☺")}, // non-ascii
+ }
+ for _, test := range testCases {
+ actual := LastIndexByte([]byte(test.a), test.b[0])
+ if actual != test.i {
+ t.Errorf("LastIndexByte(%q,%c) = %v; want %v", test.a, test.b[0], actual, test.i)
+ }
+ }
+}
+
// test a larger buffer with different sizes and alignments
func TestIndexByteBig(t *testing.T) {
var n = 1024