forked from v2ray/v2ray-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bytessubject.go
38 lines (31 loc) · 837 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
package unit
import (
"bytes"
"fmt"
)
type BytesSubject struct {
*Subject
value []byte
}
func NewBytesSubject(base *Subject, value []byte) *BytesSubject {
return &BytesSubject{
Subject: base,
value: value,
}
}
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)
}
}