diff options
Diffstat (limited to 'TestAufgabeFFP2.hs')
| -rw-r--r-- | TestAufgabeFFP2.hs | 78 |
1 files changed, 25 insertions, 53 deletions
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 | |||
| 4 | import Control.Monad | 4 | import Control.Monad |
| 5 | import AufgabeFFP2 | 5 | import AufgabeFFP2 |
| 6 | 6 | ||
| 7 | assertBoolF :: String -> Bool -> Assertion | ||
| 8 | assertBoolF msg b = when b (assertFailure msg) | ||
| 9 | 7 | ||
| 10 | ------------------------------------------------------------------------------- | 8 | cases1 = TestLabel "2.1" $ TestList [ |
| 11 | -- 1 | 9 | TestCase $ |
| 10 | [(3,5),(5,7),(11,13),(17,19),(29,31),(41,43), (59,61),(71,73),(101,103),(107,109)] | ||
| 11 | @=? (take 10 pps), | ||
| 12 | TestCase $ (347,349) @=? (pps!!20), | ||
| 13 | TestCase $ (809,811) @=? (head (drop 30 pps)) | ||
| 14 | ] | ||
| 12 | 15 | ||
| 13 | pps1 :: Test | ||
| 14 | pps1 = TestCase (assertEqual "pps" | ||
| 15 | [(3,5),(5,7),(11,13),(17,19),(29,31),(41,43), (59,61),(71,73),(101,103),(107,109)] | ||
| 16 | (take 10 pps)) | ||
| 17 | 16 | ||
| 18 | pps2 :: Test | 17 | cases2 = TestLabel "2.2" $ TestList [ |
| 19 | pps2 = TestCase (assertEqual "pps" | 18 | TestCase $ 1024 @=? (powFast 10), |
| 20 | (347,349) | 19 | TestCase $ (pow 10) @=? (powFast 10), |
| 21 | (pps!!20)) | 20 | TestCase $ 1048576 @=? (powFast 20), |
| 22 | 21 | TestCase $ (pow 20) @=? (powFast 20) | |
| 23 | pps3 :: Test | 22 | ] |
| 24 | pps3 = TestCase (assertEqual "pps" | ||
| 25 | (809,811) | ||
| 26 | (head (drop 30 pps))) | ||
| 27 | 23 | ||
| 28 | ppsTests = TestList [pps1, pps2, pps3] | ||
| 29 | 24 | ||
| 30 | ------------------------------------------------------------------------------- | 25 | cases3 = TestLabel "2.3" $ TestList [ |
| 31 | -- 2 | 26 | TestCase $ (fMT 10 10) @=? (f 10 10), |
| 27 | TestCase $ (fMT 50 10) @=? (f 50 10), | ||
| 28 | TestCase $ (fMT 1000 10) @=? (f 1000 10) | ||
| 29 | ] | ||
| 32 | 30 | ||
| 33 | ------------------------------------------------------------------------------- | ||
| 34 | -- 3 | ||
| 35 | 31 | ||
| 36 | ------------------------------------------------------------------------------- | 32 | cases4 = TestLabel "2.4" $ TestList [ |
| 37 | -- 4 | 33 | TestCase $ 144 @=? (gz 42), |
| 34 | TestCase $ 400 @=? (gz 402), | ||
| 35 | TestCase $ 144 @=? (gzs!!42), | ||
| 36 | TestCase $ 400 @=? (gzs!!402) | ||
| 37 | ] | ||
| 38 | 38 | ||
| 39 | gz1 :: Test | ||
| 40 | gz1 = TestCase (assertEqual "gz" | ||
| 41 | 144 | ||
| 42 | (gz 42)) | ||
| 43 | 39 | ||
| 44 | gz2 :: Test | ||
| 45 | gz2 = TestCase (assertEqual "gz" | ||
| 46 | 400 | ||
| 47 | (gz 402)) | ||
| 48 | 40 | ||
| 49 | gzs1 :: Test | 41 | main = runTestTT $ TestList [cases1, cases2, cases3, cases4] |
| 50 | gzs1 = TestCase (assertEqual "gzs" | ||
| 51 | 144 | ||
| 52 | (gzs!!41)) | ||
| 53 | |||
| 54 | gzs2 :: Test | ||
| 55 | gzs2 = TestCase (assertEqual "gzs" | ||
| 56 | 400 | ||
| 57 | (gzs!!401)) | ||
| 58 | |||
| 59 | |||
| 60 | gzTests = TestList [gz1, gz2, gzs1, gzs2] | ||
| 61 | |||
| 62 | ------------------------------------------------------------------------------- | ||
| 63 | |||
| 64 | tests :: [Test] | ||
| 65 | tests = [ppsTests, gzTests] | ||
| 66 | |||
| 67 | main = do | ||
| 68 | forM tests $ \test -> | ||
| 69 | runTestTT test | ||
