From c5ea6135a25e8c9e108c34ebb0d0cbb4b4af1e6d Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 20 May 2010 01:13:25 -0400 Subject: [PATCH] Added two tests for combine_all. --- src/Cidr.hs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Cidr.hs b/src/Cidr.hs index 427be15..98c42c7 100644 --- a/src/Cidr.hs +++ b/src/Cidr.hs @@ -281,6 +281,28 @@ test_combine_contained2 = cidr2 = cidr_from_string "192.168.1.0/24" +test_combine_all1 :: Test +test_combine_all1 = + TestCase $ assertEqual "10.0.0.0/24 is adjacent to 10.0.1.0/24 and 10.0.3.0/23 contains 10.0.2.0/24" expected_cidrs (combine_all test_cidrs) + where + cidr1 = cidr_from_string "10.0.0.0/24" + cidr2 = cidr_from_string "10.0.1.0/24" + cidr3 = cidr_from_string "10.0.2.0/24" + cidr4 = cidr_from_string "10.0.3.0/23" + cidr5 = cidr_from_string "10.0.0.0/23" + expected_cidrs = [cidr4, cidr5] + test_cidrs = [cidr1, cidr2, cidr3, cidr4] + + +test_combine_all2 :: Test +test_combine_all2 = + TestCase $ assertEqual "127.0.0.1/32 combines with itself recursively" expected_cidrs (combine_all test_cidrs) + where + cidr1 = cidr_from_string "127.0.0.1/32" + expected_cidrs = [cidr1] + test_cidrs = [cidr1, cidr1, cidr1, cidr1, cidr1] + + cidr_tests :: [Test] cidr_tests = [ test_equality1, test_contains1, @@ -292,7 +314,9 @@ cidr_tests = [ test_equality1, test_adjacent3, test_adjacent4, test_combine_contained1, - test_combine_contained2 + test_combine_contained2, + test_combine_all1, + test_combine_all2 ] -- 2.44.2