mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-12-28 21:15:46 -05:00
dns cache
This commit is contained in:
39
common/net/testing/assert/ip.go
Normal file
39
common/net/testing/assert/ip.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package assert
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net"
|
||||
|
||||
"github.com/v2ray/v2ray-core/common/serial"
|
||||
"github.com/v2ray/v2ray-core/testing/assert"
|
||||
)
|
||||
|
||||
func IP(value net.IP) *IPSubject {
|
||||
return &IPSubject{value: value}
|
||||
}
|
||||
|
||||
type IPSubject struct {
|
||||
assert.Subject
|
||||
value net.IP
|
||||
}
|
||||
|
||||
func (subject *IPSubject) Named(name string) *IPSubject {
|
||||
subject.Subject.Named(name)
|
||||
return subject
|
||||
}
|
||||
|
||||
func (subject *IPSubject) DisplayString() string {
|
||||
return subject.Subject.DisplayString(subject.value.String())
|
||||
}
|
||||
|
||||
func (subject *IPSubject) IsNil() {
|
||||
if subject.value != nil {
|
||||
subject.Fail(subject.DisplayString(), "is", serial.StringLiteral("nil"))
|
||||
}
|
||||
}
|
||||
|
||||
func (subject *IPSubject) Equals(ip net.IP) {
|
||||
if !bytes.Equal([]byte(subject.value), []byte(ip)) {
|
||||
subject.Fail(subject.DisplayString(), "equals to", ip)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user