Browse Source

Neunter Unit Test

main
David PC Saiz 2 years ago
parent
commit
79ea2ae1e8
  1. 1
      ScoreBoard.txt
  2. 142
      build/test/cache/test_Modules.c
  3. BIN
      build/test/out/c/test_Modules.o
  4. BIN
      build/test/out/c/test_Modules_runner.o
  5. BIN
      build/test/out/test_Modules.out
  6. 142
      build/test/preprocess/files/test_Modules.c
  7. 82
      build/test/results/test_Modules.pass
  8. 10
      build/test/runners/test_Modules_runner.c
  9. 20
      test/test_Modules.c

1
ScoreBoard.txt

@ -0,0 +1 @@
Test

142
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);
}

BIN
build/test/out/c/test_Modules.o

BIN
build/test/out/c/test_Modules_runner.o

BIN
build/test/out/test_Modules.out

142
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);
}

82
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

10
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();
}

20
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
Loading…
Cancel
Save