From 72ed30e3e530a90580a6e034a62a87204aaf22d2 Mon Sep 17 00:00:00 2001 From: Andras Banki-Horvath Date: Thu, 9 Apr 2020 19:19:12 +0200 Subject: [PATCH] tlv: simplify byte slice comparison as recommenteded by static analysis --- tlv/truncated_test.go | 6 +++--- tlv/varint_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tlv/truncated_test.go b/tlv/truncated_test.go index eb0f83a7..f530d0b6 100644 --- a/tlv/truncated_test.go +++ b/tlv/truncated_test.go @@ -77,7 +77,7 @@ func TestTUint16(t *testing.T) { t.Fatalf("unable to encode tuint16: %v", err) } - if bytes.Compare(b.Bytes(), test.bytes) != 0 { + if !bytes.Equal(b.Bytes(), test.bytes) { t.Fatalf("encoding mismatch, "+ "expected: %x, got: %x", test.bytes, b.Bytes()) @@ -201,7 +201,7 @@ func TestTUint32(t *testing.T) { t.Fatalf("unable to encode tuint32: %v", err) } - if bytes.Compare(b.Bytes(), test.bytes) != 0 { + if !bytes.Equal(b.Bytes(), test.bytes) { t.Fatalf("encoding mismatch, "+ "expected: %x, got: %x", test.bytes, b.Bytes()) @@ -371,7 +371,7 @@ func TestTUint64(t *testing.T) { t.Fatalf("unable to encode tuint64: %v", err) } - if bytes.Compare(b.Bytes(), test.bytes) != 0 { + if !bytes.Equal(b.Bytes(), test.bytes) { t.Fatalf("encoding mismatch, "+ "expected: %x, got: %x", test.bytes, b.Bytes()) diff --git a/tlv/varint_test.go b/tlv/varint_test.go index 75cc1085..30a2f851 100644 --- a/tlv/varint_test.go +++ b/tlv/varint_test.go @@ -80,7 +80,7 @@ func testWriteVarInt(t *testing.T, test varIntTest) { test.Value, err) } - if bytes.Compare(w.Bytes(), test.Bytes) != 0 { + if !bytes.Equal(w.Bytes(), test.Bytes) { t.Fatalf("expected bytes: %v, got %v", test.Bytes, w.Bytes()) }