summaryrefslogtreecommitdiffstats
path: root/TestAufgabeFFP8.hs
blob: 6e1e5a138c339c22b28d0119ec0879ef963e1db5 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/usr/bin/runhugs +l

module Main where
  
import Test.HUnit
import Control.Monad
import System
import AufgabeFFP8
import Test.QuickCheck
import System.IO.Unsafe

---------------------------------
-- Instanzen

a :: [Int]
a = []

b :: [Int]
b = [0]

c :: [Int]
c = [1]

d :: [Int]
d = [2,0,1]

e :: [Int]
e = [1,2,3]

f :: [Int]
f = [0,1,2,3,5]

g :: [Int]
g = [5,0,1,3,2]

h :: [Int]
h = [0..1000]

l :: [Int]
l = [0..4000]

---------------------------------
cases1 = "minfree_bv" ~: TestList [
  "minfree_bv a"  ~: 0      ~=? (minfree_bv a),
  "minfree_bv b"  ~: 1      ~=? (minfree_bv b),
  "minfree_bv c"  ~: 0      ~=? (minfree_bv c),
  "minfree_bv d"  ~: 3      ~=? (minfree_bv d),
  "minfree_bv e"  ~: 0      ~=? (minfree_bv e),
  "minfree_bv f"  ~: 4      ~=? (minfree_bv f),
  "minfree_bv g"  ~: 4      ~=? (minfree_bv g),
  "minfree_bv h"  ~: 1001   ~=? (minfree_bv h),
  "minfree_bv l"  ~: 4001   ~=? (minfree_bv l)
  ]

cases2 = "minfree_chl" ~: TestList [
  "minfree_chl a"  ~: 0      ~=? (minfree_chl a),
  "minfree_chl b"  ~: 1      ~=? (minfree_chl b),
  "minfree_chl c"  ~: 0      ~=? (minfree_chl c),
  "minfree_chl d"  ~: 3      ~=? (minfree_chl d),
  "minfree_chl e"  ~: 0      ~=? (minfree_chl e),
  "minfree_chl f"  ~: 4      ~=? (minfree_chl f),
  "minfree_chl g"  ~: 4      ~=? (minfree_chl g),
  "minfree_chl h"  ~: 1001   ~=? (minfree_chl h),
  "minfree_chl l"  ~: 4001   ~=? (minfree_chl l)
  ]
  
cases3 = "minfree_col" ~: TestList [
  "minfree_col a"  ~: 0      ~=? (minfree_col a),
  "minfree_col b"  ~: 1      ~=? (minfree_col b),
  "minfree_col c"  ~: 0      ~=? (minfree_col c),
  "minfree_col d"  ~: 3      ~=? (minfree_col d),
  "minfree_col e"  ~: 0      ~=? (minfree_col e),
  "minfree_col f"  ~: 4      ~=? (minfree_col f),
  "minfree_col g"  ~: 4      ~=? (minfree_col g),
  "minfree_col h"  ~: 1001   ~=? (minfree_col h),
  "minfree_col l"  ~: 4001   ~=? (minfree_col l)
  ]
    
cases4 = "minfree_b" ~: TestList [
  "minfree_b a"  ~: 0      ~=? (minfree_b a),
  "minfree_b b"  ~: 1      ~=? (minfree_b b),
  "minfree_b c"  ~: 0      ~=? (minfree_b c),
  "minfree_b d"  ~: 3      ~=? (minfree_b d),
  "minfree_b e"  ~: 0      ~=? (minfree_b e),
  "minfree_b f"  ~: 4      ~=? (minfree_b f),
  "minfree_b g"  ~: 4      ~=? (minfree_b g),
  "minfree_b h"  ~: 1001   ~=? (minfree_b h),
  "minfree_b l"  ~: 4001   ~=? (minfree_b l)
  ]

