X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FMaskbits.hs;h=59efc2d2e6d61454d55abcf7d88f7c5a782f2542;hb=f81e236ab90102d8afd6d6080131b77d59e38348;hp=ed358b9dfa64e43ac5b125383679e0db2cd04dd8;hpb=faf538fda9564ceb68774ac4bf5981fddb427b38;p=hath.git 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.