#!/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)