cases5 = "minfree_r" ~: TestList [
  "minfree_r a"  ~: 0      ~=? (minfree_r a),
  "minfree_r b"  ~: 1      ~=? (minfree_r b),
  "minfree_r c"  ~: 0      ~=? (minfree_r c),
  "minfree_r d"  ~: 3      ~=? (minfree_r d),
  "minfree_r e"  ~: 0      ~=? (minfree_r e),
  "minfree_r f"  ~: 4      ~=? (minfree_r f),
  "minfree_r g"  ~: 4      ~=? (minfree_r g),
  "minfree_r h"  ~: 1001   ~=? (minfree_r h),
  "minfree_r l"  ~: 4001   ~=? (minfree_r l)
  ]
    
cases6 = "minfree_o" ~: TestList [
  "minfree_o a"  ~: 0      ~=? (minfree_o a),
  "minfree_o b"  ~: 1      ~=? (minfree_o b),
  "minfree_o c"  ~: 0      ~=? (minfree_o c),
  "minfree_o d"  ~: 3      ~=? (minfree_o d),
  "minfree_o e"  ~: 0      ~=? (minfree_o e),
  "minfree_o f"  ~: 4      ~=? (minfree_o f),
  "minfree_o g"  ~: 4      ~=? (minfree_o g),
  "minfree_o h"  ~: 1001   ~=? (minfree_o h),
  "minfree_o l"  ~: 4001   ~=? (minfree_o l)
  ]
  
cases7 = "minfree_bhof" ~: TestList [
  "minfree_bhof a"  ~: 0      ~=? (minfree_bhof a),
  "minfree_bhof b"  ~: 1      ~=? (minfree_bhof b),
  "minfree_bhof c"  ~: 0      ~=? (minfree_bhof c),
  "minfree_bhof d"  ~: 3      ~=? (minfree_bhof d),
  "minfree_bhof e"  ~: 0      ~=? (minfree_bhof e),
  "minfree_bhof f"  ~: 4      ~=? (minfree_bhof f),
  "minfree_bhof g"  ~: 4      ~=? (minfree_bhof g),
  "minfree_bhof h"  ~: 1001   ~=? (minfree_bhof h),
  "minfree_bhof l"  ~: 4001   ~=? (minfree_bhof l)
  ]

cases8 = "minfree_rhof" ~: TestList [
  "minfree_rhof a"  ~: 0      ~=? (minfree_rhof a),
  "minfree_rhof b"  ~: 1      ~=? (minfree_rhof b),
  "minfree_rhof c"  ~: 0      ~=? (minfree_rhof c),
  "minfree_rhof d"  ~: 3      ~=? (minfree_rhof d),
  "minfree_rhof e"  ~: 0      ~=? (minfree_rhof e),
  "minfree_rhof f"  ~: 4      ~=? (minfree_rhof f),
  "minfree_rhof g"  ~: 4      ~=? (minfree_rhof g),
  "minfree_rhof h"  ~: 1001   ~=? (minfree_rhof h),
  "minfree_rhof l"  ~: 4001   ~=? (minfree_rhof l)
  ]
  
cases9 = "minfree_ohof" ~: TestList [
  "minfree_ohof a"  ~: 0      ~=? (minfree_ohof a),
  "minfree_ohof b"  ~: 1      ~=? (minfree_ohof b),
  "minfree_ohof c"  ~: 0      ~=? (minfree_ohof c),
  "minfree_ohof d"  ~: 3      ~=? (minfree_ohof d),
  "minfree_ohof e"  ~: 0      ~=? (minfree_ohof e),
  "minfree_ohof f"  ~: 4      ~=? (minfree_ohof f),
  "minfree_ohof g"  ~: 4      ~=? (minfree_ohof g),
  "minfree_ohof h"  ~: 1001   ~=? (minfree_ohof h),
  "minfree_ohof l"  ~: 4001   ~=? (minfree_ohof l)
  ]

---------------------------------
tests :: [Test]
tests = [cases1, cases2, cases3, cases4, cases5, cases6]

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)