From 14bbb58b12652eea95baf641fa2eac7989f11601 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Mon, 6 Feb 2017 23:25:52 +0100 Subject: [PATCH] fix bytes assertion --- testing/assert/bytes.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/testing/assert/bytes.go b/testing/assert/bytes.go index 70f121f29..f1c5dda07 100644 --- a/testing/assert/bytes.go +++ b/testing/assert/bytes.go @@ -3,6 +3,8 @@ package assert import ( "bytes" + "fmt" + "v2ray.com/core/common/serial" ) @@ -22,8 +24,14 @@ type BytesSubject struct { } func (subject *BytesSubject) Equals(expectation []byte) { - if !bytes.Equal(subject.value, expectation) { - subject.Fail("is equal to", serial.BytesToHexString(expectation)) + if len(subject.value) != len(expectation) { + subject.FailWithMessage(fmt.Sprint("Bytes arrays have differen size: expected", len(expectation), ", actual", len(subject.value))) + } + for idx, b := range expectation { + if subject.value[idx] != b { + subject.FailWithMessage(fmt.Sprint("Bytes are different:", b, "vs", subject.value[idx])) + return + } } }