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/ip.go

34 lines
494 B

9 years ago
package assert
import (
"bytes"
"net"
)
9 years ago
func (this *Assert) IP(value net.IP) *IPSubject {
return &IPSubject{
Subject: Subject{
a: this,
disp: value.String(),
},
value: value,
}
9 years ago
}
type IPSubject struct {
Subject
9 years ago
value net.IP
}
func (subject *IPSubject) IsNil() {
if subject.value != nil {
9 years ago
subject.Fail("is", "nil")
9 years ago
}
}
func (subject *IPSubject) Equals(ip net.IP) {
if !bytes.Equal([]byte(subject.value), []byte(ip)) {
9 years ago
subject.Fail("equals to", ip.String())
9 years ago
}
}