server/src/spells/flyingship.test.c

73 lines
1.6 KiB
C
Raw Normal View History

#include <platform.h>
#include "flyingship.h"
#include <kernel/build.h>
#include <kernel/faction.h>
#include <kernel/region.h>
#include <kernel/unit.h>
#include <kernel/ship.h>
2015-11-02 17:58:14 +01:00
#include <magic.h>
#include <CuTest.h>
#include <tests.h>
#include <assert.h>
static void test_flyingship(CuTest * tc)
{
castorder co;
spellparameter par;
spllprm par_data;
spllprm *par_data_ptr = &par_data;
region *r;
faction *f;
unit *u;
ship_type *shipType1, *shipType2;
ship *sh1, *sh2;
2015-11-07 18:45:41 +01:00
test_cleanup();
2015-11-02 17:58:14 +01:00
par.param = &par_data_ptr;
par_data.typ = SPP_SHIP;
2015-11-07 18:20:37 +01:00
par_data.flag = 0;
2015-11-02 17:58:14 +01:00
2015-11-07 18:47:55 +01:00
r = test_create_region(0, 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));
free_castorder(&co);
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));
free_castorder(&co);
2015-11-07 18:45:41 +01:00
test_cleanup();
}
CuSuite *get_flyingship_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_flyingship);
return suite;
}