1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -05:00
v2fly/testing/assert/destination.go
Darien Raymond 73c4696e00
mux io
2017-04-02 09:48:30 +02:00

65 lines
1.3 KiB
Go

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) Equals(another net.Destination) {
if v.value != another {
v.Fail("not equals to", another.String())
}
}
func (v *DestinationSubject) HasAddress() *AddressSubject {
return v.a.Address(v.value.Address)
}
func (v *DestinationSubject) HasPort() *PortSubject {
return v.a.Port(v.value.Port)
}