Merge branch 'main' of gitlab.emi.u-bordeaux.fr:pt2/teams/a42/lightup-a42e

This commit is contained in:
Théophyl Hoguet committed 2021-11-30 14:55:38 +01:00
commit f3bfddcf13
3 files changed
+112 -5

No files matched your search

+1 -1
View File
@@ -47,7 +47,7 @@ add_test(test_thperrier_game_is_black ./game_test_thperrier game_is_black)
add_test(test_thperrier_game_get_black_number ./game_test_thperrier game_get_black_number)
add_test(test_nnunes_dummy ./game_test_nnunes dummy)
add_test(test_nnunes_game_get_square ./game_test_nnunes game_get_square)
add_test(test_nnunes_game_set_square ./game_test_nnunes game_set_square)
add_test(test_nnunes_game_get_state ./game_test_nnunes game_get_state)
add_test(test_nnunes_game_get_flags ./game_test_nnunes game_get_flags)
add_test(test_nnunes_game_is_marked ./game_test_nnunes game_is_marked)
+107
View File
@@ -73,6 +73,113 @@ void game_delete(game g) {
}
void game_set_square(game g, uint i, uint j, square s) {
if (s == S_BLANK) {
g->tab_cell[i][j] = S_BLANK;
return;
}
if (s == S_LIGHTBULB) {
g->tab_cell[i][j] = S_LIGHTBULB;
return;
}
if (s == S_MARK) {
g->tab_cell[i][j] = S_MARK;
return;
}
if (s == S_BLACK) {
g->tab_cell[i][j] = S_BLACK;
return;
}
if (s == S_BLACK0) {
g->tab_cell[i][j] = S_BLACK0;
return;
}
if (s == S_BLACK1) {
g->tab_cell[i][j] = S_BLACK1;
return;
}
if (s == S_BLACK2) {
g->tab_cell[i][j] = S_BLACK2;
return;
}
if (s == S_BLACK3) {
g->tab_cell[i][j] = S_BLACK3;
return;
}
if (s == S_BLACK4) {
g->tab_cell[i][j] = S_BLACK4;
return;
}
if (s == S_BLACKU) {
g->tab_cell[i][j] = S_BLACKU;
return;
}
// Avec F_LIGHTED //
if (s == (S_BLANK|F_LIGHTED)) {
g->tab_cell[i][j] = (S_BLANK|F_LIGHTED);
return;
}
if (s == (S_LIGHTBULB|F_LIGHTED)) {
g->tab_cell[i][j] = (S_LIGHTBULB|F_LIGHTED);
return;
}
if (s == (S_MARK|F_LIGHTED)) {
g->tab_cell[i][j] = (S_MARK|F_LIGHTED);
return;
}
// Avec F_ERROR //
if (s == (S_BLANK|F_ERROR)) {
g->tab_cell[i][j] = (S_BLANK|F_ERROR);
return;
}
if (s == (S_LIGHTBULB|F_ERROR)) {
g->tab_cell[i][j] = (S_LIGHTBULB|F_ERROR);
return;
}
if (s == (S_MARK|F_ERROR)) {
g->tab_cell[i][j] = (S_MARK|F_ERROR);
return;
}
if (s == (S_BLACK|F_ERROR)) {
g->tab_cell[i][j] = (S_BLACK|F_ERROR);
return;
}
if (s == (S_BLACK0|F_ERROR)) {
g->tab_cell[i][j] = (S_BLACK0|F_ERROR);
return;
}
if (s == (S_BLACK1|F_ERROR)) {
g->tab_cell[i][j] = (S_BLACK1|F_ERROR);
return;
}
if (s == (S_BLACK2|F_ERROR)) {
g->tab_cell[i][j] = (S_BLACK2|F_ERROR);
return;
}
if (s == (S_BLACK3|F_ERROR)) {
g->tab_cell[i][j] = (S_BLACK3|F_ERROR);
return;
}
if (s == (S_BLACK4|F_ERROR)) {
g->tab_cell[i][j] = (S_BLACK4|F_ERROR);
return;
}
if (s == (S_BLACKU|F_ERROR)) {
g->tab_cell[i][j] = (S_BLACKU|F_ERROR);
return;
}
// Avec les 2 flags //
if (s == (S_BLANK|F_LIGHTED|F_ERROR)) {
g->tab_cell[i][j] = (S_BLANK|F_LIGHTED|F_ERROR);
return;
}
if (s == (S_LIGHTBULB|F_LIGHTED|F_ERROR)) {
g->tab_cell[i][j] = (S_LIGHTBULB|F_LIGHTED|F_ERROR);
return;
}
if (s == (S_MARK|F_LIGHTED|F_ERROR)) {
g->tab_cell[i][j] = (S_MARK|F_LIGHTED|F_ERROR);
return;
}
return;
}
+4 -4
View File
@@ -15,8 +15,8 @@ void usage(int argc, char* argv[]) {
exit(EXIT_FAILURE);
}
/* ************** game_get_square ************** */
bool test_game_get_square(void) {
/* ************** game_set_square ************** */
bool test_game_set_square(void) {
game g = game_new_empty();
game_set_square(g, 0, 0, S_LIGHTBULB);
if (game_get_square(g, 0, 0) != S_LIGHTBULB) {
@@ -367,8 +367,8 @@ int main(int argc, char* argv[]) {
bool success = false;
if (strcmp("dummy", argv[1]) == 0)
success = test_dummy();
else if (strcmp("game_get_square", argv[1]) == 0) {
success = test_game_get_square();
else if (strcmp("game_set_square", argv[1]) == 0) {
success = test_game_set_square();
} else if (strcmp("game_get_state", argv[1]) == 0) {
success = test_game_get_state();
} else if (strcmp("game_get_flags", argv[1]) == 0) {