Advanced Strategic Command
recyclingtest.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 "../gamemap.h"
11 #include "../actions/recycleunitcommand.h"
12 #include "../loaders.h"
13 #include "recyclingtest.h"
14 #include "unittestutil.h"
15 #include "spfst.h"
16 
17 
18 
20 {
21  auto_ptr<GameMap> game ( startMap("unittest-recycle.map"));
22 
23  Building* bld = game->getField(5,8)->building;
24  Vehicle* veh = getFirstCargo( bld );
25  assertOrThrow( veh != NULL );
26  assertOrThrow( bld != NULL );
27 
28  RecycleUnitCommand* ruc = new RecycleUnitCommand( bld );
29  ruc->setUnit( veh );
30  ActionResult res = ruc->execute( createTestingContext( game.get() ));
31  assertOrThrow( res.successful() );
32 
33 }
map accessing and usage routines used by ASC and the mapeditor
#define assertOrThrow(expr)
Definition: errors.h:69
Vehicle * getFirstCargo(ContainerBase *carrier)
Context createTestingContext(GameMap *gamemap)
void testRecycling()
ActionResult execute(const Context &context)
Definition: action.cpp:41
MapField * getField(const BuildingType::LocalCoordinate &localCoordinates) const
returns the pointer to the field which the given part of the building is standing on ...
Definition: buildings.cpp:399
GameMap * startMap(const ASCString &filename)
void setUnit(Vehicle *unit)
bool successful() const
Building * building
Definition: mapfield.h:102
An actual building on the map, which references a BuildingType Buildings have an owner,.
Definition: buildings.h:38