From 3da12c72198a99a7cd4b37ce54bdbdcf98bb5df9 Mon Sep 17 00:00:00 2001 From: Mingzhen Feng Date: Wed, 22 Apr 2015 10:04:03 +0800 Subject: [PATCH] Add TestSandboxInfoEqual in sandbox_test.go Signed-off-by: Mingzhen Feng --- libnetwork/sandbox/sandbox_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libnetwork/sandbox/sandbox_test.go b/libnetwork/sandbox/sandbox_test.go index 2678466d58..460ac30181 100644 --- a/libnetwork/sandbox/sandbox_test.go +++ b/libnetwork/sandbox/sandbox_test.go @@ -39,6 +39,23 @@ func TestInterfaceEqual(t *testing.T) { } } +func TestSandboxInfoEqual(t *testing.T) { + si1 := &Info{Interfaces: getInterfaceList(), Gateway: net.ParseIP("192.168.1.254"), GatewayIPv6: net.ParseIP("2001:2345::abcd:8889")} + si2 := &Info{Interfaces: getInterfaceList(), Gateway: net.ParseIP("172.18.255.254"), GatewayIPv6: net.ParseIP("2001:2345::abcd:8888")} + + if !si1.Equal(si1) { + t.Fatalf("Info.Equal() returned false negative") + } + + if si1.Equal(si2) { + t.Fatalf("Info.Equal() returned false positive") + } + + if si1.Equal(si2) != si2.Equal(si1) { + t.Fatalf("Info.Equal() failed commutative check") + } +} + func TestInterfaceCopy(t *testing.T) { for _, iface := range getInterfaceList() { cp := iface.GetCopy()