mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-12-27 20:45:28 -05:00
massive refactoring against unit test lib
This commit is contained in:
35
testing/assert/bytessubject.go
Normal file
35
testing/assert/bytessubject.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package assert
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func Bytes(value []byte) *BytesSubject {
|
||||
return &BytesSubject{value: value}
|
||||
}
|
||||
|
||||
type BytesSubject struct {
|
||||
Subject
|
||||
value []byte
|
||||
}
|
||||
|
||||
func (subject *BytesSubject) Named(name string) *BytesSubject {
|
||||
subject.Subject.Named(name)
|
||||
return subject
|
||||
}
|
||||
|
||||
func (subject *BytesSubject) Fail(verb string, other []byte) {
|
||||
otherString := fmt.Sprintf("%v", other)
|
||||
subject.FailWithMessage("Not true that " + subject.DisplayString() + " " + verb + " <" + otherString + ">.")
|
||||
}
|
||||
|
||||
func (subject *BytesSubject) DisplayString() string {
|
||||
return subject.Subject.DisplayString(fmt.Sprintf("%v", subject.value))
|
||||
}
|
||||
|
||||
func (subject *BytesSubject) Equals(expectation []byte) {
|
||||
if !bytes.Equal(subject.value, expectation) {
|
||||
subject.Fail("is equal to", expectation)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user