-
Notifications
You must be signed in to change notification settings - Fork 0
/
port.go
44 lines (37 loc) · 893 Bytes
/
port.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
package assert
import (
"v2ray.com/core/common/net"
)
func (v *Assert) Port(value net.Port) *PortSubject {
return &PortSubject{
Subject: Subject{
a: v,
disp: value.String(),
},
value: value,
}
}
type PortSubject struct {
Subject
value net.Port
}
func (subject *PortSubject) Equals(expectation net.Port) {
if subject.value.Value() != expectation.Value() {
subject.Fail("is equal to", expectation.String())
}
}
func (subject *PortSubject) GreaterThan(expectation net.Port) {
if subject.value.Value() <= expectation.Value() {
subject.Fail("is greater than", expectation.String())
}
}
func (subject *PortSubject) LessThan(expectation net.Port) {
if subject.value.Value() >= expectation.Value() {
subject.Fail("is less than", expectation.String())
}
}
func (subject *PortSubject) IsValid() {
if subject.value == 0 {
subject.Fail("is", "a valid port")
}
}