diff options
Diffstat (limited to 'TestAufgabeFFP3.hs')
| -rwxr-xr-x[-rw-r--r--] | TestAufgabeFFP3.hs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/TestAufgabeFFP3.hs b/TestAufgabeFFP3.hs index 065401d..30a915e 100644..100755 --- a/TestAufgabeFFP3.hs +++ b/TestAufgabeFFP3.hs | |||
| @@ -1,10 +1,13 @@ | |||
| 1 | #!/usr/bin/runhugs +l | ||
| 2 | |||
| 1 | module Main where | 3 | module Main where |
| 2 | 4 | ||
| 3 | import Prelude hiding (filter) | 5 | import Prelude hiding (filter) |
| 4 | 6 | ||
| 5 | |||
| 6 | import Test.HUnit | 7 | import Test.HUnit |
| 7 | import Control.Monad | 8 | import Control.Monad |
| 9 | import System | ||
| 10 | import Data.Array | ||
| 8 | import AufgabeFFP3 | 11 | import AufgabeFFP3 |
| 9 | 12 | ||
| 10 | cases1 = TestLabel "foo" $ TestList [ | 13 | cases1 = TestLabel "foo" $ TestList [ |
| @@ -33,11 +36,17 @@ cases4 = TestLabel "bar" $ TestList [ | |||
| 33 | TestCase $ assertEqual "a" ( [binomS (n, k) | k <- [0..50], n <- [k..50] ] ) ( [binomM (n, k) | k <- [0..50], n <- [k..50] ] ) | 36 | TestCase $ assertEqual "a" ( [binomS (n, k) | k <- [0..50], n <- [k..50] ] ) ( [binomM (n, k) | k <- [0..50], n <- [k..50] ] ) |
| 34 | ] | 37 | ] |
| 35 | 38 | ||
| 36 | |||
| 37 | tests :: [Test] | 39 | tests :: [Test] |
| 38 | tests = [cases1, cases2, cases3, cases4] | 40 | tests = [cases1, cases2, cases3, cases4] |
| 39 | 41 | ||
| 40 | main = do | 42 | isSuccess :: Counts -> Bool |
| 41 | forM tests $ \test -> | 43 | isSuccess Counts{ cases = _, tried = _, errors = 0, failures = 0 } = True |
| 42 | runTestTT test | 44 | isSuccess Counts{ cases = _, tried = _, errors = _, failures = _ } = False |
| 45 | |||
| 46 | runTest :: Test -> IO () | ||
| 47 | runTest test = do | ||
| 48 | result <- runTestTT test | ||
| 49 | unless (isSuccess result) exitFailure | ||
| 43 | 50 | ||
| 51 | main = do | ||
| 52 | forM tests $ (\test -> runTest test) | ||
