Commit 872f5ffa authored by Shawn Smith's avatar Shawn Smith Committed by Dave Cheney

bytes: add test for Contains

R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/46140043
parent 42cea1a4
......@@ -1162,6 +1162,24 @@ func TestBufferTruncateOutOfRange(t *testing.T) {
b.Truncate(20)
}
var containsTests = []struct {
b, subslice []byte
want bool
}{
{[]byte("hello"), []byte("hel"), true},
{[]byte("日本語"), []byte("日本"), true},
{[]byte("hello"), []byte("Hello, world"), false},
{[]byte("東京"), []byte("京東"), false},
}
func TestContains(t *testing.T) {
for _, tt := range containsTests {
if got := Contains(tt.b, tt.subslice); got != tt.want {
t.Errorf("Contains(%q, %q) = %v, want %v", tt.b, tt.subslice, got, tt.want)
}
}
}
var makeFieldsInput = func() []byte {
x := make([]byte, 1<<20)
// Input is ~10% space, ~10% 2-byte UTF-8, rest ASCII non-space.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment