Browse Source

lab_move direction E --> y = 2

main^2
Joe Lukas Kalb 11 months ago
committed by Peter Wiebe
parent
commit
0d6b5b8137
  1. 4
      src/main/c/labyrinth.c
  2. 17
      src/test/c/test_labyrinth.c

4
src/main/c/labyrinth.c

@ -28,6 +28,10 @@ void lab_move(unsigned short *x, unsigned short *y, Direction direction){
*x = *x - 1; *x = *x - 1;
return; return;
} }
if (direction == E){
*y = 2;
return;
}
} }

17
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); 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);
}
Loading…
Cancel
Save