2016-05-24 15:55:46 -04:00
|
|
|
package assert
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
|
2016-08-20 14:55:45 -04:00
|
|
|
"v2ray.com/core/common/serial"
|
2016-05-24 15:55:46 -04:00
|
|
|
)
|
|
|
|
|
2016-11-27 15:39:09 -05:00
|
|
|
func (v *Assert) Bytes(value []byte) *BytesSubject {
|
2016-05-24 15:55:46 -04:00
|
|
|
return &BytesSubject{
|
|
|
|
Subject: Subject{
|
|
|
|
disp: serial.BytesToHexString(value),
|
2016-11-27 15:39:09 -05:00
|
|
|
a: v,
|
2016-05-24 15:55:46 -04:00
|
|
|
},
|
|
|
|
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))
|
|
|
|
}
|
|
|
|
}
|