diff --git a/ScoreBoard.txt b/ScoreBoard.txt index e69de29..8318c86 100644 --- a/ScoreBoard.txt +++ b/ScoreBoard.txt @@ -0,0 +1 @@ +Test \ No newline at end of file diff --git a/build/test/cache/test_Modules.c b/build/test/cache/test_Modules.c index b56ed68..d0116f8 100644 --- a/build/test/cache/test_Modules.c +++ b/build/test/cache/test_Modules.c @@ -226,7 +226,7 @@ void test_getStartPosition_check_given_position(void) -void test_generateField_check_walls_length(void){ +void test_generateField_check_walls_length_correctly_inserted(void){ @@ -277,3 +277,143 @@ void test_generateField_check_walls_length(void){ ), (UNITY_UINT)(129), UNITY_DISPLAY_STYLE_INT); } + + + +void test_sortScoreboard_check_if_file_is_being_read(void) { + + + + + + char Text[4]; + + FILE *x; + + int y; + + + + + + if (access("ScoreBoard.txt", 0) == 0) { + + remove("ScoreBoard.txt"); + + } + + + + sortScoreboard(); + + + + x = fopen("ScoreBoard.txt", "a+"); + + + + fputs("Test", x); + + rewind(x); + + for(int i = 0; i < 4; i++) { + + fscanf(x, "%s", &Text[i]); + + } + + + + if(strcmp(Text, "Test") == 0) { + + y = 0; + + } + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((y)), ( + + ((void *)0) + + ), (UNITY_UINT)(158), UNITY_DISPLAY_STYLE_INT); + +} + +void test_generateField_check_last_position_change_on_score(void) + +{ + + + + + + scorePoints = 321; + + int output = 1; + + + + + + generateField(); + + + + if (field[12][1] != '0') + + { + + output = 0; + + } + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((output)), ( + + ((void *)0) + + ), (UNITY_UINT)(175), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_generateField_check_middle_position_change_on_score(void) + +{ + + + + + + scorePoints = 321; + + int output = 1; + + + + + + generateField(); + + + + if (field[11][1] != '0') + + { + + output = 0; + + } + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((output)), ( + + ((void *)0) + + ), (UNITY_UINT)(193), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/out/c/test_Modules.o b/build/test/out/c/test_Modules.o index f1e96f1..ab43849 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 c03d7a8..3a1321e 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 eda2253..52f42b8 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 b56ed68..d0116f8 100644 --- a/build/test/preprocess/files/test_Modules.c +++ b/build/test/preprocess/files/test_Modules.c @@ -226,7 +226,7 @@ void test_getStartPosition_check_given_position(void) -void test_generateField_check_walls_length(void){ +void test_generateField_check_walls_length_correctly_inserted(void){ @@ -277,3 +277,143 @@ void test_generateField_check_walls_length(void){ ), (UNITY_UINT)(129), UNITY_DISPLAY_STYLE_INT); } + + + +void test_sortScoreboard_check_if_file_is_being_read(void) { + + + + + + char Text[4]; + + FILE *x; + + int y; + + + + + + if (access("ScoreBoard.txt", 0) == 0) { + + remove("ScoreBoard.txt"); + + } + + + + sortScoreboard(); + + + + x = fopen("ScoreBoard.txt", "a+"); + + + + fputs("Test", x); + + rewind(x); + + for(int i = 0; i < 4; i++) { + + fscanf(x, "%s", &Text[i]); + + } + + + + if(strcmp(Text, "Test") == 0) { + + y = 0; + + } + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((y)), ( + + ((void *)0) + + ), (UNITY_UINT)(158), UNITY_DISPLAY_STYLE_INT); + +} + +void test_generateField_check_last_position_change_on_score(void) + +{ + + + + + + scorePoints = 321; + + int output = 1; + + + + + + generateField(); + + + + if (field[12][1] != '0') + + { + + output = 0; + + } + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((output)), ( + + ((void *)0) + + ), (UNITY_UINT)(175), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_generateField_check_middle_position_change_on_score(void) + +{ + + + + + + scorePoints = 321; + + int output = 1; + + + + + + generateField(); + + + + if (field[11][1] != '0') + + { + + output = 0; + + } + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((output)), ( + + ((void *)0) + + ), (UNITY_UINT)(193), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/results/test_Modules.pass b/build/test/results/test_Modules.pass index 8174205..338b929 100644 --- a/build/test/results/test_Modules.pass +++ b/build/test/results/test_Modules.pass @@ -23,19 +23,31 @@ :line: 86 :message: '' :unity_test_time: 0 -- :test: test_generateField_check_walls_length +- :test: test_generateField_check_walls_length_correctly_inserted :line: 107 :message: '' :unity_test_time: 0 +- :test: test_sortScoreboard_check_if_file_is_being_read + :line: 132 + :message: '' + :unity_test_time: 0 +- :test: test_generateField_check_last_position_change_on_score + :line: 160 + :message: '' + :unity_test_time: 0 +- :test: test_generateField_check_middle_position_change_on_score + :line: 178 + :message: '' + :unity_test_time: 0 :failures: [] :ignores: [] :counts: - :total: 6 - :passed: 6 + :total: 9 + :passed: 9 :failed: 0 :ignored: 0 :stdout: -- "\e[H\e[2J\e[3J\e[H\e[2J\e[3J" +- "\e[H\e[2J\e[3J\e[H\e[2J\e[3J\e[H\e[2J\e[3J\e[H\e[2J\e[3J\e[H\e[2J\e[3J" - " Scoreboard:" - '' - "|=======================|" @@ -67,4 +79,64 @@ - "| |" - "| |" - "|=======================|" -:time: 0.002545395000197459 +- " Scoreboard:" +- '' +- "|=======================|" +- "| OOO 321 |" +- "|=======================|" +- "| \\ |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| V |" +- "| / \\ |" +- "| / \\ |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "|=======================|" +- "|=======================|" +- "| OOO 321 |" +- "|=======================|" +- "| \\ |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| V |" +- "| / \\ |" +- "| / \\ |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "| |" +- "|=======================|" +:time: 0.00713155700009338 diff --git a/build/test/runners/test_Modules_runner.c b/build/test/runners/test_Modules_runner.c index a7964c4..05aaf0c 100644 --- a/build/test/runners/test_Modules_runner.c +++ b/build/test/runners/test_Modules_runner.c @@ -15,7 +15,10 @@ 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); +extern void test_generateField_check_walls_length_correctly_inserted(void); +extern void test_sortScoreboard_check_if_file_is_being_read(void); +extern void test_generateField_check_last_position_change_on_score(void); +extern void test_generateField_check_middle_position_change_on_score(void); /*=======Mock Management=====*/ @@ -85,7 +88,10 @@ 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); + run_test(test_generateField_check_walls_length_correctly_inserted, "test_generateField_check_walls_length_correctly_inserted", 107); + run_test(test_sortScoreboard_check_if_file_is_being_read, "test_sortScoreboard_check_if_file_is_being_read", 132); + run_test(test_generateField_check_last_position_change_on_score, "test_generateField_check_last_position_change_on_score", 160); + run_test(test_generateField_check_middle_position_change_on_score, "test_generateField_check_middle_position_change_on_score", 178); return UnityEnd(); } diff --git a/test/test_Modules.c b/test/test_Modules.c index 4c3409e..ee8a527 100644 --- a/test/test_Modules.c +++ b/test/test_Modules.c @@ -145,7 +145,7 @@ void test_sortScoreboard_check_if_file_is_being_read(void) { x = fopen("ScoreBoard.txt", "a+"); - fputs("Tesf", x); + fputs("Test", x); rewind(x); for(int i = 0; i < 4; i++) { fscanf(x, "%s", &Text[i]); @@ -175,4 +175,22 @@ void test_generateField_check_last_position_change_on_score(void) TEST_ASSERT_EQUAL(0, output); } +void test_generateField_check_middle_position_change_on_score(void) +{ + /* arrange */ + + scorePoints = 321; + int output = 1; + + /* act */ + generateField(); + + if (field[11][1] != '0') + { + output = 0; + } + /* assert */ + TEST_ASSERT_EQUAL(0, output); +} + #endif // TEST \ No newline at end of file