Commit 683917a7 authored by Dominik Honnef's avatar Dominik Honnef Committed by Brad Fitzpatrick

all: use bytes.Equal, bytes.Contains and strings.Contains, again

The previous cleanup was done with a buggy tool, missing some potential
rewrites.

Change-Id: I333467036e355f999a6a493e8de87e084f374e26
Reviewed-on: https://go-review.googlesource.com/21378Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 4f12cc08
......@@ -1466,7 +1466,7 @@ func TestGoTestWithPackageListedMultipleTimes(t *testing.T) {
defer tg.cleanup()
tg.parallel()
tg.run("test", "errors", "errors", "errors", "errors", "errors")
if strings.Index(strings.TrimSpace(tg.getStdout()), "\n") != -1 {
if strings.Contains(strings.TrimSpace(tg.getStdout()), "\n") {
t.Error("go test errors errors errors errors errors tested the same package multiple times")
}
}
......@@ -1495,7 +1495,7 @@ func TestGoListCmdOnlyShowsCommands(t *testing.T) {
tg.run("list", "cmd")
out := strings.TrimSpace(tg.getStdout())
for _, line := range strings.Split(out, "\n") {
if strings.Index(line, "cmd/") == -1 {
if !strings.Contains(line, "cmd/") {
t.Error("go list cmd shows non-commands")
break
}
......
......@@ -17,7 +17,7 @@ func urlFilter(args ...interface{}) string {
if t == contentTypeURL {
return s
}
if i := strings.IndexRune(s, ':'); i >= 0 && strings.IndexRune(s[:i], '/') < 0 {
if i := strings.IndexRune(s, ':'); i >= 0 && !strings.ContainsRune(s[:i], '/') {
protocol := strings.ToLower(s[:i])
if protocol != "http" && protocol != "https" && protocol != "mailto" {
return "#" + filterFailsafe
......
......@@ -4267,7 +4267,7 @@ func BenchmarkClient(b *testing.B) {
if err != nil {
b.Fatalf("ReadAll: %v", err)
}
if bytes.Compare(body, data) != 0 {
if !bytes.Equal(body, data) {
b.Fatalf("Got body: %q", body)
}
}
......
......@@ -1015,7 +1015,7 @@ func TestAbs(t *testing.T) {
vol := filepath.VolumeName(root)
var extra []string
for _, path := range absTests {
if strings.Index(path, "$") != -1 {
if strings.Contains(path, "$") {
continue
}
path = vol + path
......
......@@ -59,7 +59,7 @@ func TestGCInfo(t *testing.T) {
func verifyGCInfo(t *testing.T, name string, p interface{}, mask0 []byte) {
mask := runtime.GCMask(p)
if bytes.Compare(mask, mask0) != 0 {
if !bytes.Equal(mask, mask0) {
t.Errorf("bad GC program for %v:\nwant %+v\ngot %+v", name, mask0, mask)
return
}
......
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