diff --git a/build/test/cache/test_Modules.c b/build/test/cache/test_Modules.c index a83dc8a..b56ed68 100644 --- a/build/test/cache/test_Modules.c +++ b/build/test/cache/test_Modules.c @@ -223,3 +223,57 @@ void test_getStartPosition_check_given_position(void) ), (UNITY_UINT)(104), UNITY_DISPLAY_STYLE_INT); } + + + +void test_generateField_check_walls_length(void){ + + + + int output = 0; + + int wallX = 5; + + int wallY = 5; + + int wallLength = 3; + + int counter = wallLength; + + + + int binX = 10; + + + + generateField(); + + for (int i = 0; i < 23; i++) + + { + + for(int j = 0; j < 29; j++){ + + if(field[i][j] == '_') + + counter++; + + } + + } + + if(counter != wallLength) + + output = 1; + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((output)), ( + + ((void *)0) + + ), (UNITY_UINT)(129), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/out/c/test_Modules.o b/build/test/out/c/test_Modules.o index 1fdf844..f1e96f1 100644 Binary files a/build/test/out/c/test_Modules.o and b/build/test/out/c/test_Modules.o differ diff --git a/build/test/out/c/test_Modules_runner.o b/build/test/out/c/test_Modules_runner.o index d94fcc3..c03d7a8 100644 Binary files a/build/test/out/c/test_Modules_runner.o and b/build/test/out/c/test_Modules_runner.o differ diff --git a/build/test/out/test_Modules.out b/build/test/out/test_Modules.out index 1bd6dbb..eda2253 100755 Binary files a/build/test/out/test_Modules.out and b/build/test/out/test_Modules.out differ diff --git a/build/test/preprocess/files/test_Modules.c b/build/test/preprocess/files/test_Modules.c index a83dc8a..b56ed68 100644 --- a/build/test/preprocess/files/test_Modules.c +++ b/build/test/preprocess/files/test_Modules.c @@ -223,3 +223,57 @@ void test_getStartPosition_check_given_position(void) ), (UNITY_UINT)(104), UNITY_DISPLAY_STYLE_INT); } + + + +void test_generateField_check_walls_length(void){ + + + + int output = 0; + + int wallX = 5; + + int wallY = 5; + + int wallLength = 3; + + int counter = wallLength; + + + + int binX = 10; + + + + generateField(); + + for (int i = 0; i < 23; i++) + + { + + for(int j = 0; j < 29; j++){ + + if(field[i][j] == '_') + + counter++; + + } + + } + + if(counter != wallLength) + + output = 1; + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((output)), ( + + ((void *)0) + + ), (UNITY_UINT)(129), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/results/test_Modules.pass b/build/test/results/test_Modules.pass index 60e5e0b..8174205 100644 --- a/build/test/results/test_Modules.pass +++ b/build/test/results/test_Modules.pass @@ -23,15 +23,48 @@ :line: 86 :message: '' :unity_test_time: 0 +- :test: test_generateField_check_walls_length + :line: 107 + :message: '' + :unity_test_time: 0 :failures: [] :ignores: [] :counts: - :total: 5 - :passed: 5 + :total: 6 + :passed: 6 :failed: 0 :ignored: 0 :stdout: -- "\e[H\e[2J\e[3J" +- "\e[H\e[2J\e[3J\e[H\e[2J\e[3J" - " Scoreboard:" - '' -:time: 0.0020466310015763156 +- "|=======================|" +- "| OOO 000 |" +- "|=======================|" +- "| \\ |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| V |" +- "| / \\ |" +- "| / \\ |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "|=======================|" +:time: 0.002545395000197459 diff --git a/build/test/runners/test_Modules_runner.c b/build/test/runners/test_Modules_runner.c index 4b6d31e..a7964c4 100644 --- a/build/test/runners/test_Modules_runner.c +++ b/build/test/runners/test_Modules_runner.c @@ -15,6 +15,7 @@ extern void test_checkBallPosition_output_if_no_goal(void); extern void test_sortScoreboard_check_if_file_is_created(void); extern void test_clearField_check_if_Playgroung_clear(void); extern void test_getStartPosition_check_given_position(void); +extern void test_generateField_check_walls_length(void); /*=======Mock Management=====*/ @@ -84,6 +85,7 @@ int main(void) run_test(test_sortScoreboard_check_if_file_is_created, "test_sortScoreboard_check_if_file_is_created", 47); run_test(test_clearField_check_if_Playgroung_clear, "test_clearField_check_if_Playgroung_clear", 64); run_test(test_getStartPosition_check_given_position, "test_getStartPosition_check_given_position", 86); + run_test(test_generateField_check_walls_length, "test_generateField_check_walls_length", 107); return UnityEnd(); } diff --git a/test/test_Modules.c b/test/test_Modules.c index 37c2c07..3fb41e2 100644 --- a/test/test_Modules.c +++ b/test/test_Modules.c @@ -104,4 +104,29 @@ void test_getStartPosition_check_given_position(void) TEST_ASSERT_EQUAL(0, output); } +void test_generateField_check_walls_length_correctly_inserted(void){ + /* arrange */ + int output = 0; + int wallX = 5; + int wallY = 5; + int wallLength = 3; + int counter = wallLength; + + int binX = 10; + /* act */ + generateField(); + for (int i = 0; i < fieldWidth; i++) + { + for(int j = 0; j < fieldHeigth; j++){ + if(field[i][j] == '_') + counter++; + } + } + if(counter != wallLength) + output = 1; + + /* assert */ + TEST_ASSERT_EQUAL(0, output); +} + #endif // TEST \ No newline at end of file