1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-23 02:26:49 -05:00
v2fly/testing/assert/ip.go

34 lines
494 B
Go
Raw Normal View History

2015-12-06 05:00:10 -05:00
package assert
import (
"bytes"
"net"
)
2016-05-24 15:55:46 -04:00
func (this *Assert) IP(value net.IP) *IPSubject {
return &IPSubject{
Subject: Subject{
a: this,
disp: value.String(),
},
value: value,
}
2015-12-06 05:00:10 -05:00
}
type IPSubject struct {
2016-05-24 09:29:08 -04:00
Subject
2015-12-06 05:00:10 -05:00
value net.IP
}
func (subject *IPSubject) IsNil() {
if subject.value != nil {
2016-05-24 15:55:46 -04:00
subject.Fail("is", "nil")
2015-12-06 05:00:10 -05:00
}
}
func (subject *IPSubject) Equals(ip net.IP) {
if !bytes.Equal([]byte(subject.value), []byte(ip)) {
2016-05-24 15:55:46 -04:00
subject.Fail("equals to", ip.String())
2015-12-06 05:00:10 -05:00
}
}