From ce57e7533ce5a1f6485777f5d8004978086f9f4c Mon Sep 17 00:00:00 2001 From: David Moeller Date: Thu, 25 Jan 2024 10:00:07 +0100 Subject: [PATCH] Test self_collision --- src/main/c/Snake/get_character.c | 1 - test/Snake/test_collision.c | 24 ++++++++++++++++++++++++ test/Snake/test_part_of_snake.c | 7 ++----- 3 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 test/Snake/test_collision.c diff --git a/src/main/c/Snake/get_character.c b/src/main/c/Snake/get_character.c index a800c01..9c180ef 100644 --- a/src/main/c/Snake/get_character.c +++ b/src/main/c/Snake/get_character.c @@ -3,7 +3,6 @@ #include #include #include -#include #include struct termios orig_termios; diff --git a/test/Snake/test_collision.c b/test/Snake/test_collision.c new file mode 100644 index 0000000..81d1a76 --- /dev/null +++ b/test/Snake/test_collision.c @@ -0,0 +1,24 @@ +#ifdef TEST +#include "unity.h" +#include +#include "../../src/main/c/Snake/snake_start.h" +#include "../../src/main/c/Snake/get_character.h" + + +void setUp(void){} +void tearDown(void){} + + +void test_self_collision(void){ + /* arrange */ + bool result; + Snake snake = {{1, 0}, 5, {6 + 16 * 6, 6 + 16 * 7, 7 + 16 * 7, 7 + 16 * 6, 6 + 16 * 6}}; + + /* act */ + result = check_if_dead(&snake); + + /* assert */ + TEST_ASSERT_TRUE(result);//head collides with body +} + +#endif // TEST \ No newline at end of file diff --git a/test/Snake/test_part_of_snake.c b/test/Snake/test_part_of_snake.c index c349867..95ce3bd 100644 --- a/test/Snake/test_part_of_snake.c +++ b/test/Snake/test_part_of_snake.c @@ -4,11 +4,8 @@ #include "../../src/main/c/Snake/get_character.h" -void setUp(void){ - //Wenn Funktion Vorraussetzungen braucht -} -void tearDown(void){ -} +void setUp(void){} +void tearDown(void){} void test_find_head(void){