Snoke
Labyrinth_load.h
Go to the documentation of this file.
1 #ifndef LABYRINTH_LOAD_H
2 #define LABYRINTH_LOAD_H
3 
12 #include "shared.h"
13 #include "Labyrinth/labyrinth.h"
14 
15 TEST(Labyrinth_load, test1)
16 {
17  initscr();
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  retVal = labyrinth.setLabyrinth(gameFieldSize);
35  if(!retVal)
36  {
37  FAIL();
38  }
39 
40  retVal = labyrinth.addSnake(&snake);
41  if(!retVal)
42  {
43  FAIL();
44  }
45 
46  labyrinth.displayHandler();
47 
48  char fileName[MAXLINE] = "testsave";
49  retVal = labyrinth.load(fileName);
50  if(retVal)
51  {
52  SUCCEED();
53  }
54  else
55  {
56  FAIL();
57  }
58  endwin();
59 }
60 
61 #endif // LABYRINTH_LOAD_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.
const int MAXLINE
Definition: common.h:28
bool setLabyrinth(Point dimensions)
Sets the default values fro the variables as well as generating the labyritnh array with borders...
Definition: labyrinth.cpp:17
bool init(Point begin, short direction, int length)
Initializes snake as an entity without ancoring it anywhere.
Definition: snake.cpp:20
bool load(char name[MAXLINE])
Mehod to load labyrinth from the file.
Definition: labyrinth.cpp:339
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
void displayHandler(int displayMethod=-1)
A method which decides what dispaly method will be used in each situation.
Definition: labyrinth.cpp:152
Coordinates and style of the cell in console window.
Definition: common.h:52
TEST(Labyrinth_load, test1)
const int MVDOWN
snake's head is moving down
Definition: snake.h:56