From 090abce53a977c1bceb0d1ad4b0eed092bf3c005 Mon Sep 17 00:00:00 2001 From: Sam T Date: Sat, 4 May 2013 21:54:50 +0400 Subject: + Add some test cases for findMin & finMax. --- tests/Main.hs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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 @@ +{-# LANGUAGE OverloadedStrings #-} module Main (main) where import Data.Word @@ -30,6 +31,22 @@ prop_bitfieldMaxJust n = where s = fromIntegral n `mod` 1024 +prop_bitfieldMinCases :: Bool +prop_bitfieldMinCases = all mkTestCase + [ ("\x0\x3", Just 8) + , ("\x0\x127", Just 8) + ] + where + mkTestCase (bs, res) = findMin (MkBitfield bs) == res + +prop_bitfieldMaxCases :: Bool +prop_bitfieldMaxCases = all mkTestCase + [ ("\x0\x3", Just 9) + , ("\x0\x127", Just 13) + ] + where + mkTestCase (bs, res) = findMax (MkBitfield bs) == res + prop_bitfieldMinJust :: Word -> Bool prop_bitfieldMinJust n = let m = findMin (full (fromIntegral n `mod` 1024)) in @@ -77,10 +94,13 @@ main = defaultMain $ [ testProperty "bitfield `difference` empty bitfield" prop_bitfieldDiff0 , testProperty "empty bitfield `difference` bitfield" prop_bitfieldDiff1 + , testProperty "prop_bitfieldMinNothing" prop_bitfieldMinNothing , testProperty "prop_bitfieldMaxNothing" prop_bitfieldMaxNothing , testProperty "prop_bitfieldMaxJust" prop_bitfieldMaxJust , testProperty "prop_bitfieldMinJust" prop_bitfieldMinJust + , testProperty "prop_bitfieldMinCases" prop_bitfieldMinCases + , testProperty "prop_bitfieldMaxCases" prop_bitfieldMaxCases , testProperty "prop_bitfieldUnionIdentity" prop_bitfieldUnionIdentity , testProperty "prop_bitfieldUnionCommutative" prop_bitfieldUnionCommutative -- cgit v1.2.3