-
Notifications
You must be signed in to change notification settings - Fork 0
/
destination.go
58 lines (48 loc) · 1.12 KB
/
destination.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
55
56
57
58
package assert
import (
"v2ray.com/core/common/net"
)
func (v *Assert) Destination(value net.Destination) *DestinationSubject {
return &DestinationSubject{
Subject: Subject{
disp: value.String(),
a: v,
},
value: value,
}
}
type DestinationSubject struct {
Subject
value net.Destination
}
func (v *DestinationSubject) IsTCP() {
if v.value.Network != net.Network_TCP {
v.Fail("is", "a TCP destination")
}
}
func (v *DestinationSubject) IsNotTCP() {
if v.value.Network == net.Network_TCP {
v.Fail("is not", "a TCP destination")
}
}
func (v *DestinationSubject) IsUDP() {
if v.value.Network != net.Network_UDP {
v.Fail("is", "a UDP destination")
}
}
func (v *DestinationSubject) IsNotUDP() {
if v.value.Network == net.Network_UDP {
v.Fail("is not", "a UDP destination")
}
}
func (v *DestinationSubject) EqualsString(another string) {
if v.value.String() != another {
v.Fail("not equals to string", another)
}
}
func (v *DestinationSubject) HasAddress() *AddressSubject {
return v.a.Address(v.value.Address)
}
func (v *DestinationSubject) HasPort() *PortSubject {
return v.a.Port(v.value.Port)
}