Browse Source

refactoring: change_direction

main^2
Joe Lukas Kalb 11 months ago
committed by Peter Wiebe
parent
commit
4dff49735e
  1. 2
      src/main/c/global.h
  2. 2
      src/main/c/labyrinth.c
  3. 2
      src/main/c/labyrinth.h
  4. 6
      src/test/c/test_labyrinth.c

2
src/main/c/global.h

@ -3,6 +3,6 @@
typedef enum { typedef enum {
N, E, S, W N, E, S, W
} Dir;
} Direction;
#endif #endif

2
src/main/c/labyrinth.c

@ -5,7 +5,7 @@
#include "stdio.h" #include "stdio.h"
#include "stdlib.h" #include "stdlib.h"
void change_direction(Dir *direction){
void turn_direction_right(Direction *direction){
switch (*direction) { switch (*direction) {
case N: case N:
*direction = E; *direction = E;

2
src/main/c/labyrinth.h

@ -3,6 +3,6 @@
#include "global.h" #include "global.h"
void change_direction(Dir *direction);
void turn_direction_right(Direction *direction);
#endif // TEST_H #endif // TEST_H

6
src/test/c/test_labyrinth.c

@ -15,11 +15,11 @@ void tearDown(void)
void test_change_direction_from_N_expected_E(void) void test_change_direction_from_N_expected_E(void)
{ {
/* arrange */ /* arrange */
Dir actual = N;
Dir expected = E;
Direction actual = N;
Direction expected = E;
/* act */ /* act */
change_direction(&actual);
turn_direction_right(&actual);
/* assert */ /* assert */
TEST_ASSERT_TRUE(expected == actual); TEST_ASSERT_TRUE(expected == actual);

Loading…
Cancel
Save