running the test 1000 times should not change the result.

if it does, that is because it depends on state (of the random number generator), which is bad and needs to be fixed if it makes the test intermittent.
This commit is contained in:
Enno Rehling 2015-05-24 11:32:16 +02:00
parent 8674fc18c7
commit 6260a45be5
1 changed files with 6 additions and 7 deletions

View File

@ -696,13 +696,12 @@ static void test_reserve_self(CuTest *tc) {
static void statistic_test(CuTest *tc, int peasants, int luck, int maxp,
double variance, int min_value, int max_value) {
int effect, i;
for (i = 0; i < 1000; ++i) {
int effect;
effect = peasant_luck_effect(peasants, luck, maxp, variance);
CuAssertTrue(tc, min_value <= effect);
CuAssertTrue(tc, max_value >= effect);
}
}
static void test_peasant_luck_effect(CuTest *tc) {
const char *plf = get_param(global.parameters, "rules.peasants.peasantluck.factor");
@ -780,7 +779,7 @@ CuSuite *get_laws_suite(void)
SUITE_ADD_TEST(suite, test_force_leave_buildings);
SUITE_ADD_TEST(suite, test_force_leave_ships);
SUITE_ADD_TEST(suite, test_force_leave_ships_on_ocean);
DISABLE_TEST(suite, test_peasant_luck_effect);
SUITE_ADD_TEST(suite, test_peasant_luck_effect);
SUITE_ADD_TEST(suite, test_luck_message);
return suite;