forked from github/server
parent
c1a6d4ac03
commit
f3286cbd0a
|
@ -10,6 +10,49 @@
|
||||||
#include <CuTest.h>
|
#include <CuTest.h>
|
||||||
#include <tests.h>
|
#include <tests.h>
|
||||||
|
|
||||||
|
static void test_ship_not_allowed_in_coast(CuTest * tc)
|
||||||
|
{
|
||||||
|
region *r;
|
||||||
|
ship * sh;
|
||||||
|
terrain_type * ttype;
|
||||||
|
ship_type * stype;
|
||||||
|
const char * names[] = { "derp", "derp_p" };
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
test_create_world();
|
||||||
|
|
||||||
|
ttype = test_create_terrain("glacier", LAND_REGION|ARCTIC_REGION|WALK_INTO|SAIL_INTO);
|
||||||
|
stype = test_create_shiptype(names);
|
||||||
|
stype->coasts = (const struct terrain_type **)calloc(2, sizeof(const struct terrain_type *));
|
||||||
|
|
||||||
|
r = test_create_region(0, 0, ttype);
|
||||||
|
sh = test_create_ship(0, stype);
|
||||||
|
|
||||||
|
CuAssertIntEquals(tc, SA_NO_COAST, check_ship_allowed(sh, r));
|
||||||
|
stype->coasts[0] = ttype;
|
||||||
|
CuAssertIntEquals(tc, SA_COAST, check_ship_allowed(sh, r));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_ship_allowed_with_harbor(CuTest * tc)
|
||||||
|
{
|
||||||
|
region *r;
|
||||||
|
ship * sh;
|
||||||
|
terrain_type * ttype;
|
||||||
|
building_type * btype;
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
test_create_world();
|
||||||
|
|
||||||
|
ttype = test_create_terrain("glacier", LAND_REGION|ARCTIC_REGION|WALK_INTO|SAIL_INTO);
|
||||||
|
btype = test_create_buildingtype("harbour");
|
||||||
|
|
||||||
|
r = test_create_region(0, 0, ttype);
|
||||||
|
sh = test_create_ship(0, 0);
|
||||||
|
|
||||||
|
test_create_building(r, btype);
|
||||||
|
CuAssertIntEquals(tc, SA_HARBOUR, check_ship_allowed(sh, r));
|
||||||
|
}
|
||||||
|
|
||||||
static void test_building_type_exists(CuTest * tc)
|
static void test_building_type_exists(CuTest * tc)
|
||||||
{
|
{
|
||||||
region *r;
|
region *r;
|
||||||
|
|
Loading…
Reference in New Issue