diff --git a/app/src/test/java/htw/berlin/prog2/ha1/CalculatorTest.java b/app/src/test/java/htw/berlin/prog2/ha1/CalculatorTest.java index addc5f26..31dd1ae6 100644 --- a/app/src/test/java/htw/berlin/prog2/ha1/CalculatorTest.java +++ b/app/src/test/java/htw/berlin/prog2/ha1/CalculatorTest.java @@ -3,6 +3,8 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import javax.management.loading.MLet; + import static org.junit.jupiter.api.Assertions.assertEquals; @DisplayName("Retro calculator") @@ -40,6 +42,75 @@ void testSquareRoot() { assertEquals(expected, actual); } - //TODO hier weitere Tests erstellen + //1. grüner test + @Test + @DisplayName("should display result after split two positive multi-digit numbers") + void testAddition() { + Calculator calc = new Calculator(); + + calc.pressDigitKey(1); + calc.pressDigitKey(6); + calc.pressBinaryOperationKey("/"); + calc.pressDigitKey(4); + + calc.pressEqualsKey(); + + String expected = "4"; + String actual = calc.readScreen(); + + assertEquals(expected, actual); + } + + // 1.roter Test + + @Test + @DisplayName("should display result after subtract two postive multi-digit-numbers") + void testsubtraction() { + Calculator calc = new Calculator(); + + calc.pressDigitKey(5); + calc.pressDigitKey(4); + calc.pressBinaryOperationKey("+"); + calc.pressDigitKey(1); + calc.pressDigitKey(8); + + calc.pressEqualsKey(); + + String expected = "36"; + String actual = calc.readScreen(); + + assertEquals(expected, actual); + + @@public void pressBinaryOperationKey() { + + if(screen.endWith("+") screen= "-") +//2.roter test + @Test + @DisplayName("should display ´0´ result after multiply by zero") + void testmultiplication() ( + Calculator calc= new Calculator() + calc.pressDigitKey(2); + calc.pressDigitKey(1); + calc.pressBinaryOperationKey("*"); + calc.pressDigitKey(0); + calc.pressDigitKey(); + + calc.pressEqualsKey(); + + String expected = "22"; + String actual = calc.readScreen(); + + assertEquals(expected, actual); + + + ) + + + + + } + @@public void press String expected () { + + if(screen.endWith("22") screen= "0") }