From 063eb9ebe040e53d5f170ffd62089f2e847ec2a6 Mon Sep 17 00:00:00 2001 From: David Moeller Date: Fri, 26 Jan 2024 14:39:53 +0100 Subject: [PATCH] Test test if tile has a bomb --- src/main/c/Minesweeper/minesweeper_start.h | 1 + test/Minesweeper/test_bomb_in_array.c | 25 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 test/Minesweeper/test_bomb_in_array.c diff --git a/src/main/c/Minesweeper/minesweeper_start.h b/src/main/c/Minesweeper/minesweeper_start.h index bf0f21a..a73d944 100644 --- a/src/main/c/Minesweeper/minesweeper_start.h +++ b/src/main/c/Minesweeper/minesweeper_start.h @@ -11,6 +11,7 @@ typedef struct Minesweeper_Board{ void minesweeper_start(); +bool bomb_in_array(int array[], int bomb, int length); #endif // MINESWEEPER_START_H \ No newline at end of file diff --git a/test/Minesweeper/test_bomb_in_array.c b/test/Minesweeper/test_bomb_in_array.c new file mode 100644 index 0000000..710791b --- /dev/null +++ b/test/Minesweeper/test_bomb_in_array.c @@ -0,0 +1,25 @@ +#ifdef TEST +#include "unity.h" +#include +#include "../../src/main/c/Minesweeper/minesweeper_start.h" + + +void setUp(void){} +void tearDown(void){} + + +void test_bomb_in_array(void){ + /* arrange */ + bool result; + int array[] = {5, 9, 42, 6, 87, 95, 202, 13, 45 ,78}; + int bomb = 42; + int length = 10; + + /* act */ + result = bomb_in_array(array, bomb, length); + + /* assert */ + TEST_ASSERT_TRUE(result);//head collides with body +} + +#endif // TEST \ No newline at end of file