v2ray-core/testing/assert/destination.go

59 lines
1.1 KiB
Go
Raw Normal View History

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