1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-15 16:38:16 -04:00
v2fly/testing/assert/destination.go

49 lines
1.1 KiB
Go
Raw Normal View History

2015-12-02 11:27:55 -05:00
package assert
import (
v2net "github.com/v2ray/v2ray-core/common/net"
"github.com/v2ray/v2ray-core/common/serial"
)
func Destination(value v2net.Destination) *DestinationSubject {
return &DestinationSubject{value: value}
}
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) Named(name string) *DestinationSubject {
this.Subject.Named(name)
return this
}
func (this *DestinationSubject) DisplayString() string {
return this.Subject.DisplayString(this.value.String())
}
func (this *DestinationSubject) IsTCP() {
if !this.value.IsTCP() {
2016-05-23 14:23:40 -04:00
this.Fail(this.DisplayString(), "is", serial.StringT("a TCP destination"))
2015-12-02 11:27:55 -05:00
}
}
func (this *DestinationSubject) IsNotTCP() {
if this.value.IsTCP() {
2016-05-23 14:23:40 -04:00
this.Fail(this.DisplayString(), "is not", serial.StringT("a TCP destination"))
2015-12-02 11:27:55 -05:00
}
}
func (this *DestinationSubject) IsUDP() {
if !this.value.IsUDP() {
2016-05-23 14:23:40 -04:00
this.Fail(this.DisplayString(), "is", serial.StringT("a UDP destination"))
2015-12-02 11:27:55 -05:00
}
}
func (this *DestinationSubject) IsNotUDP() {
if this.value.IsUDP() {
2016-05-23 14:23:40 -04:00
this.Fail(this.DisplayString(), "is not", serial.StringT("a UDP destination"))
2015-12-02 11:27:55 -05:00
}
}