@@ -7,33 +7,72 @@ import Data.Binary.Put ( runPut )
77import Bits
88
99import Data.Bits
10+import Data.Monoid
1011import Data.Word
1112import Foreign.Storable
1213import System.Random
14+import System
1315
1416import BitsGet
1517import BitsPut
1618
19+import Test.Framework.Options ( TestOptions'(..) )
20+import Test.Framework.Providers.QuickCheck2 ( testProperty )
21+import Test.Framework.Runners.Console ( defaultMainWithOpts )
22+import Test.Framework.Runners.Options ( RunnerOptions'(..) )
23+import Test.Framework ( Test, testGroup )
1724import Test.QuickCheck
1825
1926main = do
20− quickCheck prop_bitreq
21− quickCheck prop_composite_case
22−
23− quickCheck (prop_putget_with_bitreq :: Word8 -> Property)
24− quickCheck (prop_putget_with_bitreq :: Word16 -> Property)
25−
26− quickCheck (prop_putget_list_simple :: [Bool] -> Property)
27− quickCheck (prop_putget_list_simple :: [Word8] -> Property)
28− quickCheck (prop_putget_list_simple :: [Word16] -> Property)
29−
30− quickCheck (prop_putget_list_with_bitreq :: [Word8] -> Property)
31− quickCheck (prop_putget_list_with_bitreq :: [Word16] -> Property)
27+ args <- getArgs
28+ defaultMainWithOpts tests (setMaxTestCases (if null args then 1024 else read (head args)))
29+ where
30+ -- increase the number of test cases
31+ setMaxTestCases n =
32+ mempty
33+ { ropt_test_options = Just $
34+ mempty
35+ { topt_maximum_generated_tests = Just n
36+ }
37+ }
38+
39+tests :: [Test]
40+tests =
41+ [ testGroup "Internal test functions"
42+ [ testProperty "prop_bitreq" prop_bitreq ]
43+
44+ , testGroup "Custom test cases"
45+ [ testProperty "prop_composite_case" prop_composite_case ]
46+
47+ , testGroup "prop_put_with_bitreq"
48+ [ testProperty "Word8" (prop_putget_with_bitreq :: Word8 -> Property)
49+ , testProperty "Word16" (prop_putget_with_bitreq :: Word16 -> Property)
50+ , testProperty "Word32" (prop_putget_with_bitreq :: Word32 -> Property)
51+ -- , testProperty "Word64" (prop_putget_with_bitreq :: Word64 -> Property)
52+ ]
53+
54+ , testGroup "prop_putget_list_simple"
55+ [ testProperty "Bool" (prop_putget_list_simple :: [Bool] -> Property)
56+ , testProperty "Word8" (prop_putget_list_simple :: [Word8] -> Property)
57+ , testProperty "Word16" (prop_putget_list_simple :: [Word16] -> Property)
58+ , testProperty "Word32" (prop_putget_list_simple :: [Word32] -> Property)
59+ -- , testProperty "Word64" (prop_putget_list_simple :: [Word64] -> Property)
60+ ]
61+
62+ , testGroup "prop_putget_list_with_bitreq"
63+ [ testProperty "Word8" (prop_putget_list_with_bitreq :: [Word8] -> Property)
64+ , testProperty "Word16" (prop_putget_list_with_bitreq :: [Word16] -> Property)
65+ , testProperty "Word32" (prop_putget_list_with_bitreq :: [Word32] -> Property)
66+ -- , testProperty "Word64" (prop_putget_list_with_bitreq :: [Word64] -> Property)
67+ ]
68+ ]
3269
70+{-
3371 -- these tests use the R structure
3472 --
3573 -- quickCheck prop_Word32_from_2_Word16
3674 -- quickCheck prop_Word32_from_Word8_and_Word16
75+-}
3776
3877prop_putget_with_bitreq :: (BinaryBit a, Num a, Bits a, Ord a) => a -> Property
3978prop_putget_with_bitreq w = property $