add test flags game save
This commit is contained in:
1 parent
df4da02bc0
commit
8d4e701b1b
1 file changed
+17
-1
+17
-1
@@ -1085,6 +1085,22 @@ bool test_game_save(bool whoami, char** name) {
|
||||
}
|
||||
game_delete(gdefault);
|
||||
fclose(f_gdefault);
|
||||
// test if flags aren't saved by game_save
|
||||
game gdefault_sol = game_default();
|
||||
game_save(gdefault_sol, "gdefault_sol.txt");
|
||||
// try to open the created save file
|
||||
FILE* f_gdefault_sol = fopen("gdefault_sol.txt", "r");
|
||||
assert(f_gdefault_sol);
|
||||
// explore default_str and test if each char of the saved file == char of default_str
|
||||
for (uint index_default_str = 0;
|
||||
index_default_str < game_nb_cols(gdefault_sol) * game_nb_rows(gdefault_sol) + NB_CHAR_SAVED_FILE_FIRST_LINE + game_nb_rows(gdefault_sol);
|
||||
index_default_str++) {
|
||||
int char_to_test = fgetc(f_gdefault_sol);
|
||||
assert(char_to_test != -1);
|
||||
assert((char)char_to_test == default_str[index_default_str]);
|
||||
}
|
||||
game_delete(gdefault_sol);
|
||||
fclose(f_gdefault_sol);
|
||||
// do the same as gdefault but with ext_5x3w_squares
|
||||
game g5x3w = game_new_ext(5, 3, ext_5x3w_squares, true);
|
||||
game_save(g5x3w, "g5x3w.txt");
|
||||
@@ -1154,7 +1170,7 @@ bool test_game_load(bool whoami, char** name) {
|
||||
/* ********** USAGE ********** */
|
||||
|
||||
int usage(char* argv[]) {
|
||||
fprintf(stderr, "Usage: %s <testname> [<...>]\n", argv[0]);
|
||||
fprintf(stderr, "Usage: %s <testname>\n", argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user