From 6e0233c784d56d4cdfe10d3120ee0159d572a3c0 Mon Sep 17 00:00:00 2001 From: David Moeller Date: Fri, 26 Jan 2024 17:39:25 +0100 Subject: [PATCH] Test bombs near but not around tile --- test/Minesweeper/test_bomb_in_array.c | 4 ++-- test/Minesweeper/test_number_of_bombs.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/test/Minesweeper/test_bomb_in_array.c b/test/Minesweeper/test_bomb_in_array.c index 2e97c56..8aae16d 100644 --- a/test/Minesweeper/test_bomb_in_array.c +++ b/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 \ No newline at end of file diff --git a/test/Minesweeper/test_number_of_bombs.c b/test/Minesweeper/test_number_of_bombs.c index 3f899f7..e449f33 100644 --- a/test/Minesweeper/test_number_of_bombs.c +++ b/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 \ No newline at end of file