add (failing) test for recruiting into existing units.

This commit is contained in:
Enno Rehling 2016-09-18 11:34:54 +02:00
parent 18fcba3ed6
commit b3c31856aa
3 changed files with 19 additions and 2 deletions

View File

@ -244,7 +244,7 @@ static recruitment *select_recruitment(request ** rop,
return recruits; return recruits;
} }
static void add_recruits(unit * u, int number, int wanted) void add_recruits(unit * u, int number, int wanted)
{ {
region *r = u->region; region *r = u->region;
assert(number <= wanted); assert(number <= wanted);

View File

@ -61,7 +61,7 @@ extern "C" {
void give_control(struct unit * u, struct unit * u2); void give_control(struct unit * u, struct unit * u2);
void tax_cmd(struct unit * u, struct order *ord, struct request ** taxorders); void tax_cmd(struct unit * u, struct order *ord, struct request ** taxorders);
void expandtax(struct region * r, struct request * taxorders); void expandtax(struct region * r, struct request * taxorders);
void add_recruits(struct unit * u, int number, int wanted);
struct message * check_steal(const struct unit * u, struct order *ord); struct message * check_steal(const struct unit * u, struct order *ord);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -290,6 +290,22 @@ static void test_maintain_buildings(CuTest *tc) {
test_cleanup(); test_cleanup();
} }
static void test_recruit(CuTest *tc) {
unit *u;
faction *f;
test_setup();
f = test_create_faction(0);
u = test_create_unit(f, test_create_region(0, 0, 0));
CuAssertIntEquals(tc, 1, u->number);
add_recruits(u, 1, 1);
CuAssertIntEquals(tc, 2, u->number);
CuAssertPtrEquals(tc, u, f->units);
CuAssertPtrEquals(tc, NULL, u->nextF);
CuAssertPtrEquals(tc, NULL, u->prevF);
test_cleanup();
}
CuSuite *get_economy_suite(void) CuSuite *get_economy_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
@ -302,5 +318,6 @@ CuSuite *get_economy_suite(void)
SUITE_ADD_TEST(suite, test_heroes_dont_recruit); SUITE_ADD_TEST(suite, test_heroes_dont_recruit);
SUITE_ADD_TEST(suite, test_tax_cmd); SUITE_ADD_TEST(suite, test_tax_cmd);
SUITE_ADD_TEST(suite, test_maintain_buildings); SUITE_ADD_TEST(suite, test_maintain_buildings);
SUITE_ADD_TEST(suite, test_recruit);
return suite; return suite;
} }