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

59 lines
1.2 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-05-24 15:55:46 -04:00
func (this *Assert) Destination(value v2net.Destination) *DestinationSubject {
return &DestinationSubject{
Subject: Subject{
disp: value.String(),
a: this,
},
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
}
func (this *DestinationSubject) IsTCP() {
2016-09-20 05:53:05 -04:00
if this.value.Network != v2net.Network_TCP {
2016-05-24 15:55:46 -04:00
this.Fail("is", "a TCP destination")
2015-12-02 11:27:55 -05:00
}
}
func (this *DestinationSubject) IsNotTCP() {
2016-09-20 05:53:05 -04:00
if this.value.Network == v2net.Network_TCP {
2016-05-24 15:55:46 -04:00
this.Fail("is not", "a TCP destination")
2015-12-02 11:27:55 -05:00
}
}
func (this *DestinationSubject) IsUDP() {
2016-09-20 05:53:05 -04:00
if this.value.Network != v2net.Network_UDP {
2016-05-24 15:55:46 -04:00
this.Fail("is", "a UDP destination")
2015-12-02 11:27:55 -05:00
}
}
func (this *DestinationSubject) IsNotUDP() {
2016-09-20 05:53:05 -04:00
if this.value.Network == v2net.Network_UDP {
2016-05-24 15:55:46 -04:00
this.Fail("is not", "a UDP destination")
}
}
func (this *DestinationSubject) EqualsString(another string) {
if this.value.String() != another {
this.Fail("not equals to string", another)
2015-12-02 11:27:55 -05:00
}
}
2016-05-24 15:55:46 -04:00
func (this *DestinationSubject) HasAddress() *AddressSubject {
2016-09-20 05:53:05 -04:00
return this.a.Address(this.value.Address)
2016-05-24 15:55:46 -04:00
}
func (this *DestinationSubject) HasPort() *PortSubject {
2016-09-20 05:53:05 -04:00
return this.a.Port(this.value.Port)
2016-05-24 15:55:46 -04:00
}