1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-25 00:45:24 +00:00

fix bytes assertion

This commit is contained in:
Darien Raymond 2017-02-06 23:25:52 +01:00
parent a8abd68574
commit 14bbb58b12
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -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
}
}
}