mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
788 B
36 lines
788 B
9 years ago
|
package assert
|
||
9 years ago
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
9 years ago
|
func Bytes(value []byte) *BytesSubject {
|
||
|
return &BytesSubject{value: value}
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
type BytesSubject struct {
|
||
|
Subject
|
||
|
value []byte
|
||
9 years ago
|
}
|
||
|
|
||
|
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)
|
||
|
}
|
||
|
}
|