state-of-tic-tac-toe: add missing test cases for invalid board states - #3153
state-of-tic-tac-toe: add missing test cases for invalid board states#3153MathJAY10 wants to merge 2 commits into
Conversation
|
This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested. If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos. For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping |
jagdish-15
left a comment
There was a problem hiding this comment.
Please update the test cases to match the latest canonical-data.json rather than using assumed values, and remove the comments that were added since they aren't needed in the final solution. Also, don't forget to update test.toml using configlet (see #2959 for more information).
| public void testInvalidBoardOKeptPlayingAfterXWins() { | ||
|
|
||
| assertThatExceptionOfType(IllegalArgumentException.class) | ||
| .isThrownBy(() -> stateOfTicTacToe.determineState(new String[]{"XXX", "OO ", "O "})) |
There was a problem hiding this comment.
Please update the test values to match those in the canonical-data.json
| public void testInvalidBoardXKeptPlayingAfterOWins() { | ||
|
|
||
| assertThatExceptionOfType(IllegalArgumentException.class) | ||
| .isThrownBy(() -> stateOfTicTacToe.determineState(new String[]{"OOO", "XX ", "XX "})) |
There was a problem hiding this comment.
| // --- NAYE CHECKS START --- | ||
| // Agar X jeeta hai, toh xCount zaroor (oCount + 1) hona chahiye. Agar barabar hai, matlab O ne extra move chala! |
There was a problem hiding this comment.
| // --- NAYE CHECKS START --- | |
| // Agar X jeeta hai, toh xCount zaroor (oCount + 1) hona chahiye. Agar barabar hai, matlab O ne extra move chala! |
| ); | ||
| } | ||
|
|
||
| // Agar O jeeta hai, toh xCount zaroor oCount ke barabar hona chahiye. Agar xCount zyaada hai, matlab X ne extra move chala! |
There was a problem hiding this comment.
| // Agar O jeeta hai, toh xCount zaroor oCount ke barabar hona chahiye. Agar xCount zyaada hai, matlab X ne extra move chala! |
| "Impossible board: game should have ended after the game was won" | ||
| ); | ||
| } | ||
| // --- NAYE CHECKS END --- |
There was a problem hiding this comment.
| // --- NAYE CHECKS END --- |
|
Hi @jagdish-15 , I have updated StateOfTicTacToeTest.java to align with canonical-data.json and cleaned up the comments in StateOfTicTacToe.java. All tests are passing locally. Could you please take another look? |
Summary of Changes(For Issue #3150 )
This PR implements missing canonical test cases for
state-of-tic-tac-toefromproblem-specifications:StateOfTicTacToeTest.java:5a84757a-fc86-4328-aec9-a5759e6ed35d: Invalid board - O kept playing after X winscf25543d-583a-4656-b9ab-f82dc00a4a02: Invalid board - X kept playing after O wins.meta/src/reference/java/StateOfTicTacToe.javato validate move counts after a victory condition is met.Testing
Ran
./gradlew testlocally — all 29 tests completed successfully with 0 failures.Closes #3150