memory leak: tests should call cleanup instead of trying to restore original state

This commit is contained in:
Enno Rehling 2015-10-14 12:05:29 +02:00
parent acda22ae1b
commit 2b59922d8d
1 changed files with 3 additions and 9 deletions

View File

@ -724,30 +724,24 @@ static void statistic_test(CuTest *tc, int peasants, int luck, int maxp,
}
static void test_peasant_luck_effect(CuTest *tc) {
const char *plf = get_param(global.parameters, "rules.peasants.peasantluck.factor");
const char *gf = get_param(global.parameters, "rules.peasants.growth.factor");
test_cleanup();
set_param(&global.parameters, "rules.peasants.peasantluck.factor", "10");
set_param(&global.parameters, "rules.peasants.growth.factor", "0.001");
statistic_test(tc, 100, 0, 1000, 0, 0, 0);
statistic_test(tc, 100, 2, 1000, 0, 1, 1);
/*
statistic_test(tc, 1000, 400, 1000, 0, (int)(400 * 10 * 0.001 * .75),
(int)(400 * 10 * 0.001 * .75));
*/
statistic_test(tc, 1000, 400, 1000, 0, 3, 3);
statistic_test(tc, 1000, 1000, 2000, .5, 1, 501);
set_param(&global.parameters, "rules.peasants.growth.factor", "1");
statistic_test(tc, 1000, 1000, 1000, 0, 501, 501);
set_param(&global.parameters, "rules.peasants.peasantluck.factor", plf);
set_param(&global.parameters, "rules.peasants.growth.factor", gf);
test_cleanup();
}
static void test_luck_message(CuTest *tc) {
region* r;
test_cleanup();
r = test_create_region(0, 0, NULL);
rsetpeasants(r, 1);