From: Michael Orlitzky Date: Sun, 9 May 2010 19:36:00 +0000 (-0400) Subject: Added HUnit tests for the Maskable instances. X-Git-Tag: 0.0.1~52 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=62733fdca35195dd5ad984bdd5c9d1247d2a9bc0;p=hath.git Added HUnit tests for the Maskable instances. --- diff --git a/src/Maskable.hs b/src/Maskable.hs index 051bb65..9300ee1 100644 --- a/src/Maskable.hs +++ b/src/Maskable.hs @@ -1,5 +1,7 @@ module Maskable where +import Test.HUnit + import qualified Bit as B import IPv4Address import Maskbits @@ -78,3 +80,24 @@ instance Maskable IPv4Address where oct2 = (octet2 addr) oct3 = (octet3 addr) oct4 = (octet4 addr) + + + +-- HUnit Tests + +test_octet_mask1 = + TestCase $ assertEqual "The network bits of 255/4 should equal 240" oct2 (apply_mask oct1 Four) + where + oct1 = octet_from_int 255 + oct2 = octet_from_int 240 + + +test_octet_mask2 = + TestCase $ assertEqual "The network bits of 255/1 should equal 128" oct2 (apply_mask oct1 One) + where + oct1 = octet_from_int 255 + oct2 = octet_from_int 128 + + +maskable_tests = [ test_octet_mask1, + test_octet_mask2 ]