init: tests

This commit is contained in:
Mylloon 2022-12-04 18:06:01 +01:00
parent 2db2ce9a26
commit 652b718b2b
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 21 additions and 5 deletions

7
includes/test.h Normal file
View file

@ -0,0 +1,7 @@
#ifndef OTHELLO_TEST_H
#define OTHELLO_TEST_H 1
/* Run the tests */
void run_tests(void);
#endif

View file

@ -1,7 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include "../includes/jeu.h"
#include "../includes/test.h"
/* Affiche un message d'aide */
void help(char const progName[]);
@ -23,10 +23,15 @@ int main(int argc, char const *argv[]) {
help(argv[0]);
exit(EXIT_SUCCESS);
} else {
fprintf(stderr, "Il manque des arguments.\n");
// Affichage du message d'aide
help(argv[0]);
exit(EXIT_FAILURE);
if (strcmp(argv[1], "--test") == 0 || strcmp(argv[1], "-t") == 0) {
run_tests();
exit(EXIT_SUCCESS);
} else {
fprintf(stderr, "Il manque des arguments.\n");
// Affichage du message d'aide
help(argv[0]);
exit(EXIT_FAILURE);
}
}
}
if (argc == 3) { // s'il y a 2 arguments
@ -96,6 +101,7 @@ void help(char const progName[]) {
"\t\t\t\t- alphabeta\t - a\n"
"\t\t\t\t=> exemple : %s humain alphabeta\n",
progName, progName);
printf("-> %s -t, --test || Test l'efficacité des IA.\n", progName);
printf("-> %s -h, --help || Affiche ce message d'aide.\n", progName);
printf("==============================================================\n");
}

3
src/test.c Normal file
View file

@ -0,0 +1,3 @@
#include "../includes/test.h"
void run_tests(void) {}