summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/Main.hs20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/Main.hs b/tests/Main.hs
index c887fd64..4045f793 100644
--- a/tests/Main.hs
+++ b/tests/Main.hs
@@ -1,3 +1,4 @@
1{-# LANGUAGE OverloadedStrings #-}
1module Main (main) where 2module Main (main) where
2 3
3import Data.Word 4import Data.Word
@@ -30,6 +31,22 @@ prop_bitfieldMaxJust n =
30 where 31 where
31 s = fromIntegral n `mod` 1024 32 s = fromIntegral n `mod` 1024
32 33
34prop_bitfieldMinCases :: Bool
35prop_bitfieldMinCases = all mkTestCase
36 [ ("\x0\x3", Just 8)
37 , ("\x0\x127", Just 8)
38 ]
39 where
40 mkTestCase (bs, res) = findMin (MkBitfield bs) == res
41
42prop_bitfieldMaxCases :: Bool
43prop_bitfieldMaxCases = all mkTestCase
44 [ ("\x0\x3", Just 9)
45 , ("\x0\x127", Just 13)
46 ]
47 where
48 mkTestCase (bs, res) = findMax (MkBitfield bs) == res
49
33prop_bitfieldMinJust :: Word -> Bool 50prop_bitfieldMinJust :: Word -> Bool
34prop_bitfieldMinJust n = 51prop_bitfieldMinJust n =
35 let m = findMin (full (fromIntegral n `mod` 1024)) in 52 let m = findMin (full (fromIntegral n `mod` 1024)) in
@@ -77,10 +94,13 @@ main = defaultMain $
77 [ 94 [
78 testProperty "bitfield `difference` empty bitfield" prop_bitfieldDiff0 95 testProperty "bitfield `difference` empty bitfield" prop_bitfieldDiff0
79 , testProperty "empty bitfield `difference` bitfield" prop_bitfieldDiff1 96 , testProperty "empty bitfield `difference` bitfield" prop_bitfieldDiff1
97
80 , testProperty "prop_bitfieldMinNothing" prop_bitfieldMinNothing 98 , testProperty "prop_bitfieldMinNothing" prop_bitfieldMinNothing
81 , testProperty "prop_bitfieldMaxNothing" prop_bitfieldMaxNothing 99 , testProperty "prop_bitfieldMaxNothing" prop_bitfieldMaxNothing
82 , testProperty "prop_bitfieldMaxJust" prop_bitfieldMaxJust 100 , testProperty "prop_bitfieldMaxJust" prop_bitfieldMaxJust
83 , testProperty "prop_bitfieldMinJust" prop_bitfieldMinJust 101 , testProperty "prop_bitfieldMinJust" prop_bitfieldMinJust
102 , testProperty "prop_bitfieldMinCases" prop_bitfieldMinCases
103 , testProperty "prop_bitfieldMaxCases" prop_bitfieldMaxCases
84 104
85 , testProperty "prop_bitfieldUnionIdentity" prop_bitfieldUnionIdentity 105 , testProperty "prop_bitfieldUnionIdentity" prop_bitfieldUnionIdentity
86 , testProperty "prop_bitfieldUnionCommutative" prop_bitfieldUnionCommutative 106 , testProperty "prop_bitfieldUnionCommutative" prop_bitfieldUnionCommutative