forked from v2ray/v2ray-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uint16subject.go
54 lines (44 loc) · 1.23 KB
/
uint16subject.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
46
47
48
49
50
51
52
53
54
package unit
import (
"strconv"
)
type Uint16Subject struct {
*Subject
value uint16
}
func NewUint16Subject(base *Subject, value uint16) *Uint16Subject {
return &Uint16Subject{
Subject: base,
value: value,
}
}
func (subject *Uint16Subject) Named(name string) *Uint16Subject {
subject.Subject.Named(name)
return subject
}
func (subject *Uint16Subject) Fail(verb string, other uint16) {
subject.FailWithMessage("Not true that " + subject.DisplayString() + " " + verb + " <" + strconv.Itoa(int(other)) + ">.")
}
func (subject *Uint16Subject) DisplayString() string {
return subject.Subject.DisplayString(strconv.Itoa(int(subject.value)))
}
func (subject *Uint16Subject) Equals(expectation uint16) {
if subject.value != expectation {
subject.Fail("is equal to", expectation)
}
}
func (subject *Uint16Subject) GreaterThan(expectation uint16) {
if subject.value <= expectation {
subject.Fail("is greater than", expectation)
}
}
func (subject *Uint16Subject) LessThan(expectation uint16) {
if subject.value >= expectation {
subject.Fail("is less than", expectation)
}
}
func (subject *Uint16Subject) Positive() {
if subject.value <= 0 {
subject.FailWithMessage("Not true that " + subject.DisplayString() + " is positive.")
}
}