From 723c3df7b2f3626991d071766dd7c1138e1db45e Mon Sep 17 00:00:00 2001 From: Steffen Mecke Date: Mon, 7 Dec 2015 19:41:34 +0100 Subject: [PATCH] test for immigration --- src/laws.test.c | 38 ++++++++++++++++++++++++++++++++++++++ src/randenc.c | 1 + 2 files changed, 39 insertions(+) diff --git a/src/laws.test.c b/src/laws.test.c index 12c4e93f4..91b04b257 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1258,6 +1258,43 @@ static void test_show_without_item(CuTest *tc) test_cleanup(); } +static int low_wage(const region * r, const faction * f, const race * rc, int in_turn) { + return 1; +} + +static void test_immigration(CuTest * tc) +{ + region *r; + double inject[] = { 1 }; + int (*old_wage)(const region*, const faction*, const race*, int) = global.functions.wage; + + test_cleanup(); + test_create_world(); + r = findregion(0, 0); + + rsetpeasants(r, 0); + config_set("rules.economy.repopulate_maximum", 0); + + random_source_inject_constant(0); + + immigration(); + CuAssertIntEquals(tc, 0, rpeasants(r)); + + random_source_inject_constant(1); + + immigration(); + CuAssertIntEquals(tc, 2, rpeasants(r)); + + random_source_inject_array(inject, 2); + + global.functions.wage = low_wage; + immigration(); + CuAssertIntEquals(tc, 2, rpeasants(r)); + global.functions.wage = old_wage; + + test_cleanup(); +} + CuSuite *get_laws_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -1316,6 +1353,7 @@ CuSuite *get_laws_suite(void) SUITE_ADD_TEST(suite, test_name_building); SUITE_ADD_TEST(suite, test_name_ship); SUITE_ADD_TEST(suite, test_show_without_item); + SUITE_ADD_TEST(suite, test_immigration); return suite; } diff --git a/src/randenc.c b/src/randenc.c index 7f27fed4d..d948ea270 100644 --- a/src/randenc.c +++ b/src/randenc.c @@ -604,6 +604,7 @@ volcano_destruction(region * volcano, region * r, const char *damage) unit *u = *up; if (u->number) { int dead = damage_unit(u, damage, true, false); + /* TODO create undead */ if (dead) { ADDMSG(&u->faction->msgs, msg_message("volcano_dead", "unit region dead", u, volcano, dead));