Browse Source

Test 5 or 8 bombs around tile

remotes/origin/David
David Moeller 11 months ago
parent
commit
616ffae6b4
  1. 39
      test/Minesweeper/test_number_of_bombs.c

39
test/Minesweeper/test_number_of_bombs.c

@ -55,4 +55,43 @@ void test_2_bombs_around_tile(void){
TEST_ASSERT_EQUAL_INT(2, result);//2 bombs placed around tile
}
void test_5_bombs_around_tile(void){
/* arrange */
int result;
Minesweeper_Board board = initialize_minesweeper();
int tile = 1 + board.width * 0;
board.bombs[0] = 0 + board.width * 0;
board.bombs[1] = 2 + board.width * 0;
board.bombs[2] = 0 + board.width * 1;
board.bombs[3] = 1 + board.width * 1;
board.bombs[4] = 2 + board.width * 1;
/* act */
result = number_of_bombs(&board, tile);
/* assert */
TEST_ASSERT_EQUAL_INT(5, result);//5 bombs placed around tile
}
void test_8_bombs_around_tile(void){
/* arrange */
int result;
Minesweeper_Board board = initialize_minesweeper();
int tile = 7 + board.width * 7;
board.bombs[0] = 6 + board.width * 6;
board.bombs[1] = 7 + board.width * 6;
board.bombs[2] = 8 + board.width * 6;
board.bombs[3] = 6 + board.width * 7;
board.bombs[4] = 8 + board.width * 7;
board.bombs[5] = 6 + board.width * 8;
board.bombs[6] = 7 + board.width * 8;
board.bombs[7] = 8 + board.width * 8;
/* act */
result = number_of_bombs(&board, tile);
/* assert */
TEST_ASSERT_EQUAL_INT(8, result);//2 bombs placed around tile
}
#endif // TEST
Loading…
Cancel
Save