) where
import Test.HUnit
+import Test.QuickCheck
import qualified Bit as B
import Maskbits
oct4 = (octet4 addr)
+instance Arbitrary IPv4Address where
+ arbitrary = do
+ oct1 <- arbitrary :: Gen Octet
+ oct2 <- arbitrary :: Gen Octet
+ oct3 <- arbitrary :: Gen Octet
+ oct4 <- arbitrary :: Gen Octet
+ return (IPv4Address oct1 oct2 oct3 oct4)
+
+ coarbitrary _ = variant 0
+
+
+
-- We don't export our constructor so this function is the only
-- way to construct an address from octets. As a result, we can
-- return IPv4Address.None in response to being passed one of more
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 ]