From a23ef5ddf9324c0d5316ced36ffa1f3d6a8a1bb3 Mon Sep 17 00:00:00 2001 From: thibault perrier Date: Thu, 20 Jan 2022 16:53:09 +0100 Subject: [PATCH] edit test_game_equal --- game_test_thperrier.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/game_test_thperrier.c b/game_test_thperrier.c index df8afec..80ae02d 100644 --- a/game_test_thperrier.c +++ b/game_test_thperrier.c @@ -116,9 +116,21 @@ bool test_game_delete() { /* ********** game_equal ********** */ bool test_game_equal() { + square tab_square[] = {S_BLANK, S_LIGHTBULB, S_MARK, S_BLACK0, S_BLACK1, S_BLACK2, S_BLACK3, S_BLACK4, S_BLACKU}; bool equal = true; + uint index_tab = 0; game g1 = game_new_empty(); - game g2 = game_new_empty(); + for (int i = 0; i < DEFAULT_SIZE; i++) { + for (int j = 0; j < DEFAULT_SIZE; j++) { + // check if index_tab reach end of tab + if (index_tab == sizeof(tab_square) / sizeof(tab_square[0])) { + index_tab = 0; + } + game_set_square(g1, i, j, tab_square[index_tab]); + index_tab++; + } + } + game g2 = game_copy(g1); for (int i = 0; i < DEFAULT_SIZE; i++) { for (int j = 0; j < DEFAULT_SIZE; j++) { if (game_get_square(g1, i, j) != game_get_square(g2, i, j)) { @@ -135,7 +147,6 @@ bool test_game_equal() { /* ********** game_new_empty ********** */ bool test_game_new_empty() { game g = game_new_empty(); - assert(g); for (int i = 0; i < g->height; i++) { for (int j = 0; j < g->width; j++) { if (game_get_square(g, i, j) != S_BLANK) {