if err != nil {
log.Fatalf("could not read target: %v", err)
}
- if bytes.Index(out, []byte("scanInt")) != -1 {
+ if bytes.Contains(out, []byte("scanInt")) {
log.Fatalf("scanf code not removed from helloworld")
}
}
if err != nil {
t.Error(err)
}
- if bytes.Index(data, []byte("\r\n")) < 0 {
+ if !bytes.Contains(data, []byte("\r\n")) {
t.Errorf("%s contains no CR/LF's", input)
}
if err != nil {
t.Error(err)
}
- if bytes.Index(data, []byte("\r")) >= 0 {
+ if bytes.Contains(data, []byte("\r")) {
t.Errorf("%s contains CR's", golden)
}
}
b1b := b1.Bytes()
b2b := b2.Bytes()
- if bytes.Compare(b1b, b2b) != 0 {
+ if !bytes.Equal(b1b, b2b) {
t.Errorf("level %d did not produce deterministic result, result mismatch, len(a) = %d, len(b) = %d", i, len(b1b), len(b2b))
}
}
d2 := make([]byte, 1024+alignD)[alignD:]
xorBytes(d1, p, q)
safeXORBytes(d2, p, q)
- if bytes.Compare(d1, d2) != 0 {
+ if !bytes.Equal(d1, d2) {
t.Error("not equal")
}
}
continue
}
for k, cert := range chain {
- if strings.Index(nameToKey(&cert.Subject), expectedChain[k]) == -1 {
+ if !strings.Contains(nameToKey(&cert.Subject), expectedChain[k]) {
continue TryNextExpected
}
}
t.Errorf("%s: ExtraExtensions didn't override SubjectKeyId", test.name)
}
- if bytes.Index(derBytes, extraExtensionData) == -1 {
+ if !bytes.Contains(derBytes, extraExtensionData) {
t.Errorf("%s: didn't find extra extension in DER output", test.name)
}
}
case reflect.Slice:
b := vf.Bytes()
- dashDash = bytes.Index(b, ddBytes) >= 0
+ dashDash = bytes.Contains(b, ddBytes)
dashLast = b[len(b)-1] == '-'
if !dashDash {
p.Write(b)
}
}
id = bytes.ToLower(id)
- if bytes.Index(id, expressionBytes) != -1 || bytes.Index(id, mozBindingBytes) != -1 {
+ if bytes.Contains(id, expressionBytes) || bytes.Contains(id, mozBindingBytes) {
return filterFailsafe
}
return string(b)
}
continue
}
- if strings.Index(got, test.err) == -1 {
+ if !strings.Contains(got, test.err) {
t.Errorf("input=%q: error\n\t%q\ndoes not contain expected string\n\t%q", test.input, got, test.err)
continue
}
if off != 16 || err != nil {
return nil, fmt.Errorf("failed to read header: read %v, err %v", off, err)
}
- if bytes.Compare(buf[:], []byte("go 1.5 trace\x00\x00\x00\x00")) != 0 {
+ if !bytes.Equal(buf[:], []byte("go 1.5 trace\x00\x00\x00\x00")) {
return nil, fmt.Errorf("not a trace file")
}