1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-02 09:17:55 -04:00
v2fly/testing/assert/bytes.go

35 lines
681 B
Go
Raw Normal View History

2016-05-24 15:55:46 -04:00
package assert
import (
"bytes"
"github.com/v2ray/v2ray-core/common/serial"
)
func (this *Assert) Bytes(value []byte) *BytesSubject {
return &BytesSubject{
Subject: Subject{
disp: serial.BytesToHexString(value),
a: this,
},
value: value,
}
}
type BytesSubject struct {
Subject
value []byte
}
func (subject *BytesSubject) Equals(expectation []byte) {
if !bytes.Equal(subject.value, expectation) {
subject.Fail("is equal to", serial.BytesToHexString(expectation))
}
}
func (subject *BytesSubject) NotEquals(expectation []byte) {
if bytes.Equal(subject.value, expectation) {
subject.Fail("is not equal to", serial.BytesToHexString(expectation))
}
}