convert another test to read_/write_game

This commit is contained in:
Enno Rehling 2016-02-26 19:01:28 +01:00
parent 3c272fd53f
commit 63408501b9
2 changed files with 15 additions and 7 deletions

View File

@ -1540,8 +1540,8 @@ int read_game(gamedata *data) {
global.data_turn = turn;
log_debug(" - reading turn %d\n", turn);
rng_init(turn);
READ_INT(store, &nread); /* max_unique_id = ignore */
READ_INT(store, &nextborder);
READ_INT(store, NULL); /* max_unique_id = ignore */
READ_INT(store, NULL);
/* Planes */
planes = NULL;
@ -1619,7 +1619,7 @@ int read_game(gamedata *data) {
/* Regionen */
READ_INT(store, &nread);
assert(nread < MAXREGIONS);
assert(nread < MAXREGIONS && nread>=0);
if (rmax < 0) {
rmax = nread;
}
@ -1883,8 +1883,8 @@ int write_game(gamedata *data) {
WRITE_SECTION(store);
WRITE_INT(store, turn);
WRITE_INT(store, 0 /*max_unique_id */);
WRITE_INT(store, nextborder);
WRITE_INT(store, 0 /* max_unique_id */);
WRITE_INT(store, 0 /* nextborder */);
/* Write planes */
WRITE_SECTION(store);

View File

@ -152,6 +152,11 @@ static void test_readwrite_dead_faction_group(CuTest *tc) {
static void test_readwrite_dead_faction_regionowner(CuTest *tc) {
faction *f;
region *r;
gamedata data;
storage store;
mstream_init(&data.strm);
gamedata_init(&data, &store, RELEASE_VERSION);
test_cleanup();
config_set("rules.region_owners", "1");
@ -161,10 +166,13 @@ static void test_readwrite_dead_faction_regionowner(CuTest *tc) {
destroyfaction(&factions);
CuAssertTrue(tc, !f->_alive);
remove_empty_units();
writegame("test.dat");
write_game(&data);
free_gamedata();
f = NULL;
readgame("test.dat", false);
data.strm.api->rewind(data.strm.handle);
read_game(&data);
mstream_done(&data.strm);
gamedata_done(&data);
f = factions;
CuAssertPtrEquals(tc, 0, f);
r = regions;