fix broken test (select DESTROY over MOVE), start writing unit tests for update_long_order

This commit is contained in:
Enno Rehling 2015-08-04 23:04:00 +02:00
parent 4d061d8592
commit 928b9966d0
2 changed files with 21 additions and 8 deletions

View File

@ -3483,15 +3483,15 @@ void update_long_order(unit * u)
}
break;
default:
#ifdef TODO // TODO: decide https://bugs.eressea.de/view.php?id=2080#c6011
if (kwd < thiskwd) {
/* swap thisorder for the new one */
order *tmp = ord;
ord = u->thisorder;
u->thisorder = tmp;
// TODO: decide https://bugs.eressea.de/view.php?id=2080#c6011
if (kwd > thiskwd) {
// swap out thisorder for the new one
cmistake(u, u->thisorder, 52, MSG_EVENT);
set_order(&u->thisorder, copy_order(ord));
}
else {
cmistake(u, ord, 52, MSG_EVENT);
}
#endif
cmistake(u, ord, 52, MSG_EVENT);
break;
}
}

View File

@ -768,9 +768,22 @@ static void test_luck_message(CuTest *tc) {
test_cleanup();
}
static void test_update_long_order(CuTest *tc) {
// TODO: write more tests
unit *u;
test_cleanup();
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
update_long_order(u);
CuAssertPtrEquals(tc, 0, u->thisorder);
CuAssertPtrEquals(tc, 0, u->orders);
CuAssertPtrEquals(tc, 0, u->old_orders);
test_cleanup();
}
CuSuite *get_laws_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_update_long_order);
SUITE_ADD_TEST(suite, test_new_building_can_be_renamed);
SUITE_ADD_TEST(suite, test_rename_building);
SUITE_ADD_TEST(suite, test_rename_building_twice);