From 52d99947407a77eac9c5a90eb9d36c375cd966bb Mon Sep 17 00:00:00 2001 From: fdai7037 Date: Fri, 10 Feb 2023 18:08:31 +0100 Subject: [PATCH] Siebter Unit Test --- test/test_Modules.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/test_Modules.c b/test/test_Modules.c index 3fb41e2..3e91d66 100644 --- a/test/test_Modules.c +++ b/test/test_Modules.c @@ -129,4 +129,33 @@ void test_generateField_check_walls_length_correctly_inserted(void){ TEST_ASSERT_EQUAL(0, output); } +void test_sortScoreboard_check_if_file_is_being_read(void) { + + /* arrange */ + char Text[4]; + FILE *x; + int y; + + /* act */ + if (access("ScoreBoard.txt", 0) == 0) { + remove("ScoreBoard.txt"); + } + + sortScoreboard(); + + x = fopen("ScoreBoard.txt", "a+"); + + fputs("Tesf", x); + rewind(x); + for(int i = 0; i < 4; i++) { + fscanf(x, "%s", &Text[i]); + } + + if(strcmp(Text, "Test") == 0) { + y = 0; + } + /* assert */ + TEST_ASSERT_EQUAL(0, y); +} + #endif // TEST \ No newline at end of file