mirror of
https://github.com/golang/go
synced 2024-11-13 18:00:30 -07:00
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/21378 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
4f12cc0813
commit
683917a721
@ -1466,7 +1466,7 @@ func TestGoTestWithPackageListedMultipleTimes(t *testing.T) {
|
|||||||
defer tg.cleanup()
|
defer tg.cleanup()
|
||||||
tg.parallel()
|
tg.parallel()
|
||||||
tg.run("test", "errors", "errors", "errors", "errors", "errors")
|
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")
|
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")
|
tg.run("list", "cmd")
|
||||||
out := strings.TrimSpace(tg.getStdout())
|
out := strings.TrimSpace(tg.getStdout())
|
||||||
for _, line := range strings.Split(out, "\n") {
|
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")
|
t.Error("go list cmd shows non-commands")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ func urlFilter(args ...interface{}) string {
|
|||||||
if t == contentTypeURL {
|
if t == contentTypeURL {
|
||||||
return s
|
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])
|
protocol := strings.ToLower(s[:i])
|
||||||
if protocol != "http" && protocol != "https" && protocol != "mailto" {
|
if protocol != "http" && protocol != "https" && protocol != "mailto" {
|
||||||
return "#" + filterFailsafe
|
return "#" + filterFailsafe
|
||||||
|
@ -4267,7 +4267,7 @@ func BenchmarkClient(b *testing.B) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("ReadAll: %v", err)
|
b.Fatalf("ReadAll: %v", err)
|
||||||
}
|
}
|
||||||
if bytes.Compare(body, data) != 0 {
|
if !bytes.Equal(body, data) {
|
||||||
b.Fatalf("Got body: %q", body)
|
b.Fatalf("Got body: %q", body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1015,7 +1015,7 @@ func TestAbs(t *testing.T) {
|
|||||||
vol := filepath.VolumeName(root)
|
vol := filepath.VolumeName(root)
|
||||||
var extra []string
|
var extra []string
|
||||||
for _, path := range absTests {
|
for _, path := range absTests {
|
||||||
if strings.Index(path, "$") != -1 {
|
if strings.Contains(path, "$") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
path = vol + path
|
path = vol + path
|
||||||
|
@ -59,7 +59,7 @@ func TestGCInfo(t *testing.T) {
|
|||||||
|
|
||||||
func verifyGCInfo(t *testing.T, name string, p interface{}, mask0 []byte) {
|
func verifyGCInfo(t *testing.T, name string, p interface{}, mask0 []byte) {
|
||||||
mask := runtime.GCMask(p)
|
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)
|
t.Errorf("bad GC program for %v:\nwant %+v\ngot %+v", name, mask0, mask)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user