From 6a30cdf1b748448692cdcbd3e023c57358ac9f5a Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:39:17 +0100 Subject: [PATCH] lab_move direction S x --> x + 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 ed5b973..b3d95b2 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -33,7 +33,7 @@ void lab_move(unsigned short *x, unsigned short *y, Direction direction){ return; } if (direction == S){ - *x = 2; + *x = *x + 1; return; } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index ad8180f..bd2c483 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -149,3 +149,20 @@ void test_lab_move_from_1_1_S_expected_2_1(void) TEST_ASSERT_TRUE(x == x_expected && y == y_expected); } +void test_lab_move_from_5_5_S_expected_6_5(void) +{ + /* arrange */ + unsigned short x = 5; + unsigned short y = 5; + Direction direction = S; + + unsigned short x_expected = 6; + unsigned short y_expected = 5; + + /* act */ + lab_move(&x, &y, direction); + + /* assert */ + TEST_ASSERT_TRUE(x == x_expected && y == y_expected); +} +