lib: Use bytes.Equal instead of bytes.Compare where possible

This commit is contained in:
Jakob Borg
2016-03-31 15:12:46 +00:00
committed by Audrius Butkevicius
parent b6f32b6e45
commit f5f0e46016
8 changed files with 21 additions and 21 deletions

View File

@@ -97,7 +97,7 @@ func TestRequest(t *testing.T) {
if err != nil {
t.Error(err)
}
if bytes.Compare(bs, []byte("foobar")) != 0 {
if !bytes.Equal(bs, []byte("foobar")) {
t.Errorf("Incorrect data from request: %q", string(bs))
}
@@ -407,13 +407,13 @@ func TestClusterConfig(t *testing.T) {
if l := len(r.Devices); l != 2 {
t.Errorf("Incorrect number of devices %d != 2", l)
}
if id := r.Devices[0].ID; bytes.Compare(id, device1[:]) != 0 {
if id := r.Devices[0].ID; !bytes.Equal(id, device1[:]) {
t.Errorf("Incorrect device ID %x != %x", id, device1)
}
if r.Devices[0].Flags&protocol.FlagIntroducer == 0 {
t.Error("Device1 should be flagged as Introducer")
}
if id := r.Devices[1].ID; bytes.Compare(id, device2[:]) != 0 {
if id := r.Devices[1].ID; !bytes.Equal(id, device2[:]) {
t.Errorf("Incorrect device ID %x != %x", id, device2)
}
if r.Devices[1].Flags&protocol.FlagIntroducer != 0 {
@@ -427,13 +427,13 @@ func TestClusterConfig(t *testing.T) {
if l := len(r.Devices); l != 2 {
t.Errorf("Incorrect number of devices %d != 2", l)
}
if id := r.Devices[0].ID; bytes.Compare(id, device1[:]) != 0 {
if id := r.Devices[0].ID; !bytes.Equal(id, device1[:]) {
t.Errorf("Incorrect device ID %x != %x", id, device1)
}
if r.Devices[0].Flags&protocol.FlagIntroducer == 0 {
t.Error("Device1 should be flagged as Introducer")
}
if id := r.Devices[1].ID; bytes.Compare(id, device2[:]) != 0 {
if id := r.Devices[1].ID; !bytes.Equal(id, device2[:]) {
t.Errorf("Incorrect device ID %x != %x", id, device2)
}
if r.Devices[1].Flags&protocol.FlagIntroducer != 0 {