ajout test_game_new_empty + modification CMakeList
This commit is contained in:
1 parent
88273a1c33
commit
9e0192960b
2 files changed
+23
No files matched your search
@@ -27,3 +27,4 @@ add_test(test_thoguet_default ./game_test_thoguet game_default)
|
|||||||
add_test(test_thoguet_game_default_solution ./game_test_thoguet game_default_solution)
|
add_test(test_thoguet_game_default_solution ./game_test_thoguet game_default_solution)
|
||||||
|
|
||||||
add_test(test_thperrier_dummy ./game_test_thperrier dummy)
|
add_test(test_thperrier_dummy ./game_test_thperrier dummy)
|
||||||
|
add_test(test_thperrier_game_new_empty ./game_test_thperrier game_new_empty)
|
||||||
@@ -2,11 +2,30 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "game.h"
|
||||||
|
#include "game_aux.c"
|
||||||
|
|
||||||
|
|
||||||
|
/* ********** DUMMY ********** */
|
||||||
bool test_dummy(){
|
bool test_dummy(){
|
||||||
return true;
|
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[]){
|
void usage(int argc, char *argv[]){
|
||||||
fprintf(stderr, "Usage: %s <testname>\n", argv[0]);
|
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){
|
else if (strcmp("dummy", argv[1]) == 0){
|
||||||
success = test_dummy();
|
success = test_dummy();
|
||||||
}
|
}
|
||||||
|
else if (strcmp("game_new_empty", argv[1]) == 0){
|
||||||
|
success = test_game_new_empty();
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
fprintf (stderr, "test \"%s\" is not a valid test name.\n", argv[1]);
|
fprintf (stderr, "test \"%s\" is not a valid test name.\n", argv[1]);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|||||||
Reference in new issue
Block a user