Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Hausaufgabe 1
# Hausaufgabe 1

Deadline für Abgabe per Pull Request: 28.04.2024 23:59 Uhr. Außerdem ist zusätzlich eine persönliche Abnahme in der von Ihnen belegten Übungsgruppe notwendig, um zu bestehen. Bei unentschuldigtem Fehlen in der auf die Deadline folgenden Übung, wird die Hausaufgabe als nicht bestanden bewertet.

Expand Down
41 changes: 41 additions & 0 deletions app/src/test/java/htw/berlin/prog2/ha1/CalculatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,46 @@ void testMultipleDecimalDots() {


//TODO hier weitere Tests erstellen
@Test
@DisplayName("should toggle negative sign correctly")
void testToggleNegative() {
Calculator calc = new Calculator();

calc.pressDigitKey(5);
calc.pressNegativeKey(); // -5
assertEquals("-5", calc.readScreen());

calc.pressNegativeKey(); // zurück zu 5
assertEquals("5", calc.readScreen());
}
@Test
@DisplayName("should clear only screen on first clear press, not memory")
void testClearKeyClearsOnlyScreen() {
Calculator calc = new Calculator();

calc.pressDigitKey(8);
calc.pressBinaryOperationKey("+");
calc.pressDigitKey(3);
calc.pressClearKey(); // sollte nur Bildschirm zurücksetzen
calc.pressDigitKey(2);
calc.pressEqualsKey();

assertEquals("10", calc.readScreen()); // 8 + 2
}
@Test
@DisplayName("should repeat last operation when equals is pressed multiple times")
void testRepeatedEquals() {
Calculator calc = new Calculator();

calc.pressDigitKey(2);
calc.pressBinaryOperationKey("+");
calc.pressDigitKey(3);
calc.pressEqualsKey(); // → 5
calc.pressEqualsKey(); // → 8
calc.pressEqualsKey(); // → 11

assertEquals("11", calc.readScreen());
}

}