diff --git a/src/spells/flyingship.test.c b/src/spells/flyingship.test.c index 00c618cd9..9657aea46 100644 --- a/src/spells/flyingship.test.c +++ b/src/spells/flyingship.test.c @@ -1,6 +1,66 @@ #include #include "flyingship.h" +#include +#include +#include +#include +#include + #include #include #include + +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; +} diff --git a/src/test_eressea.c b/src/test_eressea.c index aad65c539..2a0bf04eb 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -114,6 +114,7 @@ int RunAllTests(int argc, char *argv[]) ADD_SUITE(donations); ADD_SUITE(travelthru); ADD_SUITE(economy); + ADD_SUITE(flyingship); ADD_SUITE(give); ADD_SUITE(laws); ADD_SUITE(market);