initial commit
This commit is contained in:
		
							
								
								
									
										17
									
								
								test/Aufgabe1-Spec.hs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								test/Aufgabe1-Spec.hs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
import Aufgabe1
 | 
			
		||||
 | 
			
		||||
import Test.Framework.Providers.HUnit (testCase)
 | 
			
		||||
import Test.Framework.Runners.Console (defaultMain)
 | 
			
		||||
 | 
			
		||||
import Test.HUnit
 | 
			
		||||
 | 
			
		||||
test1 = testCase "filter funktioniert" $ assertEqual "Vowel filter" "Hll Wrld!" result
 | 
			
		||||
 | 
			
		||||
testSentence2 = "Is really EVERY VowEL of this uSEleSS SentencE remOved?"
 | 
			
		||||
testResult2 = "s rlly VRY VwL f ths SlSS Sntnc rmvd?"
 | 
			
		||||
test2 = testCase "filter test" $ assertEqual testSentence2 testResult2 $ filterVowels testSentence2 
 | 
			
		||||
 | 
			
		||||
tests = [test1, test2]
 | 
			
		||||
 | 
			
		||||
main :: IO ()
 | 
			
		||||
main = defaultMain tests
 | 
			
		||||
							
								
								
									
										40
									
								
								test/Aufgabe2-Spec.hs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								test/Aufgabe2-Spec.hs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
			
		||||
import Aufgabe2
 | 
			
		||||
 | 
			
		||||
import Test.Framework.Providers.HUnit (testCase)
 | 
			
		||||
import Test.Framework.Runners.Console (defaultMain)
 | 
			
		||||
 | 
			
		||||
import Test.HUnit
 | 
			
		||||
 | 
			
		||||
import Lib
 | 
			
		||||
 | 
			
		||||
