From 4098cb4030fc0c32dcd7faf10b302f4303801570 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:03:21 +0100 Subject: [PATCH] Direction; change_direction N --> E --- src/main/c/global.h | 8 ++++++++ src/main/c/labyrinth.c | 14 ++++++++++++++ src/main/c/labyrinth.h | 8 ++++++++ src/main/c/test.c | 6 ------ src/main/c/test.h | 6 ------ src/test/c/support/.invis | 0 src/test/c/test_labyrinth.c | 27 +++++++++++++++++++++++++++ src/test/c/test_test.c | 28 ---------------------------- 8 files changed, 57 insertions(+), 40 deletions(-) create mode 100644 src/main/c/global.h create mode 100644 src/main/c/labyrinth.c create mode 100644 src/main/c/labyrinth.h delete mode 100644 src/main/c/test.c delete mode 100644 src/main/c/test.h delete mode 100644 src/test/c/support/.invis create mode 100644 src/test/c/test_labyrinth.c delete mode 100644 src/test/c/test_test.c diff --git a/src/main/c/global.h b/src/main/c/global.h new file mode 100644 index 0000000..b6aa8f0 --- /dev/null +++ b/src/main/c/global.h @@ -0,0 +1,8 @@ +#ifndef GLOBAL_H +#define GLOBAL_H + +typedef enum { + N, E, S, W +} Dir; + +#endif \ No newline at end of file diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c new file mode 100644 index 0000000..8067030 --- /dev/null +++ b/src/main/c/labyrinth.c @@ -0,0 +1,14 @@ +#include "labyrinth.h" + +#include "global.h" + +#include "stdio.h" +#include "stdlib.h" + +void change_direction(Dir *direction){ + switch (*direction) { + case N: + *direction = E; + break; + } +} diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h new file mode 100644 index 0000000..0ab2124 --- /dev/null +++ b/src/main/c/labyrinth.h @@ -0,0 +1,8 @@ +#ifndef TEST_H +#define TEST_H + +#include "global.h" + +void change_direction(Dir *direction); + +#endif // TEST_H diff --git a/src/main/c/test.c b/src/main/c/test.c deleted file mode 100644 index 52489ec..0000000 --- a/src/main/c/test.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "test.h" - -int return_5(){ - return 5; -} - diff --git a/src/main/c/test.h b/src/main/c/test.h deleted file mode 100644 index 4458e13..0000000 --- a/src/main/c/test.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef TEST_H -#define TEST_H - -int return_5(); - -#endif // TEST_H diff --git a/src/test/c/support/.invis b/src/test/c/support/.invis deleted file mode 100644 index e69de29..0000000 diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c new file mode 100644 index 0000000..9426c2c --- /dev/null +++ b/src/test/c/test_labyrinth.c @@ -0,0 +1,27 @@ +#include "unity.h" + +#include "stdlib.h" + +#include "labyrinth.h" + +void setUp(void) +{ +} + +void tearDown(void) +{ +} + +void test_change_direction_from_N_expected_E(void) +{ + /* arrange */ + Dir actual = N; + Dir expected = E; + + /* act */ + change_direction(&actual); + + /* assert */ + TEST_ASSERT_TRUE(expected == actual); +} + diff --git a/src/test/c/test_test.c b/src/test/c/test_test.c deleted file mode 100644 index 4f61ea7..0000000 --- a/src/test/c/test_test.c +++ /dev/null @@ -1,28 +0,0 @@ -#ifdef TEST - -#include "unity.h" - -#include "test.h" - -void setUp(void) -{ -} - -void tearDown(void) -{ -} - -void test_test__return_5(void) -{ - /* arrange */ - int expected = 5; - int actual; - - /* act */ - actual = return_5(); - - /* assert */ - TEST_ASSERT_EQUAL_INT(expected, actual); -} - -#endif // TEST