1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-23 10:37:09 -05:00
v2fly/testing/assert/port.go

45 lines
928 B
Go
Raw Normal View History

2015-12-02 11:27:55 -05:00
package assert
import (
v2net "github.com/v2ray/v2ray-core/common/net"
)
2016-05-24 15:55:46 -04:00
func (this *Assert) Port(value v2net.Port) *PortSubject {
return &PortSubject{
Subject: Subject{
a: this,
disp: value.String(),
},
value: value,
}
}
type PortSubject struct {
2016-05-24 09:29:08 -04:00
Subject
value v2net.Port
}
func (subject *PortSubject) Equals(expectation v2net.Port) {
if subject.value.Value() != expectation.Value() {
2016-05-24 15:55:46 -04:00
subject.Fail("is equal to", expectation.String())
}
}
func (subject *PortSubject) GreaterThan(expectation v2net.Port) {
if subject.value.Value() <= expectation.Value() {
2016-05-24 15:55:46 -04:00
subject.Fail("is greater than", expectation.String())
}
}
func (subject *PortSubject) LessThan(expectation v2net.Port) {
if subject.value.Value() >= expectation.Value() {
2016-05-24 15:55:46 -04:00
subject.Fail("is less than", expectation.String())
}
}
2015-12-02 15:44:01 -05:00
func (subject *PortSubject) IsValid() {
2015-12-02 15:58:46 -05:00
if subject.value == 0 {
2016-05-24 15:55:46 -04:00
subject.Fail("is", "a valid port")
2015-12-02 15:58:46 -05:00
}
2015-12-02 15:44:01 -05:00
}