simplify testing

This commit is contained in:
v2ray
2016-05-24 21:55:46 +02:00
parent 3582b9d869
commit fc63f0432c
99 changed files with 726 additions and 817 deletions

34
testing/assert/bytes.go Normal file
View 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))
}
}