@@ -17,8 +17,8 @@ import BitsPut
1717import Test.QuickCheck
1818
1919main = do
20− quickCheck prop_Bools
21− quickCheck prop_SimpleCase
20+ quickCheck prop_bitreq
21+ quickCheck prop_composite_case
2222
2323 quickCheck (prop_putget_with_bitreq :: Word8 -> Property)
2424 quickCheck (prop_putget_with_bitreq :: Word16 -> Property)
@@ -71,15 +71,13 @@ bitreq v = fromIntegral . head $ [ req | (req, top) <- bittable, v <= top ]
7171bittable :: Bits a => [(Integer, a)]
7272bittable = [ (fromIntegral x, (1 `shiftL` x) - 1) | x <- [1..64] ]
7373
74−prop_Bools :: [Bool] -> Property
75−prop_Bools bs = property $
76− let p = sequence . replicate (length bs) $ getBool
77− Right bs' = runGet (runBitGet p) lbs
78− in bs == bs'
79− where lbs = runPut $ runBitPut (mapM_ putBool bs)
74+prop_bitreq :: Word64 -> Property
75+prop_bitreq w = property $
76+ ( w == 0 && bitreq w == 1 )
77+ || bitreq w == (bitreq (w `shiftR` 1)) + 1
8078
81−prop_SimpleCase :: Bool -> Word16 -> Property
82−prop_SimpleCase b w = w < 0x8000 ==>
79+prop_composite_case :: Bool -> Word16 -> Property
80+prop_composite_case b w = w < 0x8000 ==>
8381 let p = do putBool b
8482 putWord16be 15 w
8583 g = do v <- getBool
@@ -92,8 +90,6 @@ prop_SimpleCase b w = w < 0x8000 ==>
9290 lbs = runPut (runBitPut p)
9391 w' = runGet (runBitGetSimple g) lbs
9492 in w == w'
95− where
96−
9793
9894{-
9995prop_Word32_from_Word8_and_Word16 :: Word8 -> Word16 -> Property