forked from github/server
remove datafiles from save.test.c
this should fix intermittent tests on windows.
This commit is contained in:
parent
63408501b9
commit
5f923295e6
|
@ -182,6 +182,8 @@ static void test_readwrite_dead_faction_regionowner(CuTest *tc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_readwrite_dead_faction_changefaction(CuTest *tc) {
|
static void test_readwrite_dead_faction_changefaction(CuTest *tc) {
|
||||||
|
gamedata data;
|
||||||
|
storage store;
|
||||||
faction *f, *f2;
|
faction *f, *f2;
|
||||||
region *r;
|
region *r;
|
||||||
trigger *tr;
|
trigger *tr;
|
||||||
|
@ -197,10 +199,15 @@ static void test_readwrite_dead_faction_changefaction(CuTest *tc) {
|
||||||
destroyfaction(&factions);
|
destroyfaction(&factions);
|
||||||
CuAssertTrue(tc, !f->_alive);
|
CuAssertTrue(tc, !f->_alive);
|
||||||
remove_empty_units();
|
remove_empty_units();
|
||||||
writegame("test.dat");
|
mstream_init(&data.strm);
|
||||||
|
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||||
|
write_game(&data);
|
||||||
free_gamedata();
|
free_gamedata();
|
||||||
f = NULL;
|
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;
|
f = factions;
|
||||||
CuAssertPtrNotNull(tc, f);
|
CuAssertPtrNotNull(tc, f);
|
||||||
r = regions;
|
r = regions;
|
||||||
|
@ -212,6 +219,8 @@ static void test_readwrite_dead_faction_changefaction(CuTest *tc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_readwrite_dead_faction_createunit(CuTest *tc) {
|
static void test_readwrite_dead_faction_createunit(CuTest *tc) {
|
||||||
|
gamedata data;
|
||||||
|
storage store;
|
||||||
faction *f, *f2;
|
faction *f, *f2;
|
||||||
region *r;
|
region *r;
|
||||||
trigger *tr;
|
trigger *tr;
|
||||||
|
@ -227,10 +236,15 @@ static void test_readwrite_dead_faction_createunit(CuTest *tc) {
|
||||||
destroyfaction(&factions);
|
destroyfaction(&factions);
|
||||||
CuAssertTrue(tc, !f->_alive);
|
CuAssertTrue(tc, !f->_alive);
|
||||||
remove_empty_units();
|
remove_empty_units();
|
||||||
writegame("test.dat");
|
mstream_init(&data.strm);
|
||||||
|
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||||
|
write_game(&data);
|
||||||
free_gamedata();
|
free_gamedata();
|
||||||
f = NULL;
|
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;
|
f = factions;
|
||||||
CuAssertPtrNotNull(tc, f);
|
CuAssertPtrNotNull(tc, f);
|
||||||
r = regions;
|
r = regions;
|
||||||
|
@ -242,26 +256,26 @@ static void test_readwrite_dead_faction_createunit(CuTest *tc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_read_password(CuTest *tc) {
|
static void test_read_password(CuTest *tc) {
|
||||||
const char *path = "test.dat";
|
gamedata data;
|
||||||
gamedata *data;
|
storage store;
|
||||||
faction *f;
|
faction *f;
|
||||||
|
|
||||||
f = test_create_faction(0);
|
f = test_create_faction(0);
|
||||||
faction_setpassword(f, password_encode("secret", PASSWORD_DEFAULT));
|
faction_setpassword(f, password_encode("secret", PASSWORD_DEFAULT));
|
||||||
data = gamedata_open(path, "wb", RELEASE_VERSION);
|
mstream_init(&data.strm);
|
||||||
CuAssertPtrNotNull(tc, data);
|
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||||
_test_write_password(data, f);
|
_test_write_password(&data, f);
|
||||||
gamedata_close(data);
|
data.strm.api->rewind(data.strm.handle);
|
||||||
data = gamedata_open(path, "rb", RELEASE_VERSION);
|
_test_read_password(&data, f);
|
||||||
CuAssertPtrNotNull(tc, data);
|
mstream_done(&data.strm);
|
||||||
_test_read_password(data, f);
|
gamedata_done(&data);
|
||||||
gamedata_close(data);
|
|
||||||
CuAssertTrue(tc, checkpasswd(f, "secret"));
|
CuAssertTrue(tc, checkpasswd(f, "secret"));
|
||||||
CuAssertIntEquals(tc, 0, remove(path));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_read_password_external(CuTest *tc) {
|
static void test_read_password_external(CuTest *tc) {
|
||||||
const char *path = "test.dat", *pwfile = "passwords.txt";
|
gamedata data;
|
||||||
gamedata *data;
|
storage store;
|
||||||
|
const char *pwfile = "passwords.txt";
|
||||||
faction *f;
|
faction *f;
|
||||||
FILE * F;
|
FILE * F;
|
||||||
|
|
||||||
|
@ -269,24 +283,21 @@ static void test_read_password_external(CuTest *tc) {
|
||||||
f = test_create_faction(0);
|
f = test_create_faction(0);
|
||||||
faction_setpassword(f, password_encode("secret", PASSWORD_DEFAULT));
|
faction_setpassword(f, password_encode("secret", PASSWORD_DEFAULT));
|
||||||
CuAssertPtrNotNull(tc, f->_password);
|
CuAssertPtrNotNull(tc, f->_password);
|
||||||
data = gamedata_open(path, "wb", RELEASE_VERSION);
|
mstream_init(&data.strm);
|
||||||
CuAssertPtrNotNull(tc, data);
|
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||||
WRITE_TOK(data->store, (const char *)f->_password);
|
WRITE_TOK(data.store, (const char *)f->_password);
|
||||||
WRITE_TOK(data->store, (const char *)f->_password);
|
WRITE_TOK(data.store, (const char *)f->_password);
|
||||||
gamedata_close(data);
|
data.strm.api->rewind(data.strm.handle);
|
||||||
data = gamedata_open(path, "rb", RELEASE_VERSION);
|
data.version = BADCRYPT_VERSION;
|
||||||
CuAssertPtrNotNull(tc, data);
|
_test_read_password(&data, f);
|
||||||
data->version = BADCRYPT_VERSION;
|
|
||||||
_test_read_password(data, f);
|
|
||||||
CuAssertPtrEquals(tc, 0, f->_password);
|
CuAssertPtrEquals(tc, 0, f->_password);
|
||||||
F = fopen(pwfile, "wt");
|
F = fopen(pwfile, "wt");
|
||||||
fprintf(F, "%s:secret\n", itoa36(f->no));
|
fprintf(F, "%s:secret\n", itoa36(f->no));
|
||||||
fclose(F);
|
fclose(F);
|
||||||
_test_read_password(data, f);
|
_test_read_password(&data, f);
|
||||||
CuAssertPtrNotNull(tc, f->_password);
|
CuAssertPtrNotNull(tc, f->_password);
|
||||||
gamedata_close(data);
|
gamedata_done(&data);
|
||||||
CuAssertTrue(tc, checkpasswd(f, "secret"));
|
CuAssertTrue(tc, checkpasswd(f, "secret"));
|
||||||
CuAssertIntEquals(tc, 0, remove(path));
|
|
||||||
CuAssertIntEquals(tc, 0, remove(pwfile));
|
CuAssertIntEquals(tc, 0, remove(pwfile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue