X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FMaskable.hs;h=4f028a02ae519b731a5922479a7bd01a2370179d;hb=0be56eaa64ab03adf3aa1f3f3c14a191c09045c8;hp=051bb6534580629d7139e20aedd7ac5b7e9924e4;hpb=e7c180726c794ec12c43496cd7d60a8ea8d5a47f;p=hath.git diff --git a/src/Maskable.hs b/src/Maskable.hs index 051bb65..4f028a0 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,27 @@ instance Maskable IPv4Address where oct2 = (octet2 addr) oct3 = (octet3 addr) oct4 = (octet4 addr) + + + +-- HUnit Tests + +test_octet_mask1 :: Test +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 :: Test +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] +maskable_tests = [ test_octet_mask1, + test_octet_mask2 ]