-
Notifications
You must be signed in to change notification settings - Fork 0
/
bytesubject.go
45 lines (36 loc) · 1016 Bytes
/
bytesubject.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
42
43
44
45
package assert
import (
"strconv"
)
func Byte(value byte) *ByteSubject {
return &ByteSubject{value: value}
}
type ByteSubject struct {
Subject
value byte
}
func (subject *ByteSubject) Named(name string) *ByteSubject {
subject.Subject.Named(name)
return subject
}
func (subject *ByteSubject) Fail(verb string, other byte) {
subject.FailWithMessage("Not true that " + subject.DisplayString() + " " + verb + " <" + strconv.Itoa(int(other)) + ">.")
}
func (subject *ByteSubject) DisplayString() string {
return subject.Subject.DisplayString(strconv.Itoa(int(subject.value)))
}
func (subject *ByteSubject) Equals(expectation byte) {
if subject.value != expectation {
subject.Fail("is equal to", expectation)
}
}
func (subject *ByteSubject) GreaterThan(expectation byte) {
if subject.value <= expectation {
subject.Fail("is greater than", expectation)
}
}
func (subject *ByteSubject) LessThan(expectation byte) {
if subject.value >= expectation {
subject.Fail("is less than", expectation)
}
}