]> gitweb.michael.orlitzky.com - hath.git/blobdiff - src/Maskbits.hs
Added Arbitrary instance definitions for the main data types.
[hath.git] / src / Maskbits.hs
index ed358b9dfa64e43ac5b125383679e0db2cd04dd8..59efc2d2e6d61454d55abcf7d88f7c5a782f2542 100644 (file)
@@ -4,6 +4,8 @@ module Maskbits
   maskbits_from_string
 ) where
 
+import Test.QuickCheck
+
 -- A type representing the number of bits in a CIDR netmask.
 data Maskbits = None
               | Zero
@@ -79,6 +81,44 @@ instance Show Maskbits where
     show ThirtyTwo   = "32"
 
 
+instance Arbitrary Maskbits where
+    arbitrary = elements [ Zero,
+                           One,
+                           Two,
+                           Three,
+                           Four,
+                           Five,
+                           Six,
+                           Seven,
+                           Eight,
+                           Nine,
+                           Ten,
+                           Eleven,
+                           Twelve,
+                           Thirteen,
+                           Fourteen,
+                           Fifteen,
+                           Sixteen,
+                           Seventeen,
+                           Eighteen,
+                           Nineteen,
+                           Twenty,
+                           TwentyOne,
+                           TwentyTwo,
+                           TwentyThree,
+                           TwentyFour,
+                           TwentyFive,
+                           TwentySix,
+                           TwentySeven,
+                           TwentyEight,
+                           TwentyNine,
+                           Thirty,
+                           ThirtyOne,
+                           ThirtyTwo ]
+
+    coarbitrary _ = variant 0
+
+
 
 -- There are only 32 bits in an IPv4 address, so there
 -- can't be more bits than that in the mask.