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
893 B

9 years ago
package assert
import (
8 years ago
"v2ray.com/core/common/net"
)
8 years ago
func (v *Assert) Port(value net.Port) *PortSubject {
9 years ago
return &PortSubject{
Subject: Subject{
8 years ago
a: v,
9 years ago
disp: value.String(),
},
value: value,
}
}
type PortSubject struct {
Subject
8 years ago
value net.Port
}
8 years ago
func (subject *PortSubject) Equals(expectation net.Port) {
if subject.value.Value() != expectation.Value() {
9 years ago
subject.Fail("is equal to", expectation.String())
}
}
8 years ago
func (subject *PortSubject) GreaterThan(expectation net.Port) {
if subject.value.Value() <= expectation.Value() {
9 years ago
subject.Fail("is greater than", expectation.String())
}
}
8 years ago
func (subject *PortSubject) LessThan(expectation net.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
}
}