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/common/net/testing/assert.go

49 lines
1.1 KiB

7 years ago
package testing
import (
"v2ray.com/core/common/net"
"v2ray.com/ext/assert"
)
var IsIPv4 = assert.CreateMatcher(func(a net.Address) bool {
7 years ago
return a.Family().IsIPv4()
}, "is IPv4")
7 years ago
var IsIPv6 = assert.CreateMatcher(func(a net.Address) bool {
7 years ago
return a.Family().IsIPv6()
}, "is IPv6")
7 years ago
var IsIP = assert.CreateMatcher(func(a net.Address) bool {
7 years ago
return a.Family().IsIPv4() || a.Family().IsIPv6()
}, "is IP")
7 years ago
var IsTCP = assert.CreateMatcher(func(a net.Destination) bool {
7 years ago
return a.Network == net.Network_TCP
}, "is TCP")
7 years ago
var IsUDP = assert.CreateMatcher(func(a net.Destination) bool {
7 years ago
return a.Network == net.Network_UDP
}, "is UDP")
7 years ago
var IsDomain = assert.CreateMatcher(func(a net.Address) bool {
7 years ago
return a.Family().IsDomain()
}, "is Domain")
7 years ago
func init() {
assert.RegisterEqualsMatcher(func(a, b net.Address) bool {
7 years ago
return a == b
})
7 years ago
assert.RegisterEqualsMatcher(func(a, b net.Destination) bool {
7 years ago
return a == b
})
7 years ago
assert.RegisterEqualsMatcher(func(a, b net.Port) bool {
7 years ago
return a == b
})
assert.RegisterEqualsMatcher(func(a, b net.IP) bool {
return a.Equal(b)
})
7 years ago
}