From eb2b6fc6d57a42f5baaf266e9dda4c534c175e50 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 18:34:30 +0100 Subject: [PATCH] lab_move direction E --> y = 2 --- src/main/c/labyrinth.c | 4 ++++ src/test/c/test_labyrinth.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 5b18703..2575180 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -28,6 +28,10 @@ void lab_move(unsigned short *x, unsigned short *y, Direction direction){ *x = *x - 1; return; } + if (direction == E){ + *y = 2; + return; + } } diff --git a/src/test/c/test_labyrinth.c b/src/test/c/test_labyrinth.c index 022c2e8..85ad115 100644 --- a/src/test/c/test_labyrinth.c +++ b/src/test/c/test_labyrinth.c @@ -98,3 +98,20 @@ void test_lab_move_from_5_5_N_expected_4_5(void) TEST_ASSERT_TRUE(x == x_expected && y == y_expected); } +void test_lab_move_from_1_1_E_expected_1_2(void) +{ + /* arrange */ + unsigned short x = 1; + unsigned short y = 1; + Direction direction = E; + + unsigned short x_expected = 1; + unsigned short y_expected = 2; + + /* act */ + lab_move(&x, &y, direction); + + /* assert */ + TEST_ASSERT_TRUE(x == x_expected && y == y_expected); +} +