+octet_properties :: Test
+octet_properties =
+ testGroup
+ "Octet Properties "
+ [ testProperty
+ "fromEnum/toEnum are inverses"
+ prop_from_enum_to_enum_inverses,
+ testProperty
+ "read/show are inverses"
+ prop_read_show_inverses ]
+
+-- QuickCheck properties
+prop_from_enum_to_enum_inverses :: Int -> Property
+prop_from_enum_to_enum_inverses x =
+ (0 <= x) && (x <= 255) ==>
+ fromEnum (toEnum x :: Octet) == x
+
+prop_read_show_inverses :: Int -> Property
+prop_read_show_inverses x =
+ (0 <= x) && (x <= 255) ==> x' == x
+ where
+ oct :: Octet
+ oct = read $ show x
+
+ x' :: Int
+ x' = read $ show oct