From 91a941c8f6684fd8a8d47371a374ec61b6e6e425 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:42:11 +0100 Subject: [PATCH] lab_move direction W y --> y - 1 --- src/main/c/labyrinth.c | 2 +- src/test/c/test_labyrinth.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 59bff17..ba08944 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -37,7 +37,7 @@ void lab_move(unsigned short *x, unsigned short *y, Direction direction){ return; } if (direction == W){ - *y = 0; + *y = *y - 1; return; } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 03b1642..98d4f2f 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -183,3 +183,20 @@ void test_lab_move_from_1_1_W_expected_1_0(void) TEST_ASSERT_TRUE(x == x_expected && y == y_expected); } +void test_lab_move_from_5_5_W_expected_5_4(void) +{ + /* arrange */ + unsigned short x = 5; + unsigned short y = 5; + Direction direction = W; + + unsigned short x_expected = 5; + unsigned short y_expected = 4; + + /* act */ + lab_move(&x, &y, direction); + + /* assert */ + TEST_ASSERT_TRUE(x == x_expected && y == y_expected); +} +