Skip to content
Open

HA1 #85

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 72 additions & 1 deletion app/src/test/java/htw/berlin/prog2/ha1/CalculatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
}