From: Michael Orlitzky Date: Sun, 9 May 2010 19:23:16 +0000 (-0400) Subject: Add an HUnit test for Cidr. X-Git-Tag: 0.0.1~55 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=266b4e80cdde311563da66fa14f7abe6ffa7e859;p=hath.git Add an HUnit test for Cidr. --- 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 ]