From 860078cfc98c40430b9066b3b9995477792f30fd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 20 Aug 2016 19:10:53 +0200 Subject: [PATCH] fix piracy_cmd_land_to_land --- src/piracy.test.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/piracy.test.c b/src/piracy.test.c index 005ce5857..1c266fd47 100644 --- a/src/piracy.test.c +++ b/src/piracy.test.c @@ -178,22 +178,39 @@ static void test_piracy_cmd_walking(CuTest * tc) { } static void test_piracy_cmd_land_to_land(CuTest * tc) { - unit *pirate, *victim; + unit *u; order *ord; region *r; + faction *f; + int target; + const terrain_type *t_plain; + const ship_type *stype; test_cleanup(); - setup_pirate(&pirate, 0, 0, "boat", &ord, &victim, SEA_REGION, "boat"); - set_level(pirate, SK_SAILING, pirate->ship->type->sumskill); - r = pirate->region; + setup_piracy(); + t_plain = get_or_create_terrain("plain"); + stype = test_create_shiptype("boat"); - piracy_cmd(pirate, ord); - CuAssertPtrEquals(tc, 0, pirate->thisorder); - CuAssertTrue(tc, pirate->region == r); - /* TODO check message - CuAssertPtrNotNullMsg(tc, "successful PIRACY movement", test_find_messagetype(pirate->faction->msgs, "travel")); - */ + // create a target: + r = test_create_region(0, 0, t_plain); + f = test_create_faction(0); + u = test_create_unit(f, r); + u->ship = test_create_ship(r, stype); + target = f->no; + + // create a pirate: + r = test_create_region(1, 0, t_plain); + f = test_create_faction(0); + u = test_create_unit(f, r); + u->ship = test_create_ship(r, stype); + set_level(u, SK_SAILING, u->ship->type->sumskill); + ord = create_order(K_PIRACY, f->locale, "%s", itoa36(target)); + + piracy_cmd(u, ord); + CuAssertPtrEquals(tc, 0, u->thisorder); + CuAssertPtrEquals(tc, r, u->region); + // TODO check message free_order(ord); test_cleanup(); @@ -226,7 +243,7 @@ CuSuite *get_piracy_suite(void) SUITE_ADD_TEST(suite, test_piracy_cmd_errors); SUITE_ADD_TEST(suite, test_piracy_cmd); SUITE_ADD_TEST(suite, test_piracy_cmd_walking); - DISABLE_TEST(suite, test_piracy_cmd_land_to_land); + SUITE_ADD_TEST(suite, test_piracy_cmd_land_to_land); SUITE_ADD_TEST(suite, test_piracy_cmd_swimmer); return suite; }