Browse Source

lab move N --> x - 1

remotes/origin/Joe
Joe Lukas Kalb 11 months ago
parent
commit
7c44069153
  1. 2
      src/main/c/labyrinth.c
  2. 17
      src/test/c/test_labyrinth.c

2
src/main/c/labyrinth.c

@ -25,7 +25,7 @@ void turn_direction_right(Direction *direction){
void lab_move(unsigned short *x, unsigned short *y, Direction direction){ void lab_move(unsigned short *x, unsigned short *y, Direction direction){
if (direction == N){ if (direction == N){
*x = 0;
*x = *x - 1;
return; return;
} }

17
src/test/c/test_labyrinth.c

@ -81,3 +81,20 @@ void test_lab_move_from_1_1_N_expected_0_1(void)
TEST_ASSERT_TRUE(x == x_expected && y == y_expected); TEST_ASSERT_TRUE(x == x_expected && y == y_expected);
} }
void test_lab_move_from_5_5_N_expected_4_5(void)
{
/* arrange */
unsigned short x = 5;
unsigned short y = 5;
Direction direction = N;
unsigned short x_expected = 4;
unsigned short y_expected = 5;
/* act */
lab_move(&x, &y, direction);
/* assert */
TEST_ASSERT_TRUE(x == x_expected && y == y_expected);
}
Loading…
Cancel
Save