automagic simplification
This commit is contained in:
parent
79287d7e47
commit
bf64d7bdc2
|
@ -35,7 +35,7 @@ func TestBMPStringDecode(t *testing.T) {
|
|||
|
||||
func TestBMPString(t *testing.T) {
|
||||
str, err := bmpString("")
|
||||
if bytes.Compare(str, []byte{0, 0}) != 0 {
|
||||
if !bytes.Equal(str, []byte{0, 0}) {
|
||||
t.Errorf("expected empty string to return double 0, but found: % x", str)
|
||||
}
|
||||
if err != nil {
|
||||
|
@ -44,7 +44,7 @@ func TestBMPString(t *testing.T) {
|
|||
|
||||
// Example from https://tools.ietf.org/html/rfc7292#appendix-B
|
||||
str, err = bmpString("Beavis")
|
||||
if bytes.Compare(str, []byte{0x00, 0x42, 0x00, 0x65, 0x00, 0x61, 0x00, 0x0076, 0x00, 0x69, 0x00, 0x73, 0x00, 0x00}) != 0 {
|
||||
if !bytes.Equal(str, []byte{0x00, 0x42, 0x00, 0x65, 0x00, 0x61, 0x00, 0x0076, 0x00, 0x69, 0x00, 0x73, 0x00, 0x00}) {
|
||||
t.Errorf("expected 'Beavis' to return 0x00 0x42 0x00 0x65 0x00 0x61 0x00 0x76 0x00 0x69 0x00 0x73 0x00 0x00, but found: % x", str)
|
||||
}
|
||||
if err != nil {
|
||||
|
@ -54,7 +54,7 @@ func TestBMPString(t *testing.T) {
|
|||
// some characters from the "Letterlike Symbols Unicode block"
|
||||
tst := "\u2115 - Double-struck N"
|
||||
str, err = bmpString(tst)
|
||||
if bytes.Compare(str, []byte{0x21, 0x15, 0x00, 0x20, 0x00, 0x2d, 0x00, 0x20, 0x00, 0x44, 0x00, 0x6f, 0x00, 0x75, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x2d, 0x00, 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x75, 0x00, 0x63, 0x00, 0x6b, 0x00, 0x20, 0x00, 0x4e, 0x00, 0x00}) != 0 {
|
||||
if !bytes.Equal(str, []byte{0x21, 0x15, 0x00, 0x20, 0x00, 0x2d, 0x00, 0x20, 0x00, 0x44, 0x00, 0x6f, 0x00, 0x75, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x2d, 0x00, 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x75, 0x00, 0x63, 0x00, 0x6b, 0x00, 0x20, 0x00, 0x4e, 0x00, 0x00}) {
|
||||
t.Errorf("expected '%s' to return 0x21 0x15 0x00 0x20 0x00 0x2d 0x00 0x20 0x00 0x44 0x00 0x6f 0x00 0x75 0x00 0x62 0x00 0x6c 0x00 0x65 0x00 0x2d 0x00 0x73 0x00 0x74 0x00 0x72 0x00 0x75 0x00 0x63 0x00 0x6b 0x00 0x20 0x00 0x4e 0x00 0x00, but found: % x", tst, str)
|
||||
}
|
||||
if err != nil {
|
||||
|
|
|
@ -47,7 +47,7 @@ func pbDecrypt(info decryptable, password []byte) (decrypted []byte, err error)
|
|||
if psLen := int(decrypted[len(decrypted)-1]); psLen > 0 && psLen <= cbc.BlockSize() {
|
||||
m := decrypted[:len(decrypted)-psLen]
|
||||
ps := decrypted[len(decrypted)-psLen:]
|
||||
if bytes.Compare(ps, bytes.Repeat([]byte{byte(psLen)}, psLen)) != 0 {
|
||||
if !bytes.Equal(ps, bytes.Repeat([]byte{byte(psLen)}, psLen)) {
|
||||
return nil, ErrDecryption
|
||||
}
|
||||
decrypted = m
|
||||
|
@ -87,7 +87,7 @@ func TestPbDecrypterFor(t *testing.T) {
|
|||
expectedM := []byte{185, 73, 135, 249, 137, 1, 122, 247}
|
||||
cbc.CryptBlocks(M, M)
|
||||
|
||||
if bytes.Compare(M, expectedM) != 0 {
|
||||
if !bytes.Equal(M, expectedM) {
|
||||
t.Errorf("expected M to be '%d', but found '%d", expectedM, M)
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ func TestPbDecrypt(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Errorf("error decrypting C=%x: %v", c, err)
|
||||
}
|
||||
if bytes.Compare(m, e) != 0 {
|
||||
if !bytes.Equal(m, e) {
|
||||
t.Errorf("expected C=%x to be decoded to M=%x, but found %x", c, e, m)
|
||||
}
|
||||
case error:
|
||||
|
|
|
@ -12,7 +12,7 @@ func TestThatPBKDFWorksCorrectlyForLongKeys(t *testing.T) {
|
|||
password, _ := bmpString("sesame")
|
||||
key := pbkdf(salt, password, 2048)
|
||||
|
||||
if expected := []byte("\x7c\xd9\xfd\x3e\x2b\x3b\xe7\x69\x1a\x44\xe3\xbe\xf0\xf9\xea\x0f\xb9\xb8\x97\xd4\xe3\x25\xd9\xd1"); bytes.Compare(key, expected) != 0 {
|
||||
if expected := []byte("\x7c\xd9\xfd\x3e\x2b\x3b\xe7\x69\x1a\x44\xe3\xbe\xf0\xf9\xea\x0f\xb9\xb8\x97\xd4\xe3\x25\xd9\xd1"); !bytes.Equal(key, expected) {
|
||||
t.Fatalf("expected key '% x', but found '% x'", key, expected)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ func TestAWSProvider_ArtifactId(t *testing.T) {
|
|||
t.Fatalf("should not have error: %s", err)
|
||||
}
|
||||
result := `aws.region_config "us-east-1", ami: "ami-1234"`
|
||||
if strings.Index(vagrantfile, result) == -1 {
|
||||
if !strings.Contains(vagrantfile, result) {
|
||||
t.Fatalf("wrong substitution: %s", vagrantfile)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,11 +31,11 @@ func TestDigitalOceanProvider_ArtifactId(t *testing.T) {
|
|||
t.Fatalf("should not have error: %s", err)
|
||||
}
|
||||
image := `digital_ocean.image = "42"`
|
||||
if strings.Index(vagrantfile, image) == -1 {
|
||||
if !strings.Contains(vagrantfile, image) {
|
||||
t.Fatalf("wrong image substitution: %s", vagrantfile)
|
||||
}
|
||||
region := `digital_ocean.region = "San Francisco"`
|
||||
if strings.Index(vagrantfile, region) == -1 {
|
||||
if !strings.Contains(vagrantfile, region) {
|
||||
t.Fatalf("wrong region substitution: %s", vagrantfile)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue