forked from github/server
testing that remove_unit takes unit out of the world properly.
there is more to it than this, but I'd be happy with the dfindhash check for now.
This commit is contained in:
parent
fdb5ecc68b
commit
3e2c630c3f
|
@ -401,6 +401,34 @@ static void test_unit_description(CuTest *tc) {
|
|||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_remove_unit(CuTest *tc) {
|
||||
region *r;
|
||||
unit *u;
|
||||
faction *f;
|
||||
int uno;
|
||||
const resource_type *rtype;
|
||||
|
||||
test_setup();
|
||||
init_resources();
|
||||
rtype = get_resourcetype(R_SILVER);
|
||||
r = test_create_region(0, 0, 0);
|
||||
f = test_create_faction(0);
|
||||
u = test_create_unit(f, r);
|
||||
uno = u->no;
|
||||
region_setresource(r, rtype, 0);
|
||||
i_change(&u->items, rtype->itype, 100);
|
||||
remove_unit(&r->units, u);
|
||||
CuAssertIntEquals(tc, 100, region_getresource(r, rtype));
|
||||
CuAssertIntEquals(tc, 0, u->number);
|
||||
CuAssertPtrEquals(tc, 0, u->region);
|
||||
CuAssertPtrEquals(tc, 0, u->items);
|
||||
CuAssertPtrEquals(tc, 0, u->faction);
|
||||
CuAssertPtrEquals(tc, 0, r->units);
|
||||
CuAssertPtrEquals(tc, 0, findunit(uno));
|
||||
CuAssertPtrEquals(tc, f, dfindhash(uno));
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
CuSuite *get_unit_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
|
@ -409,6 +437,7 @@ CuSuite *get_unit_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_unit_name);
|
||||
SUITE_ADD_TEST(suite, test_unit_name_from_race);
|
||||
SUITE_ADD_TEST(suite, test_update_monster_name);
|
||||
SUITE_ADD_TEST(suite, test_remove_unit);
|
||||
SUITE_ADD_TEST(suite, test_remove_empty_units);
|
||||
SUITE_ADD_TEST(suite, test_remove_units_ignores_spells);
|
||||
SUITE_ADD_TEST(suite, test_remove_units_without_faction);
|
||||
|
|
Loading…
Reference in New Issue