From a767881c16a119a90ff80d9c14106348d8bc310d Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 9 May 2010 20:48:13 -0400 Subject: [PATCH] Added type signatures for all of the tests. --- src/Cidr.hs | 2 ++ src/IPv4Address.hs | 4 +++- src/Maskable.hs | 3 +++ src/Octet.hs | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Cidr.hs b/src/Cidr.hs index d772d5b..77f1ae4 100644 --- a/src/Cidr.hs +++ b/src/Cidr.hs @@ -179,6 +179,7 @@ adjacent cidr1 cidr2 -- 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 @@ -186,4 +187,5 @@ test_contains = cidr2 = cidr_from_string "10.1.1.0/24" +cidr_tests :: [Test] cidr_tests = [ test_contains ] diff --git a/src/IPv4Address.hs b/src/IPv4Address.hs index 29afa5f..e91e673 100644 --- a/src/IPv4Address.hs +++ b/src/IPv4Address.hs @@ -355,14 +355,16 @@ mk_testaddr a b c d = 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 ] diff --git a/src/Maskable.hs b/src/Maskable.hs index 9300ee1..4f028a0 100644 --- a/src/Maskable.hs +++ b/src/Maskable.hs @@ -85,6 +85,7 @@ instance Maskable IPv4Address where -- 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 @@ -92,6 +93,7 @@ test_octet_mask1 = 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 @@ -99,5 +101,6 @@ test_octet_mask2 = oct2 = octet_from_int 128 +maskable_tests :: [Test] maskable_tests = [ test_octet_mask1, test_octet_mask2 ] diff --git a/src/Octet.hs b/src/Octet.hs index efc19d5..04caae5 100644 --- a/src/Octet.hs +++ b/src/Octet.hs @@ -73,10 +73,12 @@ max_octet = Octet One One One One One One One One -- 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 ] -- 2.44.2