X-Git-Url: http://gitweb.michael.orlitzky.com/?p=hath.git;a=blobdiff_plain;f=src%2FMaskbits.hs;h=59efc2d2e6d61454d55abcf7d88f7c5a782f2542;hp=ed358b9dfa64e43ac5b125383679e0db2cd04dd8;hb=6257f1c59c5c9663f8d95996c1c35362417def71;hpb=a626afee0e8a4d5a8e1b9a22c150073be6a00cc3 diff --git a/src/Maskbits.hs b/src/Maskbits.hs index ed358b9..59efc2d 100644 --- a/src/Maskbits.hs +++ b/src/Maskbits.hs @@ -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.