You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray-core/testing/assert/port.go

45 lines
928 B

9 years ago
package assert
import (
v2net "github.com/v2ray/v2ray-core/common/net"
)
9 years ago
func (this *Assert) Port(value v2net.Port) *PortSubject {
return &PortSubject{
Subject: Subject{
a: this,
disp: value.String(),
},
value: value,
}
}
type PortSubject struct {
Subject
value v2net.Port
}
func (subject *PortSubject) Equals(expectation v2net.Port) {
if subject.value.Value() != expectation.Value() {
9 years ago
subject.Fail("is equal to", expectation.String())
}
}
func (subject *PortSubject) GreaterThan(expectation v2net.Port) {
if subject.value.Value() <= expectation.Value() {
9 years ago
subject.Fail("is greater than", expectation.String())
}
}
func (subject *PortSubject) LessThan(expectation v2net.Port) {
if subject.value.Value() >= expectation.Value() {
9 years ago
subject.Fail("is less than", expectation.String())
}
}
func (subject *PortSubject) IsValid() {
9 years ago
if subject.value == 0 {
9 years ago
subject.Fail("is", "a valid port")
9 years ago
}
}