From e76000bc1846d6a989bfab9e4db5319304562df2 Mon Sep 17 00:00:00 2001 From: John Goerzen Date: Tue, 12 Aug 2008 02:51:08 -0500 Subject: [PATCH] Improved random Char generation --- testsrc/TestInfrastructure.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testsrc/TestInfrastructure.hs b/testsrc/TestInfrastructure.hs index feb058e..ec22ba7 100644 --- a/testsrc/TestInfrastructure.hs +++ b/testsrc/TestInfrastructure.hs @@ -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 -- 2.39.2