mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 10:08:15 -05:00
fix bytes assertion
This commit is contained in:
parent
a8abd68574
commit
14bbb58b12
@ -3,6 +3,8 @@ package assert
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"v2ray.com/core/common/serial"
|
"v2ray.com/core/common/serial"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,8 +24,14 @@ type BytesSubject struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (subject *BytesSubject) Equals(expectation []byte) {
|
func (subject *BytesSubject) Equals(expectation []byte) {
|
||||||
if !bytes.Equal(subject.value, expectation) {
|
if len(subject.value) != len(expectation) {
|
||||||
subject.Fail("is equal to", serial.BytesToHexString(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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user