Skip to content
Snippets Groups Projects
Commit 3154de03 authored by PIERRON Laurent's avatar PIERRON Laurent :man_in_tuxedo_tone1:
Browse files

Testing KeyErrorSequence

parent 1f8a5bd5
No related branches found
No related tags found
No related merge requests found
......@@ -64,4 +64,31 @@ public class CalcEngineTest {
assertEquals(3, engine.getDisplayValue());
}
@Test
@DisplayName("Testing error in key sequence;")
void testKeySequenceError() {
// Make sure the engine is in a valid starting state.
engine.clear();
// Simulate the key presses: 1 + 2 + 3 =
engine.numberPressed(1);
engine.plus();
engine.numberPressed(2);
engine.plus();
engine.numberPressed(3);
engine.equals();
// Intermediate result : 6
assertEquals(6, engine.getDisplayValue());
engine.plus();
engine.minus();
// Sequencing error, check to verify everything is in initial state
assertEquals(0, engine.getDisplayValue());
// We can do operations again
// Simulate the presses: 9 - 4 =
engine.numberPressed(9);
engine.minus();
engine.numberPressed(4);
engine.equals();
// Return the result, which should be 5.
assertEquals(5, engine.getDisplayValue());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment