mirror of https://github.com/v2ray/v2ray-core
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.
34 lines
494 B
34 lines
494 B
package assert
|
|
|
|
import (
|
|
"bytes"
|
|
"net"
|
|
)
|
|
|
|
func (this *Assert) IP(value net.IP) *IPSubject {
|
|
return &IPSubject{
|
|
Subject: Subject{
|
|
a: this,
|
|
disp: value.String(),
|
|
},
|
|
value: value,
|
|
}
|
|
}
|
|
|
|
type IPSubject struct {
|
|
Subject
|
|
value net.IP
|
|
}
|
|
|
|
func (subject *IPSubject) IsNil() {
|
|
if subject.value != nil {
|
|
subject.Fail("is", "nil")
|
|
}
|
|
}
|
|
|
|
func (subject *IPSubject) Equals(ip net.IP) {
|
|
if !bytes.Equal([]byte(subject.value), []byte(ip)) {
|
|
subject.Fail("equals to", ip.String())
|
|
}
|
|
}
|