+ prop :: Int -> Property
+ prop x = (0 <= x) && (x <= 255) ==> x' == x
+ where
+ oct :: Octet
+ oct = read $ show x
+
+ x' :: Int
+ x' = read $ show oct
+
+-- | Ensure that the Ord instance for Octets agrees with the Ord
+-- instance for Int (i.e. that numerical comparisons work).
+prop_ord_instances_agree :: TestTree
+prop_ord_instances_agree =
+ testProperty "the Octet and Int Ord instances agree" prop
+ where
+ prop :: Int -> Int -> Property
+ prop x y = (0 <= x) && (x <= 255) && (0 <= y) && (y <= 255) ==> ord == ord'
+ where
+ ord = (x <= y)