1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-03 15:55:20 -05:00

test cases for Equals()

This commit is contained in:
Darien Raymond
2016-01-21 12:05:28 +00:00
parent d75eeed25d
commit 7f4ff04483
3 changed files with 94 additions and 2 deletions

View File

@@ -26,3 +26,35 @@ func TestUDPDestination(t *testing.T) {
v2netassert.Destination(dest).IsUDP()
assert.String(dest).Equals("udp:[2001:4860:4860::8888]:53")
}
func TestTCPDestinationEquals(t *testing.T) {
v2testing.Current(t)
dest := v2net.TCPDestination(v2net.IPAddress([]byte{1, 2, 3, 4}), 80)
assert.Bool(dest.Equals(nil)).IsFalse()
dest2 := v2net.TCPDestination(v2net.IPAddress([]byte{1, 2, 3, 4}), 80)
assert.Bool(dest.Equals(dest2)).IsTrue()
dest3 := v2net.UDPDestination(v2net.IPAddress([]byte{1, 2, 3, 4}), 80)
assert.Bool(dest.Equals(dest3)).IsFalse()
dest4 := v2net.TCPDestination(v2net.DomainAddress("v2ray.com"), 80)
assert.Bool(dest.Equals(dest4)).IsFalse()
}
func TestUDPDestinationEquals(t *testing.T) {
v2testing.Current(t)
dest := v2net.UDPDestination(v2net.IPAddress([]byte{1, 2, 3, 4}), 80)
assert.Bool(dest.Equals(nil)).IsFalse()
dest2 := v2net.UDPDestination(v2net.IPAddress([]byte{1, 2, 3, 4}), 80)
assert.Bool(dest.Equals(dest2)).IsTrue()
dest3 := v2net.TCPDestination(v2net.IPAddress([]byte{1, 2, 3, 4}), 80)
assert.Bool(dest.Equals(dest3)).IsFalse()
dest4 := v2net.UDPDestination(v2net.DomainAddress("v2ray.com"), 80)
assert.Bool(dest.Equals(dest4)).IsFalse()
}