reset turn to 0 before and after each test.

save tests that depend on the global turn variable would fail when being run out of order.
this cause issue #560
This commit is contained in:
Enno Rehling 2016-09-08 19:48:36 +02:00
parent a281ace21b
commit ab876431de
3 changed files with 10 additions and 7 deletions

View File

@ -623,6 +623,7 @@ static void write_owner(struct gamedata *data, region_owner * owner)
if (owner) {
faction *f;
WRITE_INT(data->store, owner->since_turn);
if (owner->since_turn >= 0) {
WRITE_INT(data->store, owner->morale_turn);
WRITE_INT(data->store, owner->flags);
f = owner->last_owner;
@ -630,6 +631,7 @@ static void write_owner(struct gamedata *data, region_owner * owner)
f = owner->owner;
write_faction_reference((f && f->_alive) ? f : NULL, data->store);
}
}
else {
WRITE_INT(data->store, -1);
}

View File

@ -162,7 +162,7 @@ static void test_readwrite_dead_faction_regionowner(CuTest *tc) {
config_set("rules.region_owners", "1");
f = test_create_faction(0);
test_create_unit(f, r = test_create_region(0, 0, 0));
region_set_owner(r, f, turn);
region_set_owner(r, f, 0);
destroyfaction(&factions);
CuAssertTrue(tc, !f->_alive);
remove_empty_units();

View File

@ -161,6 +161,7 @@ void test_log_stderr(int flags) {
static void test_reset(void) {
int i;
turn = 0;
default_locale = 0;
free_gamedata();
free_terrains();