Advanced Strategic Command
jumptest.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 #include <iostream>
11 
12 #include "../actions/jumpdrivecommand.h"
13 #include "../loaders.h"
14 #include "../itemrepository.h"
15 #include "unittestutil.h"
16 #include "../gamemap.h"
17 
18 
20 {
21  auto_ptr<GameMap> game ( startMap("testjump.map"));
22 
23  Vehicle* veh = game->getField(5,14)->vehicle;
24  assertOrThrow( veh != NULL );
25  assertOrThrow( veh->damage == 0 );
26 
27  JumpDriveCommand* jdc = new JumpDriveCommand( veh );
28 
29  jdc->setDestination( MapCoordinate( 5, 4));
30  ActionResult res = jdc->execute( createTestingContext( game.get() ));
31 
32  assertOrThrow( veh->attacked );
33  assertOrThrow( veh->damage > 0 );
34 
35 }
36 
void testJumpdrive()
Definition: jumptest.cpp:19
int damage
Damage. 0 is no damage, when damage reaches 100 the container is destroyed.
#define assertOrThrow(expr)
Definition: errors.h:69
Context createTestingContext(GameMap *gamemap)
ActionResult execute(const Context &context)
Definition: action.cpp:41
Coordinate on the twodimensional map.
Definition: typen.h:202
GameMap * startMap(const ASCString &filename)
void setDestination(const MapCoordinate &position)
bool attacked
did the unit already attack this turn
Definition: vehicle.h:109