Skip to content
Snippets Groups Projects
Commit 461d7244 authored by Hatice Yildirim's avatar Hatice Yildirim
Browse files

Mein Commit

parent 2732c77c
No related branches found
No related tags found
1 merge request!1RomanConverter
This commit is part of merge request !1. Comments created here will be created in the context of that merge request.
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
#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()
#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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment