summaryrefslogtreecommitdiffstats
path: root/TestAufgabeFFP2.hs
blob: 1131e04b09f36355089162f36f4ac7784cdd21c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
module Main where

import Test.HUnit
import Control.Monad
import AufgabeFFP2

cases1 = TestLabel "pps" $ TestList [
  TestCase $ assertEqual "take 10 pps"
    [(3,5),(5,7),(11,13),(17,19),(29,31),(41,43), (59,61),(71,73),(101,103),(107,109)]
    (take 10 pps),
  TestCase $ assertEqual "pps!!20" (347,349) (pps!!20),
  TestCase $ assertEqual "head (drop 30 pps)" (809,811) (head (drop 30 pps))
  ]


cases2 = TestLabel "powFast" $ TestList [
  TestCase $ assertEqual "powFast 10" 1024     (powFast 10),
  TestCase $ assertEqual "powFast 10" (pow 10) (powFast 10),
  TestCase $ assertEqual "powFast 20" 1048576  (powFast 20),
  TestCase $ assertEqual "powFast 20" (pow 20) (powFast 20)
  ]

cases3 = TestLabel "fMT/f" $ TestList [
  TestCase $ assertEqual "fMT/f 10 10"   (fMT 10 10)   (f 10 10),
  TestCase $ assertEqual "fMT/f 50 10"   (fMT 50 10)   (f 50 10),
  TestCase $ assertEqual "fMT/f 1000 10" (fMT 1000 10) (f 1000 10)
  ]

cases4 = TestLabel "gz/gzs" $ TestList [
  TestCase $ assertEqual "gz 42"    144 (gz 42),
  TestCase $ assertEqual "gz 402"   400 (gz 402),
  TestCase $ assertEqual "gzs!!42"  432 (gzs!!42),
  TestCase $ assertEqual "gzs!!402" 2000 (gzs!!402),
  TestCase $ assertEqual "take 7 gzs" [2,4,8,16,32,64,128] (take 7 gzs),
  TestCase $ assertEqual "take 20 gzs" [gz i|i<-[1..20]] (take 20 gzs),
  TestCase $ assertEqual "(sum.take 100) gzs" 30174552 ((sum.take 100) gzs)
  ]

tests :: [Test]
tests = [cases1, cases2, cases3, cases4]

main = do
  forM tests $ \test ->
    runTestTT test