Advanced Strategic Command
actiontest.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * This program is free software; you can redistribute it and/or modify *
4  * it under the terms of the GNU General Public License as published by *
5  * the Free Software Foundation; either version 2 of the License, or *
6  * (at your option) any later version. *
7  * *
8  ***************************************************************************/
9 
10 
11 #include "../actions/moveunitcommand.h"
12 #include "../loaders.h"
13 #include "../itemrepository.h"
14 #include "unittestutil.h"
15 
16 
17 void testActions()
18 {
19  auto_ptr<GameMap> game ( startMap("unittest-movement.map"));
20 
21  Vehicle* veh = game->getField(0,0)->vehicle;
22  assertOrThrow( veh->getMovement() == 100 );
23 
24 
25  move(veh, MapCoordinate(0,1));
26  move(veh, MapCoordinate(1,2));
27  move(veh, MapCoordinate(1,3));
28  move(veh, MapCoordinate(2,4));
29  move(veh, MapCoordinate(2,5));
30  move(veh, MapCoordinate(3,6));
31  move(veh, MapCoordinate(3,7));
32  move(veh, MapCoordinate(4,8));
33  move(veh, MapCoordinate(4,9));
34  move(veh, MapCoordinate(5,10));
35 
36  for ( int i = 0; i < 5; ++i ) {
37  ActionResult res = game->actions.rerun( createTestingContext( game.get() ) );
38  assertOrThrow( res.successful() );
39  }
40 
41 }
42 
void move(Vehicle *veh, const MapCoordinate &dest)
#define assertOrThrow(expr)
Definition: errors.h:69
Context createTestingContext(GameMap *gamemap)
Coordinate on the twodimensional map.
Definition: typen.h:202
GameMap * startMap(const ASCString &filename)
bool successful() const
void testActions()
Definition: actiontest.cpp:17
int getMovement(bool checkFuel=true, bool checkRF=true) const
returns the movement points the unit has left for this turn. CheckFuel should almost always be true...
Definition: vehicle.cpp:558