start writing a test (WIP).

This commit is contained in:
Enno Rehling 2016-12-16 07:29:43 +01:00
parent 31b3f2b2de
commit 95954fb386
3 changed files with 28 additions and 2 deletions

View File

@ -571,7 +571,7 @@ direction_t reldirection(const region * from, const region * to)
return NODIRECTION; return NODIRECTION;
} }
static void leave_trail(ship * sh, region * from, region_list * route) void leave_trail(ship * sh, region * from, region_list * route)
{ {
region *r = from; region *r = from;

View File

@ -63,6 +63,8 @@ extern "C" {
int enoughsailors(const struct ship *sh, int sumskill); int enoughsailors(const struct ship *sh, int sumskill);
bool canswim(struct unit *u); bool canswim(struct unit *u);
bool canfly(struct unit *u); bool canfly(struct unit *u);
void leave_trail(struct ship *sh, struct region *from,
struct region_list *route);
struct ship *move_ship(struct ship *sh, struct region *from, struct ship *move_ship(struct ship *sh, struct region *from,
struct region *to, struct region_list *route); struct region *to, struct region_list *route);
int walkingcapacity(const struct unit *u); int walkingcapacity(const struct unit *u);

View File

@ -478,7 +478,7 @@ static void test_drifting_ships(CuTest *tc) {
region *r1, *r2, *r3; region *r1, *r2, *r3;
terrain_type *t_ocean, *t_plain; terrain_type *t_ocean, *t_plain;
ship_type *st_boat; ship_type *st_boat;
test_cleanup(); test_setup();
t_ocean = test_create_terrain("ocean", SEA_REGION); t_ocean = test_create_terrain("ocean", SEA_REGION);
t_plain = test_create_terrain("plain", LAND_REGION); t_plain = test_create_terrain("plain", LAND_REGION);
r1 = test_create_region(0, 0, t_ocean); r1 = test_create_region(0, 0, t_ocean);
@ -491,11 +491,35 @@ static void test_drifting_ships(CuTest *tc) {
test_cleanup(); test_cleanup();
} }
static void test_ship_leave_trail(CuTest *tc) {
ship *s1, *s2;
region *r1, *r2;
terrain_type *t_ocean;
ship_type *st_boat;
region_list *route = NULL;
test_setup();
t_ocean = test_create_terrain("ocean", SEA_REGION);
r1 = test_create_region(0, 0, t_ocean);
add_regionlist(&route, r2 = test_create_region(1, 0, t_ocean));
add_regionlist(&route, test_create_region(2, 0, t_ocean));
st_boat = test_create_shiptype("boat");
s1 = test_create_ship(r1, st_boat);
s2 = test_create_ship(r1, st_boat);
leave_trail(s1, r1, route);
leave_trail(s2, r1, route);
// CuAssertPtrNotNull(tc, r1->attribs);
CuAssertPtrNotNull(tc, r2->attribs);
free_regionlist(route);
test_cleanup();
}
CuSuite *get_move_suite(void) CuSuite *get_move_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_walkingcapacity); SUITE_ADD_TEST(suite, test_walkingcapacity);
SUITE_ADD_TEST(suite, test_ship_not_allowed_in_coast); SUITE_ADD_TEST(suite, test_ship_not_allowed_in_coast);
SUITE_ADD_TEST(suite, test_ship_leave_trail);
SUITE_ADD_TEST(suite, test_ship_allowed_without_harbormaster); SUITE_ADD_TEST(suite, test_ship_allowed_without_harbormaster);
SUITE_ADD_TEST(suite, test_ship_blocked_by_harbormaster); SUITE_ADD_TEST(suite, test_ship_blocked_by_harbormaster);
SUITE_ADD_TEST(suite, test_ship_has_harbormaster_contact); SUITE_ADD_TEST(suite, test_ship_has_harbormaster_contact);