1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-10-30 15:57:35 -04:00
v2fly/testing/assert/destination.go

59 lines
1.1 KiB
Go
Raw Normal View History

2015-12-02 11:27:55 -05:00
package assert
import (
2016-08-20 14:55:45 -04:00
v2net "v2ray.com/core/common/net"
2015-12-02 11:27:55 -05:00
)
2016-11-27 15:39:09 -05:00
func (v *Assert) Destination(value v2net.Destination) *DestinationSubject {
2016-05-24 15:55:46 -04:00
return &DestinationSubject{
Subject: Subject{
disp: value.String(),
2016-11-27 15:39:09 -05:00
a: v,
2016-05-24 15:55:46 -04:00
},
value: value,
}
2015-12-02 11:27:55 -05:00
}
type DestinationSubject struct {
2016-05-24 09:29:08 -04:00
Subject
2015-12-02 11:27:55 -05:00
value v2net.Destination
}
2016-11-27 15:39:09 -05:00
func (v *DestinationSubject) IsTCP() {
if v.value.Network != v2net.Network_TCP {
v.Fail("is", "a TCP destination")
2015-12-02 11:27:55 -05:00
}
}
2016-11-27 15:39:09 -05:00
func (v *DestinationSubject) IsNotTCP() {
if v.value.Network == v2net.Network_TCP {
v.Fail("is not", "a TCP destination")
2015-12-02 11:27:55 -05:00
}
}
2016-11-27 15:39:09 -05:00
func (v *DestinationSubject) IsUDP() {
if v.value.Network != v2net.Network_UDP {
v.Fail("is", "a UDP destination")
2015-12-02 11:27:55 -05:00
}
}
2016-11-27 15:39:09 -05:00
func (v *DestinationSubject) IsNotUDP() {
if v.value.Network == v2net.Network_UDP {
v.Fail("is not", "a UDP destination")
2016-05-24 15:55:46 -04:00
}
}
2016-11-27 15:39:09 -05:00
func (v *DestinationSubject) EqualsString(another string) {
if v.value.String() != another {
v.Fail("not equals to string", another)
2015-12-02 11:27:55 -05:00
}
}
2016-05-24 15:55:46 -04:00
2016-11-27 15:39:09 -05:00
func (v *DestinationSubject) HasAddress() *AddressSubject {
return v.a.Address(v.value.Address)
2016-05-24 15:55:46 -04:00
}
2016-11-27 15:39:09 -05:00
func (v *DestinationSubject) HasPort() *PortSubject {
return v.a.Port(v.value.Port)
2016-05-24 15:55:46 -04:00
}