From 266b4e80cdde311563da66fa14f7abe6ffa7e859 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 9 May 2010 15:23:16 -0400 Subject: [PATCH] Add an HUnit test for Cidr. --- src/Cidr.hs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Cidr.hs b/src/Cidr.hs index 08eebcb..d772d5b 100644 --- a/src/Cidr.hs +++ b/src/Cidr.hs @@ -1,10 +1,12 @@ module Cidr ( Cidr(..), cidr_from_string, + cidr_tests, combine_all ) where import Data.List (nubBy) +import Test.HUnit import IPv4Address import ListUtils @@ -170,3 +172,18 @@ adjacent cidr1 cidr2 addr2 = ipv4address cidr2 mbits1 = maskbits cidr1 mbits2 = maskbits cidr2 + + + + + +-- HUnit Tests + +test_contains = + TestCase $ assertEqual "10.1.1.0/23 contains 10.1.1.0/24" (cidr1 `contains` cidr2) True + where + cidr1 = cidr_from_string "10.1.1.0/23" + cidr2 = cidr_from_string "10.1.1.0/24" + + +cidr_tests = [ test_contains ] -- 2.44.2