diff --git a/Other/WeishauptOrlando_1/tests/TestCount_ED.py b/Other/WeishauptOrlando_1/tests/TestCount_ED.py new file mode 100644 index 0000000000000000000000000000000000000000..152bccd1cb4dff5df43c1c368fea2de123bfc632 --- /dev/null +++ b/Other/WeishauptOrlando_1/tests/TestCount_ED.py @@ -0,0 +1,34 @@ +import unittest +import sys +import os + +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../src'))) +from src.Count_ED import Counter + +class TestCounter(unittest.TestCase): + def setUp(self): + self.c = Counter() + + def test_count_ed_regular(self): + self.assertEqual(self.c.count_ed("Decker"), 3) + + def test_count_ed_empty(self): + self.assertEqual(self.c.count_ed(""), 0) + + def test_count_ed_wo(self): + """Testet einen String ohne E und D""" + self.assertEqual(self.c.count_ed("Hallo"), 0) + + def test_count_ed_case_insensitive(self): + """Testet verschiedene Groß- und Kleinschreibungen""" + self.assertEqual(self.c.count_ed("Der Esel"), 4) + + def test_count_ED_single_letter(self): + """Testet Eingaben mit nur einem Buchstaben""" + self.assertEqual(self.c.count_ed('D'), 1) + self.assertEqual(self.c.count_ed('E'), 1) + self.assertEqual(self.c.count_ed('d'), 1) + self.assertEqual(self.c.count_ed('e'), 1) + +if __name__ == "__main__": + unittest.main() \ No newline at end of file diff --git a/Other/WeishauptOrlando_1/tests/__init__.py b/Other/WeishauptOrlando_1/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Other/WeishauptOrlando_1/tests/test_calculator.py b/Other/WeishauptOrlando_1/tests/test_calculator.py new file mode 100644 index 0000000000000000000000000000000000000000..a0c79315eb48c048e5a191db3037f095771d70a9 --- /dev/null +++ b/Other/WeishauptOrlando_1/tests/test_calculator.py @@ -0,0 +1,103 @@ +# Testfälle für calculate(), Eingabe: str, Ausgabe: float/int + +# 1ï¸âƒ£ Additionstests +# Eingabe: "1+1" → Erwartete Ausgabe: 2 +# Eingabe: "10+20" → Erwartete Ausgabe: 30 +# Eingabe: "0+5" → Erwartete Ausgabe: 5 +# Eingabe: "-3+7" → Erwartete Ausgabe: 4 +# Eingabe: "2.5+2.5" → Erwartete Ausgabe: 5.0 + +# 2ï¸âƒ£ Subtraktionstests +# Eingabe: "5-3" → Erwartete Ausgabe: 2 +# Eingabe: "10-20" → Erwartete Ausgabe: -10 +# Eingabe: "0-5" → Erwartete Ausgabe: -5 +# Eingabe: "-3-7" → Erwartete Ausgabe: -10 +# Eingabe: "2.5-1.5" → Erwartete Ausgabe: 1.0 + +# 3ï¸âƒ£ Multiplikationstests +# Eingabe: "2*3" → Erwartete Ausgabe: 6 +# Eingabe: "10*0" → Erwartete Ausgabe: 0 +# Eingabe: "-2*5" → Erwartete Ausgabe: -10 +# Eingabe: "3.5*2" → Erwartete Ausgabe: 7.0 +# Eingabe: "-3*-3" → Erwartete Ausgabe: 9 + +# 4ï¸âƒ£ Divisionstests +# Eingabe: "10/2" → Erwartete Ausgabe: 5 +# Eingabe: "5/2" → Erwartete Ausgabe: 2.5 +# Eingabe: "-6/3" → Erwartete Ausgabe: -2 +# Eingabe: "7.5/2.5" → Erwartete Ausgabe: 3.0 +# Eingabe: "5/0" → Erwartete Ausgabe: ZeroDivisionError (Fehlermeldung) + +# 5ï¸âƒ£ Komplexe Berechnungen +# Eingabe: "3+5*2" → Erwartete Ausgabe: 13 (Multiplikation vor Addition) +# Eingabe: "(3+5)*2" → Erwartete Ausgabe: 16 (Klammer zuerst) +# Eingabe: "10-4/2" → Erwartete Ausgabe: 8 (Division vor Subtraktion) +# Eingabe: "3+(2*5)-8/4" → Erwartete Ausgabe: 10 (Mehrere Operatoren) + +# 6ï¸âƒ£ Ungültige Eingaben +# Eingabe: "3++5" → Erwartete Ausgabe: SyntaxError (Fehlermeldung) +# Eingabe: "10*/2" → Erwartete Ausgabe: SyntaxError (Fehlermeldung) +# Eingabe: "abc" → Erwartete Ausgabe: ValueError (Fehlermeldung) + + +import unittest +from src.calculator import Calculator + +class TestCalculator(unittest.TestCase): + def setUp(self): + self.calc = Calculator() + + # Addition + def test_addition(self): + self.assertEqual(self.calc.calculate("1+1"), 2) + self.assertEqual(self.calc.calculate("10+20"), 30) + self.assertEqual(self.calc.calculate("0+5"), 5) + self.assertEqual(self.calc.calculate("-3+7"), 4) + self.assertEqual(self.calc.calculate("2.5+2.5"), 5.0) + + # Subtraktion + def test_subtraction(self): + self.assertEqual(self.calc.calculate("5-3"), 2) + self.assertEqual(self.calc.calculate("10-20"), -10) + self.assertEqual(self.calc.calculate("0-5"), -5) + self.assertEqual(self.calc.calculate("-3-7"), -10) + self.assertEqual(self.calc.calculate("2.5-1.5"), 1.0) + + # Multiplikation + def test_multiplication(self): + self.assertEqual(self.calc.calculate("2*3"), 6) + self.assertEqual(self.calc.calculate("10*0"), 0) + self.assertEqual(self.calc.calculate("-2*5"), -10) + self.assertEqual(self.calc.calculate("3.5*2"), 7.0) + self.assertEqual(self.calc.calculate("-3*-3"), 9) + + # Division + def test_division(self): + self.assertEqual(self.calc.calculate("10/2"), 5) + self.assertEqual(self.calc.calculate("5/2"), 2.5) + self.assertEqual(self.calc.calculate("-6/3"), -2) + self.assertEqual(self.calc.calculate("7.5/2.5"), 3.0) + + # Division durch Null + def test_division_by_zero(self): + with self.assertRaises(ZeroDivisionError): + self.calc.calculate("5/0") + + # Komplexe Berechnungen + def test_complex_expressions(self): + self.assertEqual(self.calc.calculate("3+5*2"), 13) # Punkt-vor-Strich beachten + self.assertEqual(self.calc.calculate("(3+5)*2"), 16) # Klammer zuerst + self.assertEqual(self.calc.calculate("10-4/2"), 8) # Division vor Subtraktion + self.assertEqual(self.calc.calculate("3+(2*5)-8/4"), 11.0) # 11 + + # Ungültige Eingaben + def test_invalid_expressions(self): + with self.assertRaises(ValueError): + self.calc.calculate("3++5") + with self.assertRaises(ValueError): + self.calc.calculate("10*/2") + with self.assertRaises(ValueError): + self.calc.calculate("abc") + +if __name__ == "__main__": + unittest.main() \ No newline at end of file diff --git a/Other/WeishauptOrlando_1/tests/test_roman.py b/Other/WeishauptOrlando_1/tests/test_roman.py new file mode 100644 index 0000000000000000000000000000000000000000..30cbabf8e6517f5fdcb4741df4389df09b0d3817 --- /dev/null +++ b/Other/WeishauptOrlando_1/tests/test_roman.py @@ -0,0 +1,66 @@ +# Testfälle roman_to_int, str -> int + +# 1. Einzelne römische Ziffern +# Eingabe: "I" → Erwartete Ausgabe: 1 +# Eingabe: "V" → Erwartete Ausgabe: 5 +# Eingabe: "X" → Erwartete Ausgabe: 10 +# Eingabe: "L" → Erwartete Ausgabe: 50 +# Eingabe: "C" → Erwartete Ausgabe: 100 +# Eingabe: "D" → Erwartete Ausgabe: 500 +# Eingabe: "M" → Erwartete Ausgabe: 1000 + +#2. Mehrere gleiche Ziffern hintereinander (einfache Addition) +# Eingabe: "II" → Erwartete Ausgabe: 2 +# Eingabe: "XX" → Erwartete Ausgabe: 20 +# Eingabe: "CC" → Erwartete Ausgabe: 200 +# Eingabe: "MM" → Erwartete Ausgabe: 2000 + +#3. Subtraktive Notation +# Eingabe: "IV" → Erwartete Ausgabe: 4 +# Eingabe: "IX" → Erwartete Ausgabe: 9 +# Eingabe: "XL" → Erwartete Ausgabe: 40 +# Eingabe: "XC" → Erwartete Ausgabe: 90 +# Eingabe: "CD" → Erwartete Ausgabe: 400 +# Eingabe: "CM" → Erwartete Ausgabe: 900 + +#4. Komplexe Zahlen +# Eingabe: "MCMXCIV" → Erwartete Ausgabe: 1994 +#Eingabe: "XIV" → Erwartete Ausgabe: 14 +#Eingabe: "CDXLIV" → Erwartete Ausgabe: 444 + + +import sys +import os +import unittest + +# Füge das src-Verzeichnis zum Python-Pfad hinzu +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../src'))) + +from src.RomanConverter import RomanConverter # Importiere die zu testende Klasse + +class TestRomanConverter(unittest.TestCase): + def setUp(self): + self.converter = RomanConverter() + + def test_single_digits(self): + self.assertEqual(self.converter.roman_to_int("I"), 1) + self.assertEqual(self.converter.roman_to_int("V"), 5) + self.assertEqual(self.converter.roman_to_int("X"), 10) + + def test_multiple_digits(self): + self.assertEqual(self.converter.roman_to_int("II"), 2) + self.assertEqual(self.converter.roman_to_int("XX"), 20) + self.assertEqual(self.converter.roman_to_int("VI"), 6) + + def test_subtractive_notation(self): + self.assertEqual(self.converter.roman_to_int("IV"), 4) + self.assertEqual(self.converter.roman_to_int("IX"), 9) + self.assertEqual(self.converter.roman_to_int("XL"), 40) + self.assertEqual(self.converter.roman_to_int("XC"), 90) + + def test_complex_numbers(self): + self.assertEqual(self.converter.roman_to_int("MCMXCIV"), 1994) + self.assertEqual(self.converter.roman_to_int("CDXLIV"), 444) + +if __name__ == "__main__": + unittest.main() \ No newline at end of file