2014-12-16 13:12:54 +00:00
|
|
|
#include <iostream> // std::cout
|
|
|
|
|
2014-12-16 13:12:55 +00:00
|
|
|
#include "unitv.h"
|
2014-12-16 13:12:57 +00:00
|
|
|
#include "board.h"
|
|
|
|
#include "orders.h"
|
2014-12-16 13:13:00 +00:00
|
|
|
#include "game.h"
|
2014-12-16 13:12:57 +00:00
|
|
|
|
2014-12-16 13:13:00 +00:00
|
|
|
const char* tests()
|
2014-12-16 13:12:54 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
CBoard board = CBoard(10,5);
|
|
|
|
board.clear();
|
|
|
|
board.fill(48);
|
|
|
|
}
|
|
|
|
|
2014-12-16 13:12:56 +00:00
|
|
|
{
|
|
|
|
CUnitV myV;
|
2014-12-16 13:13:00 +00:00
|
|
|
if( myV.getVisual() != 'v' && myV.getVisual() != '<' && myV.getVisual() != '^' && myV.getVisual() != '>' )
|
|
|
|
return "failed to properly create V unit";
|
2014-12-16 13:12:56 +00:00
|
|
|
}
|
2014-12-16 13:12:55 +00:00
|
|
|
|
2014-12-16 13:13:00 +00:00
|
|
|
{
|
|
|
|
CUnitV myV;
|
|
|
|
CUnitV myV2;
|
|
|
|
if( myV.getID() == myV2.getID() )
|
|
|
|
return "Unit IDs the same";
|
|
|
|
}
|
|
|
|
|
2014-12-16 13:12:56 +00:00
|
|
|
{
|
|
|
|
std::unique_ptr<CUnit> myV = CUnit::getUnitFromVis('v');
|
2014-12-16 13:12:57 +00:00
|
|
|
if( myV->getVisual() != 'v' )
|
2014-12-16 13:13:00 +00:00
|
|
|
return "failed to properly create V unit";
|
2014-12-16 13:12:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
COrder order;
|
|
|
|
order.order = 'F';
|
|
|
|
order.unit = 10;
|
|
|
|
std::string order_string = GetStringFromOrder(order);
|
|
|
|
COrder order2 = GetOrderFromString(order_string);
|
|
|
|
|
|
|
|
if ( order2 != order )
|
2014-12-16 13:13:00 +00:00
|
|
|
return "failed order string conversion test";
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
COrder order;
|
|
|
|
order.order = 'F';
|
|
|
|
if (!isMovementOrder(order) )
|
|
|
|
return "Failed to detect a movement order";
|
|
|
|
|
|
|
|
if (isActionOrder(order) )
|
|
|
|
return "Wrongly detected an action order";
|
2014-12-16 13:12:56 +00:00
|
|
|
}
|
2014-12-16 13:13:00 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
COrder order;
|
|
|
|
order.order = 'L';
|
|
|
|
if (! isActionOrder(order) )
|
|
|
|
return "Failed to detect a action order";
|
|
|
|
|
|
|
|
if (isMovementOrder(order) )
|
|
|
|
return "Wrongly detected an movement order";
|
|
|
|
}
|
|
|
|
|
2014-12-16 13:13:00 +00:00
|
|
|
{
|
|
|
|
CTTRTSGame game( 15, 10 );
|
|
|
|
if( game.SimulateToNextTurn() )
|
|
|
|
return "Failed to simulate a blank game";
|
|
|
|
|
|
|
|
if( game.GetNumOrders() )
|
|
|
|
return "Game started with non-zero order number";
|
|
|
|
|
|
|
|
if( game.GetNumUnits() )
|
|
|
|
return "Game started with non-zero unit number";
|
|
|
|
}
|
|
|
|
|
2014-12-16 13:13:00 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Main program entry point
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
std::cout<<"Running tests"<<std::endl;
|
|
|
|
|
|
|
|
const char* res = tests();
|
|
|
|
|
|
|
|
if( res )
|
|
|
|
{
|
|
|
|
std::cout<<"Tests failed - "<<res<<std::endl;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::cout<<"Tests succeeded"<<std::endl;
|
|
|
|
return 0;
|
2014-12-16 13:12:51 +00:00
|
|
|
};
|