From 05dace618d454b236d9e8a30a4be5541b7e7c2d0 Mon Sep 17 00:00:00 2001 From: vishalnayak Date: Wed, 28 Sep 2016 14:04:02 -0400 Subject: [PATCH] Added a few checks to the CIDR Subset checking util --- helper/cidrutil/cidr_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/helper/cidrutil/cidr_test.go b/helper/cidrutil/cidr_test.go index 74bbc7c8f0..1e29273faf 100644 --- a/helper/cidrutil/cidr_test.go +++ b/helper/cidrutil/cidr_test.go @@ -175,6 +175,23 @@ func TestCIDRUtil_Subset(t *testing.T) { if subset { t.Fatalf("expected CIDR %q to not be a subset of CIDR %q", cidr2, cidr1) } + + cidr1 = "192.168.0.128/25" + cidr2 = "192.168.0.0/24" + subset, err = Subset(cidr1, cidr2) + if err != nil { + t.Fatal(err) + } + if subset { + t.Fatalf("expected CIDR %q to not be a subset of CIDR %q", cidr2, cidr1) + } + subset, err = Subset(cidr2, cidr1) + if err != nil { + t.Fatal(err) + } + if !subset { + t.Fatal("expected CIDR %q to be a subset of CIDR %q", cidr1, cidr2) + } } func TestCIDRUtil_SubsetBlocks(t *testing.T) {