forked from v2ray/v2ray-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbytessubject.go
41 lines (33 loc) · 948 Bytes
/
bytessubject.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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)
}
}
func (subject *BytesSubject) NotEquals(expectation []byte) {
if bytes.Equal(subject.value, expectation) {
subject.Fail("is not equal to", expectation)
}
}