From d255b92e89701a772dd0d16945bb802763dbefde Mon Sep 17 00:00:00 2001
From: Marvin Serchimo <marvin.serchimo@student.reutlingen-university.de>
Date: Sun, 6 Apr 2025 21:14:13 +0200
Subject: [PATCH] failed

---
 feature7                                      |   7 +-
 other/AliciMuhamed/Stringcalculator           | 136 ++++++++++++++++++
 .../__pycache__/__init__.cpython-313.pyc      | Bin 0 -> 171 bytes
 other/__pycache__/__init__.cpython-313.pyc    | Bin 0 -> 158 bytes
 4 files changed, 141 insertions(+), 2 deletions(-)
 create mode 100644 other/AliciMuhamed/Stringcalculator
 create mode 100644 other/AliciMuhamed/__pycache__/__init__.cpython-313.pyc
 create mode 100644 other/__pycache__/__init__.cpython-313.pyc

diff --git a/feature7 b/feature7
index be466e1..604c685 100644
--- a/feature7
+++ b/feature7
@@ -1,6 +1,9 @@
 import re 
 import unittest
-from other.RafehDaniel.stringCalculator import StringCalculator as Dani
+from other.AliciMuhamed.Stringcalculator import StringCalculator as Momo
+
+
+
 #class StringCalculator:
  #   def add(self, numbers: str) -> int:
         # Feature 1: Leerer String ergibt 0
@@ -53,7 +56,7 @@ class TestStringCalculator(unittest.TestCase):
 
     def setUp(self):
         """neue Instanz des StringCalculators vor jedem Test"""
-        self.calculator = Dani()
+        self.calculator = Momo()
 
     def test_empty_string_returns_zero(self):
         """Feature 1: Leerer String soll 0 ergeben"""
