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
45
46
47
48
49
50
|
#!/usr/bin/runhugs +l
module Main where
import Test.HUnit
import Control.Monad
import System
import AufgabeFFP7
import Test.QuickCheck
import System.IO.Unsafe
{--
cases1 = TestLabel "TODO" $ TestList [
TestCase $ assertEqual "TODO" (result) (call)
...
]
--}
--------------------------------------------------------------------------------
cases2 = TestLabel "ssfn/minfree" $ TestList [
TestCase $ assertEqual "ssfn1" (5) (ssfn [0,1,2,3,4,6,7,8,9]),
TestCase $ assertEqual "minfree1" (5) (minfree [0,1,2,3,4,6,7,8,9]),
TestCase $ assertEqual "ssfn2" (0) (ssfn [1,2,3,4,5,6,7,8,9]),
TestCase $ assertEqual "minfree2" (0) (minfree [1,2,3,4,5,6,7,8,9]),
TestCase $ assertEqual "ssfn/minfree"
(ssfn (filter (/=499) [0..520]))
(minfree (filter (/=499) [0..520])),
TestCase $ assertEqual "quickCheck1" ()
(unsafePerformIO (quickCheck prop_ssfn_eq_minfree_a)),
TestCase $ assertEqual "quickCheck2" ()
(unsafePerformIO (quickCheck prop_ssfn_eq_minfree_b))
]
--------------------------------------------------------------------------------
tests :: [Test]
tests = [cases2]
isSuccess :: Counts -> Bool
isSuccess Counts{ cases = _, tried = _, errors = 0, failures = 0 } = True
isSuccess Counts{ cases = _, tried = _, errors = _, failures = _ } = False
runTest :: Test -> IO ()
runTest test = do
result <- runTestTT test
unless (isSuccess result) exitFailure
main = do
forM tests $ (\test -> runTest test)
|