-- HUnit Tests
+test_contains :: Test
test_contains =
TestCase $ assertEqual "10.1.1.0/23 contains 10.1.1.0/24" (cidr1 `contains` cidr2) True
where
cidr2 = cidr_from_string "10.1.1.0/24"
+cidr_tests :: [Test]
cidr_tests = [ test_contains ]
oct4 = octet_from_int d
+test_most_sig_bit_different1 :: Test
test_most_sig_bit_different1 =
TestCase $ assertEqual "10.1.1.0 and 10.1.0.0 differ in bit 24" TwentyFour (most_sig_bit_different (mk_testaddr 10 1 1 0) (mk_testaddr 10 1 0 0))
+test_most_sig_bit_different2 :: Test
test_most_sig_bit_different2 =
TestCase $ assertEqual "10.1.2.0 and 10.1.1.0 differ in bit 23" TwentyThree (most_sig_bit_different (mk_testaddr 10 1 2 0) (mk_testaddr 10 1 1 0))
-
+ipv4address_tests :: [Test]
ipv4address_tests = [ test_most_sig_bit_different1,
test_most_sig_bit_different2 ]
-- 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
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
oct2 = octet_from_int 128
+maskable_tests :: [Test]
maskable_tests = [ test_octet_mask1,
test_octet_mask2 ]
-- HUnit Tests
+test_octet_from_int1 :: Test
test_octet_from_int1 =
TestCase $ assertEqual "octet_from_int 128 should parse as 10000000" oct1 (octet_from_int 128)
where
oct1 = Octet One Zero Zero Zero Zero Zero Zero Zero
+octet_tests :: [Test]
octet_tests = [ test_octet_from_int1 ]