instance (Eq a, Eq b, Eq c) => Eq (Article a b c) where
 | 
			
		||||
  (Article a b c) == (Article a' b' c') = a == a' && b == b' && c == c'
 | 
			
		||||
 | 
			
		||||
data TestProd = Tp1 | Tp2 | Tp3 deriving (Eq, Show)
 | 
			
		||||
 | 
			
		||||
emptyProductList :: ProductList Int () ()
 | 
			
		||||
emptyProductList = ListEnd
 | 
			
		||||
 | 
			
		||||
productList :: ProductList Int TestProd ()
 | 
			
		||||
productList = insert (Article 0 Tp1 ())
 | 
			
		||||
            $ insert (Article 1 Tp2 ())
 | 
			
		||||
            $ insert (Article 2 Tp3 ())
 | 
			
		||||
            $ ListEnd
 | 
			
		||||
 | 
			
		||||
emptyFind = testCase "Suche in leerer Liste"
 | 
			
		||||
          $ assertEqual "empty list search" Nothing
 | 
			
		||||
          $ findArticle 0 emptyProductList
 | 
			
		||||
 | 
			
		||||
findNone = testCase "Suche nach nicht vorhandenem"
 | 
			
		||||
         $ assertEqual "find nothing" Nothing 
 | 
			
		||||
         $ findArticle 3 productList
 | 
			
		||||
 | 
			
		||||
findSome = testCase "Suche nach vorhandenem"
 | 
			
		||||
         $ assertEqual "find some" (Just $ Article 0 Tp1 ()) 
 | 
			
		||||
         $ findArticle 0 productList
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
tests = [emptyFind, findNone, findSome]
 | 
			
		||||
 | 
			
		||||
main :: IO ()
 | 
			
		||||
main = defaultMain tests
 | 
			
		||||
							
								
								
									
										63
									
								
								test/Aufgabe3-Spec.hs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								test/Aufgabe3-Spec.hs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,63 @@
 | 
			
		||||
import Aufgabe3
 | 
			
		||||
 | 
			
		||||
import Test.Framework.Providers.HUnit (testCase)
 | 
			
		||||
import Test.Framework.Runners.Console (defaultMain)
 | 
			
		||||
 | 
			
		||||
import Test.HUnit
 | 
			
		||||
 | 
			
		||||
import Lib
 | 
			
		||||
 | 
			
		||||
data TestProd = Tp1 | Tp2 | Tp3 deriving (Eq, Show)
 | 
			
		||||
 | 
			
		||||
productList :: ProductList Int TestProd ()
 | 
			
		||||
productList = insert (Article 0 Tp1 ())
 | 
			
		||||
            $ insert (Article 1 Tp2 ())
 | 
			
		||||
            $ insert (Article 2 Tp3 ())
 | 
			
		||||
            $ ListEnd
 | 
			
		||||
 | 
			
		||||
emptyScannerList :: ScannerList Int TestProd ()
 | 
			
		||||
emptyScannerList = AmountListEnd
 | 
			
		||||
 | 
			
		||||
scannerList1 = scan 0 productList emptyScannerList
 | 
			
		||||
scannerList2 = scan 9 productList emptyScannerList
 | 
			
		||||
scannerList3 = scannerList1 >>= scan 0 productList
 | 
			
		||||
scannerList4 = scannerList3 >>= scan 1 productList
 | 
			
		||||
scannerList5 = scannerList4 >>= scan 2 productList
 | 
			
		||||
scannerList6 = scannerList5 >>= scan 9 productList
 | 
			
		||||
scannerList7 = scannerList5 >>= scan 1 productList 
 | 
			
		||||
scannerList8 = scannerList7 >>= scan 0 productList
 | 
			
		||||
scannerList9 = scannerList8 >>= scan 9 productList
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
scan1 = testCase "Scan,     existing product, list size: 0                         "
 | 
			
		||||
      $ assertEqual "scan 1" (Just $ AmountAndElement 1 (Article 0 Tp1 ()) AmountListEnd) scannerList1
 | 
			
		||||
 | 
			
		||||
scan2 = testCase "Scan, not existing product, list size: 0                         "
 | 
			
		||||
      $ assertEqual "scan 2" Nothing scannerList2
 | 
			
		||||
 | 
			
		||||
scan3 = testCase "Scan,     existing product, list size: 1, product already in list"
 | 
			
		||||
      $ assertEqual "scan 3" (Just $ AmountAndElement 2 (Article 0 Tp1 ()) AmountListEnd) scannerList3
 | 
			
		||||
 | 
			
		||||
scan4 = testCase "Scan,     existing product, list size: 1, product not in list    "
 | 
			
		||||
      $ assertEqual "scan 4" (Just $ AmountAndElement 2 (Article 0 Tp1 ()) $ AmountAndElement 1 (Article 1 Tp2 ()) AmountListEnd) scannerList4
 | 
			
		||||
 | 
			
		||||
scan5 = testCase "Scan,     existing product, list size: 2, product not in list    "
 | 
			
		||||
      $ assertEqual "scan 5" (Just $ AmountAndElement 2 (Article 0 Tp1 ()) $ AmountAndElement 1 (Article 1 Tp2 ()) $ AmountAndElement 1 (Article 2 Tp3 ()) AmountListEnd) scannerList5
 | 
			
		||||
 | 
			
		||||
scan6 = testCase "Scan, not existing product, list size: 2                         "
 | 
			
		||||
      $ assertEqual "scan 3" Nothing scannerList6
 | 
			
		||||
 | 
			
		||||
scan7 = testCase "Scan,     existing product, list size: 3, product in list        "
 | 
			
		||||
      $ assertEqual "scan 7" (Just $ AmountAndElement 2 (Article 0 Tp1 ()) $ AmountAndElement 2 (Article 1 Tp2 ()) $ AmountAndElement 1 (Article 2 Tp3 ()) AmountListEnd) scannerList7
 | 
			
		||||
 | 
			
		||||
scan8 = testCase "Scan,     existing product, list size: 3, product in list        "
 | 
			
		||||
      $ assertEqual "scan 8" (Just $ AmountAndElement 3 (Article 0 Tp1 ()) $ AmountAndElement 2 (Article 1 Tp2 ()) $ AmountAndElement 1 (Article 2 Tp3 ()) AmountListEnd) scannerList8
 | 
			
		||||
 | 
			
		||||
scan9 = testCase "Scan, not existing product, list size: 3                         "
 | 
			
		||||
      $ assertEqual "scan 9" Nothing scannerList9
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
tests = [scan1, scan2, scan3, scan4, scan5, scan6, scan7, scan8, scan9]
 | 
			
		||||
 | 
			
		||||
main :: IO ()
 | 
			
		||||
main = defaultMain tests
 | 
			
		||||
							
								
								
									
										4
									
								
								test/Aufgabe4-Spec.hs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								test/Aufgabe4-Spec.hs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
main :: IO ()
 | 
			
		||||
main = do
 | 
			
		||||
  putStrLn "Da Ihnen in dieser Aufgabe Platz für Kreativität eingeräumt wurde,"
 | 
			
		||||
  putStrLn "lässt sich Ihre Lösung leider nicht automatisiert überprüfen."
 | 
			
		||||
		Reference in New Issue
	
	Block a user