From 27751e1d55fbc76f336dc7a76b5b5aedcb5899c1 Mon Sep 17 00:00:00 2001 From: Muhamed <Muhamedalici@hotmail.de> Date: Fri, 4 Apr 2025 13:41:06 +0200 Subject: [PATCH] ich vs Lasse --- muhamed_directory/String calculator | 59 ++++++++++++++++-- .../test_stringclaculator.cpython-311.pyc | Bin 0 -> 6470 bytes muhamed_directory/other/report.md | 17 ++++- 3 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 muhamed_directory/other/Lasse/__pycache__/test_stringclaculator.cpython-311.pyc diff --git a/muhamed_directory/String calculator b/muhamed_directory/String calculator index 0a39f92..ef4e56c 100644 --- a/muhamed_directory/String calculator +++ b/muhamed_directory/String calculator @@ -9,7 +9,8 @@ import unittest import re from abc import ABC, abstractmethod -from other.Lasse.stringcalculator import StringCalculator as Lasse +#from other.Lasse.stringcalculator import StringCalculator as Lasse +#from other.Lasse.test_stringclaculator import TestStringCalculator as lassetest -> Geht nicht class CalculatorInterface(ABC): @abstractmethod @@ -60,9 +61,59 @@ class StringCalculator(CalculatorInterface): return sum(numbers_to_add) def get_called_count(self): return self.called_count - + +class TestStringCalculator(unittest.TestCase): + + def setUp(self): + self.calculator = StringCalculator() + + def test_add_empty_string(self): + self.assertEqual(self.calculator.add(""), 0) + + def test_add_single_number(self): + self.assertEqual(self.calculator.add("1"), 1) + + def test_add_two_numbers(self): + self.assertEqual(self.calculator.add("10,20"), 30) + + def test_add_multiple_numbers(self): + self.assertEqual(self.calculator.add("1,2,3"), 6) + self.assertEqual(self.calculator.add("10,20,30,40"), 100) + + def test_add_with_newline_separator(self): + self.assertEqual(self.calculator.add("1\n2,3"), 6) + self.assertEqual(self.calculator.add("10\n20\n30"), 60) + + def test_add_single_negative_number(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("1,-2,3") + print(str(context.exception)) + self.assertEqual(str(context.exception), "Negative nicht erlaubt: [-2]") + + def test_add_multiple_negative_numbers(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("-10\n-20,-30") + print(str(context.exception)) + self.assertEqual(str(context.exception), "Negative nicht erlaubt: [-10, -20, -30]") + + def test_add_with_custom_delimiter(self): + self.assertEqual(self.calculator.add("//;\n1;2"), 3) + self.assertEqual(self.calculator.add("//x\n7x8\n9"), 24) + + def test_invalid_custom_delimiter_format(self): + with self.assertRaises(ValueError) as context: + self.calculator.add("//;1;2") + print(str(context.exception)) + + def test_ignore_numbers_greater_than_1000(self): + self.assertEqual(self.calculator.add("2,1001"), 2) + self.assertEqual(self.calculator.add("1002,50200"), 0) + + def test_add_with_custom_delimiter_multiple_characters(self): + self.assertEqual(self.calculator.add("//[**]\n1**2**3"), 6) + self.assertEqual(self.calculator.add("//[###]\n10###20###30"), 60) -class TestStingCalculator(unittest.TestCase): +'''class TestStingCalculator(unittest.TestCase): def setUp(self): self.calculator = Lasse() def test_empty_string(self): @@ -116,7 +167,7 @@ class TestStingCalculator(unittest.TestCase): def test_custom_del(self): self.assertEqual(self.calculator.add("//[+++]\n1+++2+++3"),6) def test_custom_del2(self): - self.assertEqual(self.calculator.add("//[aa]\n1aa2aa3"),6) + self.assertEqual(self.calculator.add("//[aa]\n1aa2aa3"),6)''' diff --git a/muhamed_directory/other/Lasse/__pycache__/test_stringclaculator.cpython-311.pyc b/muhamed_directory/other/Lasse/__pycache__/test_stringclaculator.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..972efcde27dd3a1dfa6140948dbef025095fa998 GIT binary patch literal 6470 zcmeHL%WoUU8K31#BZ`!z#0|W1V=<8xmkcQ`DNE4{l4aR&k+f23<<ZDA7BqJwG3G;_ zT}JZ4Efl~9A5x$<8%PcK<VNttN1xjGKiCx(u(4=?0!0rxRe^Faa_aXjxl28kbc~{C z;C6TT<2=5Z+4&yxeKUWIM#BW2FCPDMS?ng{?^tl2U?a0zfy`|p5s532CH(i5xUz4_ z#}Oa7KqUW7A_ZjfncwMnA94@e(o#SUO2Ml>Y-PPZ0+b<_5;6~*0^wkWMf(>IZDZ|x zoU?isRaU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vooTmXW%X>Dx7uFY!YepuQ z^TmoN#yc!ps}xmKEUTw+&Fo%s*KfTkYS3IBE@*9jjpG0T?9S|~0=ycv+4()4s>^Gd zp&!A!O69iz5J_^}&M4t}Hjd!?l%(|iX(y28@Qc0i&X{>T`K{gf-CmL_90^2jX<L3? e_w!E!y&FHj`O7aBZZ2%t?~b1Y`k=vH^}hhAMPPCO literal 0 HcmV?d00001 diff --git a/muhamed_directory/other/report.md b/muhamed_directory/other/report.md index 1c96c1d..71c94d4 100644 --- a/muhamed_directory/other/report.md +++ b/muhamed_directory/other/report.md @@ -5,4 +5,19 @@ | Hatice | 2 | test_add_numbers_greater_than_1000_and_minus (Interface Break: Erwartete Fehlermeldung für negative Zahl in Kombination mit Zahl > 1000 war anders: "invalid literal for int() with base 10: '-3,4'" vs. erwartet 'negatives not allowed: -3'), test_multiple_negative_numbers_exception (Geringfügige Abweichung in der Fehlermeldung: 'Negatives not allowed: -1, -2' vs. erwartet 'negatives not allowed: -1,-2'), test_negative_number_exception (Geringfügige Abweichung in der Fehlermeldung: 'Negatives not allowed: -1' vs. erwartet 'negatives not allowed: -1'), test_add_numbers_with_custom_delimiter (Interface Break: ValueError: invalid literal for int() mit Eingabe '//;\n1,2,3'), test_custom_del (Interface Break: ValueError: invalid literal for int() mit Eingabe '//[+++]\n1+++2+++3'), test_custom_del2 (Interface Break: ValueError: invalid literal for int() mit Eingabe '//[aa]\n1aa2aa3'), test_custom_delimiter (Interface Break: ValueError: invalid literal for int() mit Eingabe '//[***]\n1***2***3') | | Marvin | yes | test_add_numbers_greater_1000_and_minus (Interface Break: Fehlermeldung für negative Zahl war anders: 'Negative numbers are not allowed: -3' vs. erwartet 'negatives not allowed: -3'), test_add_numbers_with_custom_delimiter (Interface Break: Fehlermeldung für negative Zahl war anders: 'Negative numbers are not allowed: -3' vs. erwartet 'negatives not allowed: -3'), test_multiple_negative_numbers_exception (Interface Break: Fehlermeldung für negative Zahl war anders: 'Negative numbers are not allowed: -1, -2' vs. erwartet 'negatives not allowed: -1,-2'), test_negative_number_exception (Interface Break: Fehlermeldung für negative Zahl war anders: 'Negative numbers are not allowed: -1' vs. erwartet 'negatives not allowed: -1') | | Wasili | no | none -| Lasse | yes | test_add_numbers_greater_1000_and_minus (Interface Break: Fehlermeldung für negative Zahl war anders: 'Negative nicht erlaubt: [-3]' vs. erwartet 'negatives not allowed: -3'), test_add_numbers_with_custom_delimiter (Interface Break: Fehlermeldung für negative Zahl war anders: 'Negative nicht erlaubt: [-3]' vs. erwartet 'negatives not allowed: -3'), test_multiple_negative_numbers_exception (Interface Break: Fehlermeldung für negative Zahl war anders: 'Negative nicht erlaubt: [-1, -2]' vs. erwartet 'negatives not allowed: -1,-2'), test_negative_number_exception (Interface Break: Fehlermeldung für negative Zahl war anders: 'Negative nicht erlaubt: [-1]' vs. erwartet 'negatives not allowed: -1') | \ No newline at end of file +| Lasse | yes | test_add_numbers_greater_1000_and_minus (Interface Break: Fehlermeldung für negative Zahl war anders: 'Negative nicht erlaubt: [-3]' vs. erwartet 'negatives not allowed: -3'), test_add_numbers_with_custom_delimiter (Interface Break: Fehlermeldung für negative Zahl war anders: 'Negative nicht erlaubt: [-3]' vs. erwartet 'negatives not allowed: -3'), test_multiple_negative_numbers_exception (Interface Break: Fehlermeldung für negative Zahl war anders: 'Negative nicht erlaubt: [-1, -2]' vs. erwartet 'negatives not allowed: -1,-2'), test_negative_number_exception (Interface Break: Fehlermeldung für negative Zahl war anders: 'Negative nicht erlaubt: [-1]' vs. erwartet 'negatives not allowed: -1') | + +### alma tests muhamed calculator + +* **Anzahl der ausgeführten Tests:** 15 +* **Fehler (Errors):** 2 + * **test_long_delimiter:** Dieser Test schlägt fehl, weil deine Implementierung Schwierigkeiten hat, Zahlen zu addieren, die durch ein benutzerdefiniertes Trennzeichen getrennt sind, das länger als ein einzelnes Zeichen ist (z.B. "***"). Es kommt zu einem `ValueError`, da der Teil des Strings, der das Trennzeichen enthält, nicht korrekt in eine Zahl umgewandelt werden kann. + * **test_long_delimiter_with_multiple_numbers:** Dieser Test schlägt ebenfalls fehl aus dem gleichen Grund wie oben, nur dass hier mehrere Zahlen durch ein längeres benutzerdefiniertes Trennzeichen (z.B. "---") getrennt sind. + +### lasse tests muhamed calculator + +* **Anzahl der ausgeführten Tests:** 11 +* **Fehler (Errors):** 0 +* **Fehlgeschlagene Tests (Failures):** 2 + * **test_add_multiple_negative_numbers:** Dieser Test ist fehlgeschlagen, weil deine `add`-Methode bei der Eingabe von "-10\n-20,-30" zwar eine `ValueError`-Ausnahme auslöst (was korrekt ist), die erwartete Fehlermeldung lautete jedoch "Negative nicht erlaubt: [-10, -20, -30]", während deine Implementierung die Meldung "negatives not allowed: -10,-20,-30" zurückgegeben hat. + * **test_add_single_negative_number:** Dieser Test ist ebenfalls fehlgeschlagen, weil deine `add`-Methode bei der Eingabe von "1,-2,3" zwar eine `ValueError`-Ausnahme auslöst, die erwartete Fehlermeldung lautete jedoch "Negative nicht erlaubt: [-2]", während deine Implementierung die Meldung "negatives not allowed: -2" zurückgegeben hat. \ No newline at end of file -- GitLab