You've already forked v2ray-core
simplify testing
This commit is contained in:
34
testing/assert/bytes.go
Normal file
34
testing/assert/bytes.go
Normal file
@@ -0,0 +1,34 @@
|
||||
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))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user