Browse Source

Test bombs near but not around tile

remotes/origin/David
David Moeller 11 months ago
parent
commit
6e0233c784
  1. 4
      test/Minesweeper/test_bomb_in_array.c
  2. 17
      test/Minesweeper/test_number_of_bombs.c

4
test/Minesweeper/test_bomb_in_array.c

@ -19,7 +19,7 @@ void test_bomb_in_array(void){
result = bomb_in_array(array, bomb, length);
/* assert */
TEST_ASSERT_TRUE(result);//head collides with body
TEST_ASSERT_TRUE(result);
}
@ -34,7 +34,7 @@ void test_bomb_not_in_array(void){
result = bomb_in_array(array, bomb, length);
/* assert */
TEST_ASSERT_FALSE(result);//head collides with body
TEST_ASSERT_FALSE(result);
}
#endif // TEST

17
test/Minesweeper/test_number_of_bombs.c

@ -21,4 +21,21 @@ void test_no_bombs_placed_around_tile(void){
TEST_ASSERT_EQUAL_INT(0, result);//no bombs placed
}
void test_searching_for_bombs_on_correct_tiles(void){
/* arrange */
int result;
Minesweeper_Board board = initialize_minesweeper();
int tile = 0 + board.width * 1;
board.bombs[0] = 0 + board.width * 2;
board.bombs[0] = 2 + board.width * 1;
board.bombs[0] = board.width - 1 + board.width * 1;
board.bombs[0] = 0 + board.width * (board.height - 1);
/* act */
result = number_of_bombs(&board, tile);
/* assert */
TEST_ASSERT_EQUAL_INT(0, result);//no bombs placed around tile
}
#endif // TEST
Loading…
Cancel
Save