Test error message when following yourself.

This commit is contained in:
Enno Rehling 2020-08-12 01:33:24 +02:00
parent b657873488
commit afb7b4f8e8
1 changed files with 20 additions and 0 deletions

View File

@ -445,6 +445,25 @@ static void test_ship_damage_overload(CuTest *tc) {
CuAssertDblEquals(tc, 0.37, damage_overload(5), ASSERT_DBL_DELTA);
}
static void test_follow_unit_self(CuTest *tc) {
unit *u;
order *ord;
faction *f;
test_setup();
mt_create_va(mt_new("followfail", NULL),
"unit:unit", "follower:unit", MT_NEW_END);
f = test_create_faction(NULL);
u = test_create_unit(f, test_create_plain(0, 0));
ord = create_order(K_FOLLOW, f->locale, "EINHEIT %s", itoa36(u->no));
unit_addorder(u, ord);
follow_unit(u);
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "followfail"));
CuAssertIntEquals(tc, 0, fval(u, UFL_FOLLOWING | UFL_LONGACTION));
test_teardown();
}
typedef struct traveldir {
int no;
direction_t dir;
@ -708,6 +727,7 @@ CuSuite *get_move_suite(void)
SUITE_ADD_TEST(suite, test_ship_ridiculous_overload_bad);
SUITE_ADD_TEST(suite, test_ship_ridiculous_overload_no_captain);
SUITE_ADD_TEST(suite, test_ship_damage_overload);
SUITE_ADD_TEST(suite, test_follow_unit_self);
SUITE_ADD_TEST(suite, test_follow_ship_msg);
SUITE_ADD_TEST(suite, test_drifting_ships);
SUITE_ADD_TEST(suite, test_route_cycle);