ajout test_game_new_empty + modification CMakeList

This commit is contained in:
Thibault Perrier committed 2021-11-10 18:12:26 +01:00
1 parent 88273a1c33
commit 9e0192960b
2 files changed
+24 -1

No files matched your search

+22
View File
@@ -2,11 +2,30 @@
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include "game.h"
#include "game_aux.c"
/* ********** DUMMY ********** */
bool test_dummy(){
return true;
}
/* ********** game_new_empty ********** */
bool test_game_new_empty(){
game g = game_new_empty();
assert(g);
for (int i = 0; i < DEFAULT_SIZE; i++){
for (int j = 0; j < DEFAULT_SIZE; j++){
if (game_get_flags(g, i, j) != S_BLANK){
game_delete(g);
return false;
}
}
}
game_delete(g);
return true;
}
void usage(int argc, char *argv[]){
fprintf(stderr, "Usage: %s <testname>\n", argv[0]);
@@ -21,6 +40,9 @@ int main (int argc, char *argv[]){
else if (strcmp("dummy", argv[1]) == 0){
success = test_dummy();
}
else if (strcmp("game_new_empty", argv[1]) == 0){
success = test_game_new_empty();
}
else{
fprintf (stderr, "test \"%s\" is not a valid test name.\n", argv[1]);
return EXIT_FAILURE;