From 9a0159cc0ff165f33527c9a4fe1a8ac0a2afc15b Mon Sep 17 00:00:00 2001 From: Matthias Wisniowski Date: Sat, 14 Apr 2012 16:27:03 +0200 Subject: Testcases for 2 --- TestAufgabeFFP2.hs | 78 +++++++++++++++++------------------------------------- 1 file changed, 25 insertions(+), 53 deletions(-) (limited to 'TestAufgabeFFP2.hs') diff --git a/TestAufgabeFFP2.hs b/TestAufgabeFFP2.hs index 0df8612..61fdb51 100644 --- a/TestAufgabeFFP2.hs +++ b/TestAufgabeFFP2.hs @@ -4,66 +4,38 @@ import Test.HUnit import Control.Monad import AufgabeFFP2 -assertBoolF :: String -> Bool -> Assertion -assertBoolF msg b = when b (assertFailure msg) -------------------------------------------------------------------------------- --- 1 +cases1 = TestLabel "2.1" $ TestList [ + TestCase $ + [(3,5),(5,7),(11,13),(17,19),(29,31),(41,43), (59,61),(71,73),(101,103),(107,109)] + @=? (take 10 pps), + TestCase $ (347,349) @=? (pps!!20), + TestCase $ (809,811) @=? (head (drop 30 pps)) + ] -pps1 :: Test -pps1 = TestCase (assertEqual "pps" - [(3,5),(5,7),(11,13),(17,19),(29,31),(41,43), (59,61),(71,73),(101,103),(107,109)] - (take 10 pps)) -pps2 :: Test -pps2 = TestCase (assertEqual "pps" - (347,349) - (pps!!20)) - -pps3 :: Test -pps3 = TestCase (assertEqual "pps" - (809,811) - (head (drop 30 pps))) +cases2 = TestLabel "2.2" $ TestList [ + TestCase $ 1024 @=? (powFast 10), + TestCase $ (pow 10) @=? (powFast 10), + TestCase $ 1048576 @=? (powFast 20), + TestCase $ (pow 20) @=? (powFast 20) + ] -ppsTests = TestList [pps1, pps2, pps3] -------------------------------------------------------------------------------- --- 2 +cases3 = TestLabel "2.3" $ TestList [ + TestCase $ (fMT 10 10) @=? (f 10 10), + TestCase $ (fMT 50 10) @=? (f 50 10), + TestCase $ (fMT 1000 10) @=? (f 1000 10) + ] -------------------------------------------------------------------------------- --- 3 -------------------------------------------------------------------------------- --- 4 +cases4 = TestLabel "2.4" $ TestList [ + TestCase $ 144 @=? (gz 42), + TestCase $ 400 @=? (gz 402), + TestCase $ 144 @=? (gzs!!42), + TestCase $ 400 @=? (gzs!!402) + ] -gz1 :: Test -gz1 = TestCase (assertEqual "gz" - 144 - (gz 42)) -gz2 :: Test -gz2 = TestCase (assertEqual "gz" - 400 - (gz 402)) -gzs1 :: Test -gzs1 = TestCase (assertEqual "gzs" - 144 - (gzs!!41)) - -gzs2 :: Test -gzs2 = TestCase (assertEqual "gzs" - 400 - (gzs!!401)) - - -gzTests = TestList [gz1, gz2, gzs1, gzs2] - -------------------------------------------------------------------------------- - -tests :: [Test] -tests = [ppsTests, gzTests] - -main = do - forM tests $ \test -> - runTestTT test +main = runTestTT $ TestList [cases1, cases2, cases3, cases4] -- cgit v1.2.3