prop_all_cidrs_contain_themselves,
prop_contains_proper_antisymmetric,
prop_normalize_idempotent,
- prop_normalize_preserves_equality ]
+ prop_normalize_preserves_equality,
+ prop_ord_instance_reflexive,
+ prop_ord_instance_transitive ]
-- HUnit Tests
-- Running "normalize" a second time shouldn't do anything.
prop_normalize_idempotent :: TestTree
prop_normalize_idempotent =
- testProperty "The CIDR \"normalize\" function is idempotent " prop
+ testProperty "The CIDR \"normalize\" function is idempotent" prop
where
prop :: Cidr -> Bool
prop cidr = (normalize cidr) == (normalize (normalize cidr))
-- Normalization should not affect equality of two CIDRs.
prop_normalize_preserves_equality :: TestTree
prop_normalize_preserves_equality =
- testProperty "The CIDR \"normalize\" function preserves equality " prop
+ testProperty "The CIDR \"normalize\" function preserves equality" prop
where
prop :: Cidr -> Cidr -> Bool
prop cidr1 cidr2 = (cidr1 == cidr2) == (normalize cidr1 == normalize cidr2)
+
+prop_ord_instance_reflexive :: TestTree
+prop_ord_instance_reflexive =
+ testProperty "The CIDR order is reflexive" prop
+ where
+ prop :: Cidr -> Bool
+ prop cidr = cidr <= cidr
+
+
+prop_ord_instance_transitive :: TestTree
+prop_ord_instance_transitive =
+ testProperty "The CIDR order is transitive" prop
+ where
+ prop :: Cidr -> Cidr -> Cidr -> Property
+ prop cidr1 cidr2 cidr3 =
+ (cidr1 <= cidr2 && cidr2 <= cidr3) ==> cidr1 <= cidr3