coquille vide + update test
This commit is contained in:
1 parent
777b419b5c
commit
a2d0b0e4a3
3 files changed
+25
-35
No files matched your search
@@ -7,36 +7,19 @@ struct game_s {
|
|||||||
};
|
};
|
||||||
|
|
||||||
game game_new(square* squares) {
|
game game_new(square* squares) {
|
||||||
game g = (game)malloc(sizeof(game));
|
return NULL;
|
||||||
if (g == NULL) {
|
|
||||||
fprintf(stderr, "not enough memory\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
g->tab_cell = (square**)malloc(sizeof(square**) * DEFAULT_SIZE);
|
|
||||||
if (g->tab_cell == NULL) {
|
|
||||||
fprintf(stderr, "not enough memory\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < DEFAULT_SIZE; i++) {
|
|
||||||
g->tab_cell[i] = (square*)malloc(sizeof(square*) * DEFAULT_SIZE);
|
|
||||||
if (g->tab_cell[i] == NULL) {
|
|
||||||
fprintf(stderr, "not enough memory\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return g;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
game game_new_empty(void) {
|
game game_new_empty(void) {
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
game game_copy(cgame g) {
|
game game_copy(cgame g) {
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool game_equal(cgame g1, cgame g2) {
|
bool game_equal(cgame g1, cgame g2) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void game_delete(game g) {
|
void game_delete(game g) {
|
||||||
@@ -48,47 +31,47 @@ void game_set_square(game g, uint i, uint j, square s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
square game_get_square(cgame g, uint i, uint j) {
|
square game_get_square(cgame g, uint i, uint j) {
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
square game_get_state(cgame g, uint i, uint j) {
|
square game_get_state(cgame g, uint i, uint j) {
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
square game_get_flags(cgame g, uint i, uint j) {
|
square game_get_flags(cgame g, uint i, uint j) {
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool game_is_blank(cgame g, uint i, uint j) {
|
bool game_is_blank(cgame g, uint i, uint j) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool game_is_lightbulb(cgame g, uint i, uint j) {
|
bool game_is_lightbulb(cgame g, uint i, uint j) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool game_is_black(cgame g, uint i, uint j) {
|
bool game_is_black(cgame g, uint i, uint j) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int game_get_black_number(cgame g, uint i, uint j) {
|
int game_get_black_number(cgame g, uint i, uint j) {
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool game_is_marked(cgame g, uint i, uint j) {
|
bool game_is_marked(cgame g, uint i, uint j) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool game_is_lighted(cgame g, uint i, uint j) {
|
bool game_is_lighted(cgame g, uint i, uint j) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool game_has_error(cgame g, uint i, uint j) {
|
bool game_has_error(cgame g, uint i, uint j) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool game_check_move(cgame g, uint i, uint j, square s) {
|
bool game_check_move(cgame g, uint i, uint j, square s) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void game_play_move(game g, uint i, uint j, square s) {
|
void game_play_move(game g, uint i, uint j, square s) {
|
||||||
@@ -100,7 +83,7 @@ void game_update_flags(game g) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool game_is_over(cgame g) {
|
bool game_is_over(cgame g) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void game_restart(game g) {
|
void game_restart(game g) {
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ bool test_game_print(void) {
|
|||||||
}
|
}
|
||||||
printf("%d\n", i);
|
printf("%d\n", i);
|
||||||
g = game_new(tab);
|
g = game_new(tab);
|
||||||
|
assert(g);
|
||||||
game_print(g);
|
game_print(g);
|
||||||
game_delete(g);
|
game_delete(g);
|
||||||
}
|
}
|
||||||
@@ -398,6 +399,10 @@ bool check_update(game g) {
|
|||||||
bool brutforce(game g, int a, bool* deldup) {
|
bool brutforce(game g, int a, bool* deldup) {
|
||||||
// char c;
|
// char c;
|
||||||
bool* delDupNext = (bool*)calloc(DEFAULT_SIZE * DEFAULT_SIZE, sizeof(bool));
|
bool* delDupNext = (bool*)calloc(DEFAULT_SIZE * DEFAULT_SIZE, sizeof(bool));
|
||||||
|
if (delDupNext == NULL) {
|
||||||
|
fprintf(stderr, "Not enought memory\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
square list[] = {S_LIGHTBULB, S_MARK, S_BLACK0, S_BLACK1, S_BLACK2,
|
square list[] = {S_LIGHTBULB, S_MARK, S_BLACK0, S_BLACK1, S_BLACK2,
|
||||||
S_BLACK3, S_BLACK4, S_BLACKU, S_BLANK};
|
S_BLACK3, S_BLACK4, S_BLACKU, S_BLANK};
|
||||||
for (uint i = 0; i < DEFAULT_SIZE; i++) {
|
for (uint i = 0; i < DEFAULT_SIZE; i++) {
|
||||||
@@ -439,6 +444,7 @@ bool brutforce(game g, int a, bool* deldup) {
|
|||||||
|
|
||||||
bool test_game_update_flags(void) {
|
bool test_game_update_flags(void) {
|
||||||
game g = game_default();
|
game g = game_default();
|
||||||
|
assert(g);
|
||||||
if (!brutforce(g, 1, NULL)) {
|
if (!brutforce(g, 1, NULL)) {
|
||||||
game_delete(g);
|
game_delete(g);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|||||||
@@ -144,8 +144,9 @@ bool test_game_is_blank() {
|
|||||||
|
|
||||||
/* ********** game_delete ********** */
|
/* ********** game_delete ********** */
|
||||||
bool test_game_delete() {
|
bool test_game_delete() {
|
||||||
game g1 = game_new_empty();
|
game g = game_new_empty();
|
||||||
game_delete(g1);
|
assert(g);
|
||||||
|
game_delete(g);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user