diff --git a/calculator.py b/calculator.py new file mode 100644 index 0000000000000000000000000000000000000000..79532fcf5edde813fe1f73aa5077023520b017f2 --- /dev/null +++ b/calculator.py @@ -0,0 +1,13 @@ +import unittest + +class Calculator: + def add(self, a, b): + return a + b + +class TestCalculator(unittest.TestCase): + def test_add(self): + c = Calculator() + self.assertEqual(c.add(2,3), 5) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/counter.py b/counter.py new file mode 100644 index 0000000000000000000000000000000000000000..f6ee3bb865d651fd9c93a7faa2daf9851732b86e --- /dev/null +++ b/counter.py @@ -0,0 +1,35 @@ +#Bei Einhabe des Strings "Decker" liefert die Funktion 3 +#Bei Eingabe eines leeren Strings soll 0 ausgegeben werden +#Bei Eingabe des Strings "Hallo" ohne E und D soll 0 ausgegeben werden + +from abc import ABC,abstractmethod +import unittest + +class ICounter (ABC): + @abstractmethod + def count_ED(self,s): + pass + +class Counter (ICounter): + #def count_ED(self,s): + #return s.count("e")+s.count("D") + pass + +class TestCounter (unittest.TestCase): + def test_count_ED_regular (self): + c=Counter() + res=c.count_ED ("Decker") + self.assertEqual(res,3) + def test_count_ED_empty (self): + c=Counter() + res=c.count_ED ("") + self.assertEqual(res,0) + def test_count_ED_wo (self): + '''Testet einen String ohne E und D''' + c=Counter() + res=c.count_ED ("Hallo") + self.assertEqual(res,0) + + +if __name__=="__main__": + unittest.main() diff --git a/test.py b/test.py new file mode 100644 index 0000000000000000000000000000000000000000..d40dcf92e86fa7d9cc3fa3f3309aa5d30b9a311e --- /dev/null +++ b/test.py @@ -0,0 +1,5 @@ +#Meine Übung, um es zu verstehen! +class Employee: + def __init__(self, name, age): + self.name = name + self.age = age \ No newline at end of file