Snoke
Snake_setDirection.h
Go to the documentation of this file.
1 #ifndef SNAKE_SETDIRECTION_H
2 #define SNAKE_SETDIRECTION_H
3 
9 #include "shared.h"
10 #include "Snake/snake.h"
11 
15 TEST(Snake_setDirection, test1) {
16 
17  /*
18  * Minimal environment block for the snake_init_test
19  */
20  Snake snake;
21  Point begin;
22  begin.x = 1;
23  begin.y = 1;
24  short direction = MVRIGHT;
25  int length = 5;
26 
27  bool retVal = snake.init(begin, direction, length);
28 
29  /*
30  * if snake cannot be initialized in normal conditions - FAIL
31  */
32  if(!retVal)
33  {
34  FAIL();
35  }
36 
37  retVal = snake.setDirection(MVDOWN);
38 
39  if(retVal)
40  {
41  SUCCEED();
42  }
43  else
44  {
45  FAIL();
46  }
47 
48 }
49 
53 TEST(Snake_setDirection, test2) {
54 
55  /*
56  * Minimal environment block for the snake_init_test
57  */
58  Snake snake;
59  Point begin;
60  begin.x = 1;
61  begin.y = 1;
62  short direction = MVRIGHT;
63  int length = 5;
64 
65  bool retVal = snake.init(begin, direction, length);
66 
67  /*
68  * if snake cannot be initialized in normal conditions - FAIL
69  */
70  if(!retVal)
71  {
72  FAIL();
73  }
74 
75  retVal = snake.setDirection(MVLEFT);
76 
77  if(!retVal)
78  {
79  SUCCEED();
80  }
81  else
82  {
83  FAIL();
84  }
85 
86 }
87 
88 #endif // SNAKE_SETDIRECTION_H
short x
Definition: common.h:55
TEST(Snake_setDirection, test1)
method runs with normal parameters
bool setDirection(int dir)
The method to set the direction where the snake is heading.
Definition: snake.cpp:294
bool init(Point begin, short direction, int length)
Initializes snake as an entity without ancoring it anywhere.
Definition: snake.cpp:20
const int MVLEFT
snake's head is moving left
Definition: snake.h:60
shared functions for testing
short y
Definition: common.h:56
Describes the Snake entity of the game.
Definition: snake.h:79
const int MVRIGHT
snake's head is moving right
Definition: snake.h:52
Coordinates and style of the cell in console window.
Definition: common.h:52
Definitions and prototypes for Snake class.
const int MVDOWN
snake's head is moving down
Definition: snake.h:56