Browse Source

Dritter Unit Test

main
fdai7037 2 years ago
parent
commit
0cce59bb11
  1. 0
      ScoreBoard.txt
  2. 40
      build/test/cache/test_Modules.c
  3. BIN
      build/test/out/c/cmock.o
  4. BIN
      build/test/out/c/test_Modules.o
  5. BIN
      build/test/out/c/test_Modules_runner.o
  6. BIN
      build/test/out/c/unity.o
  7. BIN
      build/test/out/test_Modules.out
  8. 40
      build/test/preprocess/files/test_Modules.c
  9. 15
      build/test/results/test_Modules.pass
  10. 2
      build/test/runners/test_Modules_runner.c
  11. 21
      test/test_Modules.c

0
ScoreBoard.txt

40
build/test/cache/test_Modules.c

@ -6,8 +6,6 @@
void setUp(void) void setUp(void)
{ {
@ -93,3 +91,41 @@ void test_checkBallPosition_output_if_no_goal(void)
), (UNITY_UINT)(44), UNITY_DISPLAY_STYLE_INT); ), (UNITY_UINT)(44), UNITY_DISPLAY_STYLE_INT);
} }
void test_sortScoreboard_check_if_file_exists(void) {
if (access("ScoreBoard.txt", 0) == 0) {
remove("ScoreBoard.txt");
}
sortScoreboard();
int output = access("ScoreBoard.txt", 0);
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((output)), (
((void *)0)
), (UNITY_UINT)(61), UNITY_DISPLAY_STYLE_INT);
}

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

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

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

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

BIN
build/test/out/test_Modules.out

40
build/test/preprocess/files/test_Modules.c

@ -6,8 +6,6 @@
void setUp(void) void setUp(void)
{ {
@ -93,3 +91,41 @@ void test_checkBallPosition_output_if_no_goal(void)
), (UNITY_UINT)(44), UNITY_DISPLAY_STYLE_INT); ), (UNITY_UINT)(44), UNITY_DISPLAY_STYLE_INT);
} }
void test_sortScoreboard_check_if_file_exists(void) {
if (access("ScoreBoard.txt", 0) == 0) {
remove("ScoreBoard.txt");
}
sortScoreboard();
int output = access("ScoreBoard.txt", 0);
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((output)), (
((void *)0)
), (UNITY_UINT)(61), UNITY_DISPLAY_STYLE_INT);
}

15
build/test/results/test_Modules.pass

@ -11,12 +11,19 @@
:line: 31 :line: 31
:message: '' :message: ''
:unity_test_time: 0 :unity_test_time: 0
- :test: test_sortScoreboard_check_if_file_exists
:line: 47
:message: ''
:unity_test_time: 0
:failures: [] :failures: []
:ignores: [] :ignores: []
:counts: :counts:
:total: 2
:passed: 2
:total: 3
:passed: 3
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: []
:time: 0.0006384879998222459
:stdout:
- "\e[H\e[2J\e[3J"
- " Scoreboard:"
- ''
:time: 0.0021875080001336755

2
build/test/runners/test_Modules_runner.c

@ -12,6 +12,7 @@ extern void setUp(void);
extern void tearDown(void); extern void tearDown(void);
extern void test_checkBallPosition_output_if_goal(void); extern void test_checkBallPosition_output_if_goal(void);
extern void test_checkBallPosition_output_if_no_goal(void); extern void test_checkBallPosition_output_if_no_goal(void);
extern void test_sortScoreboard_check_if_file_exists(void);
/*=======Mock Management=====*/ /*=======Mock Management=====*/
@ -78,6 +79,7 @@ int main(void)
UnityBegin("test_Modules.c"); UnityBegin("test_Modules.c");
run_test(test_checkBallPosition_output_if_goal, "test_checkBallPosition_output_if_goal", 15); run_test(test_checkBallPosition_output_if_goal, "test_checkBallPosition_output_if_goal", 15);
run_test(test_checkBallPosition_output_if_no_goal, "test_checkBallPosition_output_if_no_goal", 31); run_test(test_checkBallPosition_output_if_no_goal, "test_checkBallPosition_output_if_no_goal", 31);
run_test(test_sortScoreboard_check_if_file_exists, "test_sortScoreboard_check_if_file_exists", 47);
return UnityEnd(); return UnityEnd();
} }

21
test/test_Modules.c

@ -1,7 +1,7 @@
#ifdef TEST #ifdef TEST
#include "unity.h" #include "unity.h"
#include "unistd.h"
#include "Modules.c" #include "Modules.c"
void setUp(void) void setUp(void)
@ -44,4 +44,21 @@ void test_checkBallPosition_output_if_no_goal(void)
TEST_ASSERT_EQUAL(2, output); TEST_ASSERT_EQUAL(2, output);
} }
#endif // TEST
void test_sortScoreboard_check_if_file_is_created(void) {
/* arrange */
/* act */
if (access("ScoreBoard.txt", 0) == 0) {
remove("ScoreBoard.txt");
}
sortScoreboard();
int output = access("ScoreBoard.txt", 0);
/* assert */
TEST_ASSERT_EQUAL(0, output);
}
#endif // TEST
Loading…
Cancel
Save