summaryrefslogtreecommitdiffstats
path: root/TestAufgabeFFP5.hs
diff options
context:
space:
mode:
authorMatthias Wisniowski <matthias.wisniowski@gmail.com>2012-05-06 22:24:13 +0200
committerMatthias Wisniowski <matthias.wisniowski@gmail.com>2012-05-06 22:24:13 +0200
commit2eb3ebc3247656c246258fd6a078fa5801ff80f3 (patch)
treebb10da183ca12cec493a8f0403437e3579840037 /TestAufgabeFFP5.hs
parent6d5084dde0a659debb606e837e8edf06b4b534cf (diff)
downloadffp-2eb3ebc3247656c246258fd6a078fa5801ff80f3.tar.gz
ffp-2eb3ebc3247656c246258fd6a078fa5801ff80f3.tar.bz2
ffp-2eb3ebc3247656c246258fd6a078fa5801ff80f3.zip
Aufgabe 5, 4. Almost done, except testing errors
Diffstat (limited to 'TestAufgabeFFP5.hs')
-rw-r--r--TestAufgabeFFP5.hs40
1 files changed, 39 insertions, 1 deletions
diff --git a/TestAufgabeFFP5.hs b/TestAufgabeFFP5.hs
index 256c1ea..eaace62 100644
--- a/TestAufgabeFFP5.hs
+++ b/TestAufgabeFFP5.hs
@@ -20,6 +20,11 @@ d = array (1,6) [(1, (-3)), (2, 1), (3, 10), (4, (-5)), (5, 8), (6, 7)]
20minA :: Array Int Int 20minA :: Array Int Int
21minA = array (0,0) [(0,0)] 21minA = array (0,0) [(0,0)]
22 22
23data Week = Mon | Tue | Wed | Thu | Fri | Sat | Sun deriving (Eq, Ord, Ix, Show)
24
25w :: Array Week String
26w = array (Tue, Sat) [(Wed, "work"), (Thu, "study"), (Tue, "study"), (Fri, "chill"), (Sat, "relax")]
27
23cases1 = TestLabel "mas" $ TestList [ 28cases1 = TestLabel "mas" $ TestList [
24 TestCase $ assertEqual "mas a" 29 TestCase $ assertEqual "mas a"
25 12 30 12
@@ -73,10 +78,43 @@ cases3 = TestLabel "lmas" $ TestList [
73 (0,0) 78 (0,0)
74 (lmas minA) 79 (lmas minA)
75 ] 80 ]
81
82cases4 = TestLabel "minIndex" $ TestList [
83 TestCase $ assertEqual "minIndex a (>5)"
84 4
85 (minIndex a (>5)),
86 TestCase $ assertEqual "minIndex a (<0)"
87 2
88 (minIndex a (<0)),
89 TestCase $ assertEqual "minIndex a (even)"
90 3
91 (minIndex a (even)),
92 TestCase $ assertEqual "minIndex b (odd)"
93 1
94 (minIndex b (odd)),
95 -- TestCase $ assertEqual "minIndex b (>100)"
96 -- error "No matching index"
97 -- (minIndex b (>100)),
98 TestCase $ assertEqual "minIndex w (=='relax')"
99 Sat
100 (minIndex w (=="relax")),
101 TestCase $ assertEqual "minIndex w (=='work')"
102 Wed
103 (minIndex w (=="work")),
104 TestCase $ assertEqual "minIndex w (=='chill')"
105 Fri
106 (minIndex w (=="chill")),
107 TestCase $ assertEqual "minIndex w (/='chill')"
108 Tue
109 (minIndex w (/="chill"))
110 -- TestCase $ assertEqual "minIndex w (=='swim')"
111 -- error "No matching index"
112 -- (minIndex w (=="swim"))
113 ]
76 114
77 115
78tests :: [Test] 116tests :: [Test]
79tests = [cases1, cases2, cases3] 117tests = [cases1, cases2, cases3, cases4]
80 118
81main = do 119main = do
82 forM tests $ \test -> 120 forM tests $ \test ->