test gameisover

This commit is contained in:
Theophyl Hoguet committed 2021-11-10 22:49:28 +01:00
1 parent 43ebf0e4ce
commit 05c9cdc127
2 files changed
+21

No files matched your search

+1
View File
@@ -28,6 +28,7 @@ add_test(test_thoguet_get_square ./game_test_thoguet game_get_square)
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_game_restart ./game_test_thoguet game_restart)
add_test(test_game_is_over ./game_test_thoguet game_is_over)
add_test(test_thperrier_dummy ./game_test_thperrier dummy)
add_test(test_thperrier_game_new_empty ./game_test_thperrier game_new_empty)
+20
View File
@@ -12,6 +12,24 @@ bool test_dummy(void){
return EXIT_SUCCESS;
}
/* ******* game_is_over ******* */
bool test_game_is_over(void){
square tab[49] =
{
S_LIGHTBULB,S_BLANK ,S_BLACK1 ,S_LIGHTBULB,S_BLANK ,S_BLANK ,S_BLANK ,
S_BLANK ,S_LIGHTBULB,S_BLACK2 ,S_BLANK ,S_BLANK ,S_BLANK ,S_LIGHTBULB,
S_BLANK ,S_BLANK ,S_LIGHTBULB,S_BLANK ,S_BLANK ,S_BLACKU ,S_BLACK2 ,
S_BLANK ,S_BLANK ,S_BLANK ,S_BLANK ,S_BLANK ,S_BLANK ,S_LIGHTBULB,
S_BLACK1 ,S_BLACKU ,S_BLANK ,S_BLANK ,S_LIGHTBULB,S_BLANK ,S_BLANK ,
S_LIGHTBULB,S_BLANK ,S_BLANK ,S_BLANK ,S_BLACK2 ,S_LIGHTBULB,S_BLANK ,
S_BLANK ,S_LIGHTBULB,S_BLANK ,S_BLANK ,S_BLACKU ,S_BLANK ,S_BLANK
};
game g = game_new(tab);
game_update_flags(g);
assert(game_is_over(g));
return EXIT_SUCCESS;
}
/* ******* game_restart ******* */
bool test_game_restart(void){
@@ -156,6 +174,8 @@ int main(int argc, char * argv[]){
ok = test_game_restart();
else if (strcmp("game_get_square", argv[1]) == 0)
ok = test_game_get_square();
else if (strcmp("game_is_over", argv[1]) == 0)
ok = test_game_is_over();
else {
fprintf(stderr, "Error: test \"%s\" not found!\n", argv[1]);
exit(EXIT_FAILURE);