added test-suite for flyingship.c

some general testing of the spells functionality for future maintenance
purposes
This commit is contained in:
Philipp Dreher 2015-11-02 17:54:23 +01:00
parent 29173887b6
commit 96ccb046ab
2 changed files with 61 additions and 0 deletions

View File

@ -1,6 +1,66 @@
#include <platform.h> #include <platform.h>
#include "flyingship.h" #include "flyingship.h"
#include <kernel/build.h>
#include <kernel/faction.h>
#include <kernel/region.h>
#include <kernel/unit.h>
#include <kernel/ship.h>
#include <CuTest.h> #include <CuTest.h>
#include <tests.h> #include <tests.h>
#include <assert.h> #include <assert.h>
static void test_flyingship(CuTest * tc)
{
castorder co;
spellparameter par;
spllprm par_data;
spllprm *par_data_ptr = &par_data;
par.param = &par_data_ptr;
par_data.typ = SPP_SHIP;
region *r;
faction *f;
unit *u;
ship_type *shipType1, *shipType2;
ship *sh1, *sh2;
test_cleanup();
test_create_world();
r = findregion(0, 0);
f = test_create_faction(test_create_race("human"));
u = test_create_unit(f, r);
shipType1 = test_create_shiptype("boot");
shipType1->construction->maxsize = 50;
shipType2 = test_create_shiptype("schiff");
shipType2->construction->maxsize = 51;
sh1 = test_create_ship(r, shipType1);
par_data.data.sh = sh1;
test_create_castorder(&co, u, 10, 10.0, 0, &par);
CuAssertTrue(tc, !flying_ship(sh1));
CuAssertIntEquals(tc, 10, sp_flying_ship(&co));
CuAssertTrue(tc, flying_ship(sh1));
sh2 = test_create_ship(r, shipType2);
par_data.data.sh = sh2;
test_create_castorder(&co, u, 10, 10.0, 0, &par);
CuAssertTrue(tc, !flying_ship(sh2));
CuAssertIntEquals(tc, 0, sp_flying_ship(&co));
CuAssertTrue(tc, !flying_ship(sh2));
}
CuSuite *get_flyingship_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_flyingship);
return suite;
}

View File

@ -114,6 +114,7 @@ int RunAllTests(int argc, char *argv[])
ADD_SUITE(donations); ADD_SUITE(donations);
ADD_SUITE(travelthru); ADD_SUITE(travelthru);
ADD_SUITE(economy); ADD_SUITE(economy);
ADD_SUITE(flyingship);
ADD_SUITE(give); ADD_SUITE(give);
ADD_SUITE(laws); ADD_SUITE(laws);
ADD_SUITE(market); ADD_SUITE(market);