Skip to content
Snippets Groups Projects
Commit 506a816f authored by linopino's avatar linopino
Browse files

1

1
parent 7e42a4d0
No related merge requests found
print("Hello WORLD")
\ No newline at end of file
print("Hello WORLD")
print("test")
\ No newline at end of file
#Test1: Addition 2 positiver Zaheln (2+5) erwartetes Ergebnis 8
#Test2: Addition negativer und positiver Zahl (-1+1) erwartetes Ergebnis 0
#Test3: Addition (0+0), erwartetes Ergebnis 0
#Test4: Addition von 2 Dezimalzahlen (2,5+3,5), erwartetes Ergebnis 6
from abc import ABC, abstractmethod
class ICalculator(ABC):
@abstractmethod
def add(self, a: float, b: float) -> float:
pass
class Calculator(ICalculator):
def add(self, a: float, b: float) -> float:
return a + b
class TestCalculator:
def __init__(self, calculator: ICalculator):
self.calculator = calculator
def test_add(self):
assert self.calculator.add(2,3) == 5, "Fehler falls nicht 5"
assert self.calculator.add(-1,1) == 0, "Fegler falls nich 0"
assert self.calculator.add(0,0) == 0, "Fehler falls nicht 0"
assert self.calculator.add(2.5,3.5) == 6, "Fehler falls nicht 5"
print("Test erfolgreich")
if __name__ == "__main__":
calc = Calculator()
tester = TestCalculator(calc)
tester.test_add()
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