diff --git a/other/AliciMuhamed/Stringcalculator b/other/AliciMuhamed/Stringcalculator
new file mode 100644
index 0000000..fc44a5a
--- /dev/null
+++ b/other/AliciMuhamed/Stringcalculator
@@ -0,0 +1,136 @@
+#vorher im anderen projekt jetzt im neuen projekt
+#test no string
+#test add 1 string
+#test adding 2 strings
+
+#add 3 strings
+#add 4 strings
+#add 6 strings
+
+#\n statt , bei 2 strings
+#\n statt , bei mehreren strings
+
+# eine negative zahl
+# mehrere negative zahlen
+
+# Delimiters:
+# add numbers seperated by a custom delimiter
+# Test with - Numbers
+
+#numbers over 1000 should be ignored
+#1001 + 2 should return 2
+#1001 -2 should return negatives not allowed
+
+#custom delimiters
+#input "//[***]\n1***2***3"
+#output 6
+
+import unittest
+import re
+
+class StringCalculator:
+    def __init__(self):
+        self.called_count = 0
+    def add (self, numbers : str)-> int: #Erwartet Integer
+        if not numbers:
+            return 0
+        
+        if numbers.startswith("//"):
+            delimiter_end_index = numbers.index("\n")
+            delimiter_section = numbers[2:delimiter_end_index]
+            numbers = numbers[delimiter_end_index +1:]
+            
+            if delimiter_section.startswith("[")and delimiter_section.endswith("]"):
+                delimiters = re.findall(r'\[([^\]]+)\]',delimiter_section)
+            else:
+                delimiters= [delimiter_section]
+
+            for delimiters in delimiters:
+                numbers = numbers.replace(delimiters,",")
+
+        numbers = numbers.replace("\n",",")
+            
+        number_list = numbers.split(',')#aufteilung der strings
+        negative = [] #array für die negativen nummern
+        numbers_to_add = []
+            #total_sum = 0
+        for number_str in number_list: #jedes element in der liste wird durch genommen
+                #if number_str:
+            number = int(number_str)# summierung der integer
+            if number <0:
+                negative.append(number)
+            elif number > 1000:
+                continue
+            else:
+                numbers_to_add.append(number)
+                    #total_sum += number
+
+        if negative:
+            print(f"Negative Zahlen:{negative} ")#ausgabe negative zahlen
+            raise ValueError(f"negatives not allowed: {','.join(map(str, negative))}")
+        self.called_count += 1
+        return sum(numbers_to_add)
+    def get_called_count(self):
+        return self.called_count
+        
+    
+class TestStingCalculator(unittest.TestCase):
+    def setUp(self):
+        self.calculator = StringCalculator()     
+    def test_empty_string(self):
+        self.assertEqual(self.calculator.add(""), 0) #leerer string + 0
+    def test_single_number(self):
+        self.assertEqual(self.calculator.add("5"),5) #eingabe von einem String
+    def test_multiple_numbers(self):
+        self.assertEqual(self.calculator.add("5,5"),10)#eingabe mehrere strings
+    def test_unknowen_amount_of_numbers(self):
+        self.assertEqual(self.calculator.add("1,2,3"),6)
+        self.assertEqual(self.calculator.add("10,20,30,40"),100)
+        self.assertEqual(self.calculator.add("1,2,3,4,5,6"),21)
+    def test_numbers_seperated_by_newline(self):
+        self.assertEqual(self.calculator.add("1\n2"),3)
+        self.assertEqual(self.calculator.add("1\n2\n3"),6)
+        self.assertEqual(self.calculator.add("10,20\n30"),60)
+
+    def test_negative_number_exception(self):
+
+        with self.assertRaises(ValueError) as e:
+            self.calculator.add("-1,2")
+        self.assertEqual(str(e.exception), "negatives not allowed: -1")
+    def test_multiple_negative_numbers_exception(self):
+        with self.assertRaises(ValueError)as e:
+            self.calculator.add("-1,-2,3")
+        self.assertEqual(str(e.exception),"negatives not allowed: -1,-2")
+        with self.assertRaises(ValueError) as e:
+            self.calculator.add("-1,-3,4")
+        self.assertEqual(str(e.exception),"negatives not allowed: -1,-3")
+
+        with self.assertRaises(ValueError) as e:
+            self.calculator.add("-1\n-3,4")
+        self.assertEqual(str(e.exception),"negatives not allowed: -1,-3")
+    def test_add_numbers_with_custom_delimiter(self):
+        self.assertEqual(self.calculator.add("//;\n1;2;3"),6)
+        self.assertEqual(self.calculator.add("//;\n1,2,3"),6)
+        with self.assertRaises(ValueError) as e:
+            self.calculator.add("//;\n-3,4")
+        self.assertEqual(str(e.exception),"negatives not allowed: -3")
+    
+    def test_add_numbers_greater_than_1000(self):
+        self.assertEqual(self.calculator.add("1,1001,2,3"),6)
+    def test_add_numbers_greater_than_1000_1002(self):
+        self.assertEqual(self.calculator.add("1002,1,2,3"),6)
+    def test_add_numbers_greater_1000_and_minus(self):
+        with self.assertRaises(ValueError) as e:
+            self.calculator.add("//;\n-3,4;1001")
+        self.assertEqual(str(e.exception),"negatives not allowed: -3")
+    def test_custom_delimiter(self):
+        self.assertEqual(self.calculator.add("//[***]\n1***2***3"),6)
+    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)
+        
+        
+
+if __name__=='__main__':
+    unittest.main()
\ No newline at end of file
diff --git a/other/AliciMuhamed/__pycache__/__init__.cpython-313.pyc b/other/AliciMuhamed/__pycache__/__init__.cpython-313.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..f59d9aef39912fbf3c48c517faee693e27ca18af
GIT binary patch
literal 171
zcmey&%ge<81a~idN(a%8K?DpiLK&Y~fQ+dO=?t2Tek&P@n1H;`AgNnk`k}?CMaBBL
ziA80ZdHOE-$)&lec_qdA?wKVXrAhjU#l@NFc_1NOBmMl6jMO51$DGXMOyAOs#N5;r
s{rLFIyv&mLc)fzkTO2mI`6;D2sdh!IK%+rc7lRldnHd=wi<p5d03_fnj{pDw

literal 0
HcmV?d00001

diff --git a/other/__pycache__/__init__.cpython-313.pyc b/other/__pycache__/__init__.cpython-313.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..2f81337b3f670f5b88bbb598ac7352a7f961b3d1
GIT binary patch
literal 158
zcmey&%ge<81a~idN(a%8K?DpiLK&Y~fQ+dO=?t2Tek&P@n1H;`AgNon`k}?CMaBBL
ziA80ZdHOE-$)&lec_qdA?wKVXrAhjU#l@NFc_1NOBmMl6jMO6i`1s7c%#!$cy@JYH
f95%W6DWy57c15f}(?GTrgBTx~85tRin1L(+sMsg4

literal 0
HcmV?d00001

-- 
GitLab