]> code.delx.au - offlineimap/blobdiff - testsrc/TestInfrastructure.hs
Improved random Char generation
[offlineimap] / testsrc / TestInfrastructure.hs
index feb058e186473f2cf4fb34d7a594f48994b9abe6..ec22ba7e963bafa50552d59e489284c977992585 100644 (file)
@@ -60,8 +60,8 @@ instance Random Word8 where
     random g = randomR (minBound, maxBound) g
 
 instance Arbitrary Char where
-    arbitrary = sized $ \n -> choose (toEnum 0, min (toEnum n) maxBound)
-    coarbitrary n = variant (if (fromEnum n) >= 0 then toEnum (2 * x) else toEnum (2 * x + 1))
+    arbitrary = sized $ \n -> choose (toEnum 0, min (toEnum (n * 0x50)) maxBound)
+    coarbitrary n = variant (toEnum (2 * x + 1))
                 where x = (abs . fromEnum $ n)::Int
 
 -- Modified from HUnit