From f0714574269afae276ade2110dafe77c8e2427ba Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:20:32 +0100 Subject: [PATCH] move north set x 0 --- src/main/c/labyrinth.c | 10 ++++++++++ src/main/c/labyrinth.h | 1 + src/test/c/test_labyrinth.c | 17 +++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index a76a53b..89227c3 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -21,3 +21,13 @@ void turn_direction_right(Direction *direction){ break; } } + +void move(unsigned short *x, unsigned short *y, Direction direction){ + + if (direction == N){ + *x = 0; + return; + } + +} + diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index 4c077e9..402e915 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -4,5 +4,6 @@ #include "global.h" void turn_direction_right(Direction *direction); +void move(unsigned short *x, unsigned short *y, Direction direction); #endif // TEST_H diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index e257b07..5e63380 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -64,3 +64,20 @@ void test_turn_direction_right_from_W_expected_N(void) TEST_ASSERT_TRUE(expected == actual); } +void test_lab_move_from_1_1_N_expected_0_1(void) +{ + /* arrange */ + unsigned short x = 1; + unsigned short y = 1; + Direction direction = N; + + unsigned short x_expected = 0; + unsigned short y_expected = 1; + + /* act */ + move(&x, &y, direction); + + /* assert */ + TEST_ASSERT_TRUE(x == x_expected && y == y_expected); +} +