forked from v2ray/v2ray-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintsubject.go
41 lines (33 loc) · 1 KB
/
intsubject.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 (
"github.com/v2ray/v2ray-core/common/serial"
)
func Int(value int) *IntSubject {
return &IntSubject{value: serial.IntLiteral(value)}
}
type IntSubject struct {
Subject
value serial.IntLiteral
}
func (subject *IntSubject) Named(name string) *IntSubject {
subject.Subject.Named(name)
return subject
}
func (subject *IntSubject) DisplayString() string {
return subject.Subject.DisplayString(subject.value.String())
}
func (subject *IntSubject) Equals(expectation int) {
if subject.value.Value() != expectation {
subject.Fail(subject.DisplayString(), "is equal to", serial.IntLiteral(expectation))
}
}
func (subject *IntSubject) GreaterThan(expectation int) {
if subject.value.Value() <= expectation {
subject.Fail(subject.DisplayString(), "is greater than", serial.IntLiteral(expectation))
}
}
func (subject *IntSubject) LessThan(expectation int) {
if subject.value.Value() >= expectation {
subject.Fail(subject.DisplayString(), "is less than", serial.IntLiteral(expectation))
}
}