Snoke
Labyrinth_addSnake.h
Go to the documentation of this file.
1 #ifndef LABYRINTH_ADDSNAKE_H
2 #define LABYRINTH_ADDSNAKE_H
3 
10 #include "shared.h"
11 #include "Labyrinth/labyrinth.h"
12 #include <iostream>
13 
17 TEST(Labyrinth_addSnake, test1) {
18  gameFieldSize.x = 70;
19  gameFieldSize.y = 35;
20 
21  Snake snake;
22  Point begin;
23  begin.x = 1;
24  begin.y = 1;
25  short direction = MVDOWN;
26  int lenght = 5;
27  bool retVal = snake.init(begin, direction, lenght);
28  if(!retVal)
29  {
30  FAIL();
31  }
32 
33  Labyrinth labyrinth;
34  Point size;
35  size.x = 70;
36  size.y = 35;
37  retVal = labyrinth.setLabyrinth(size);
38  if(!retVal)
39  {
40  FAIL();
41  }
42 
43  retVal = labyrinth.addSnake(&snake);
44  if(retVal)
45  {
46  SUCCEED();
47  }
48  else
49  {
50  FAIL();
51  }
52 }
53 
57 TEST(Labyrinth_addSnake, test2) {
58 
59  Snake snake;
60  Point begin;
61  begin.x = 1;
62  begin.y = 1;
63  short direction = MVDOWN;
64  int lenght = 45;
65  bool retVal = snake.init(begin, direction, lenght);
66  if(!retVal)
67  {
68  FAIL();
69  }
70 
71  Labyrinth labyrinth;
72  Point size;
73  size.x = 70;
74  size.y = 35;
75  retVal = labyrinth.setLabyrinth(size);
76  if(!retVal)
77  {
78  FAIL();
79  }
80 
81  retVal = labyrinth.addSnake(&snake);
82  if(!retVal)
83  {
84  SUCCEED();
85  }
86  else
87  {
88  FAIL();
89  }
90 }
91 
92 
96 TEST(Labyrinth_addSnake, test3) {
97 
98  Snake snake;
99  Point begin;
100  begin.x = 1;
101  begin.y = 1;
102  short direction = MVRIGHT;
103  int lenght = 70;
104  bool retVal = snake.init(begin, direction, lenght);
105  if(!retVal)
106  {
107  FAIL();
108  }
109 
110  Labyrinth labyrinth;
111  Point size;
112  size.x = 70;
113  size.y = 35;
114  retVal = labyrinth.setLabyrinth(size);
115  if(!retVal)
116  {
117  FAIL();
118  }
119 
120  retVal = labyrinth.addSnake(&snake);
121  if(!retVal)
122  {
123  SUCCEED();
124  }
125  else
126  {
127  FAIL();
128  }
129 }
130 
131 #endif // LABYRINTH_ADDSNAKE_H
short x
Definition: common.h:55
class for containing and displaying the game field
Definition: labyrinth.h:66
Definitions and prototypes for Labyrinth class.
bool setLabyrinth(Point dimensions)
Sets the default values fro the variables as well as generating the labyritnh array with borders...
Definition: labyrinth.cpp:17
TEST(Labyrinth_addSnake, test1)
method runs with normal parameters
bool init(Point begin, short direction, int length)
Initializes snake as an entity without ancoring it anywhere.
Definition: snake.cpp:20
shared functions for testing
Point gameFieldSize
Definition: game.cpp:17
short y
Definition: common.h:56
Describes the Snake entity of the game.
Definition: snake.h:79
bool addSnake(Snake *snake)
Adding snake to the laburinth and getting the host snake(firest added snake)
Definition: labyrinth.cpp:110
const int MVRIGHT
snake&#39;s head is moving right
Definition: snake.h:52
Coordinates and style of the cell in console window.
Definition: common.h:52
const int MVDOWN
snake&#39;s head is moving down
Definition: snake.h:56