edit test_game_set_square & test_game_get_state
This commit is contained in:
1 parent
c332b09a11
commit
bea852ea2a
1 file changed
+14
-136
+14
-136
@@ -24,13 +24,6 @@ bool test_game_set_square(void) {
|
||||
square list_flag[] = {F_ERROR, F_LIGHTED, (F_ERROR | F_LIGHTED)};
|
||||
for (uint i = 0; i < DEFAULT_SIZE; i++) {
|
||||
for (uint j = 0; j < DEFAULT_SIZE; j++) {
|
||||
for (uint tab_index = 0; tab_index < sizeof(list) / sizeof(list[0]); tab_index++) {
|
||||
game_set_square(g, i, j, list[tab_index]);
|
||||
if (game_get_square(g, i, j) != list[tab_index]) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (uint flag_index = 0; flag_index < sizeof(list_flag) / sizeof(list_flag[0]); flag_index++) {
|
||||
for (uint tab_index = 0; tab_index < sizeof(list) / sizeof(list[0]); tab_index++) {
|
||||
game_set_square(g, i, j, (list[tab_index] | list_flag[flag_index]));
|
||||
@@ -49,135 +42,20 @@ bool test_game_set_square(void) {
|
||||
/* ************** game_get_state ************** */
|
||||
bool test_game_get_state(void) {
|
||||
game g = game_new_empty();
|
||||
game_set_square(g, 0, 0, S_LIGHTBULB);
|
||||
if (game_get_state(g, 0, 0) != S_LIGHTBULB) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, S_BLANK);
|
||||
if (game_get_state(g, 0, 0) != S_BLANK) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, S_MARK);
|
||||
if (game_get_state(g, 0, 0) != S_MARK) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, S_BLACK);
|
||||
if (game_get_state(g, 0, 0) != S_BLACK) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, S_BLACK0);
|
||||
if (game_get_state(g, 0, 0) != S_BLACK0) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, S_BLACK1);
|
||||
if (game_get_state(g, 0, 0) != S_BLACK1) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, S_BLACK2);
|
||||
if (game_get_state(g, 0, 0) != S_BLACK2) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, S_BLACK3);
|
||||
if (game_get_state(g, 0, 0) != S_BLACK3) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, S_BLACK4);
|
||||
if (game_get_state(g, 0, 0) != S_BLACK4) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, S_BLACKU);
|
||||
if (game_get_state(g, 0, 0) != S_BLACKU) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, (S_LIGHTBULB | F_ERROR));
|
||||
if (game_get_state(g, 0, 0) != S_LIGHTBULB) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, (S_BLANK | F_ERROR));
|
||||
if (game_get_state(g, 0, 0) != S_BLANK) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, (S_MARK | F_ERROR));
|
||||
if (game_get_state(g, 0, 0) != S_MARK) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, (S_BLACK | F_ERROR));
|
||||
if (game_get_state(g, 0, 0) != S_BLACK) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, (S_BLACK0 | F_ERROR));
|
||||
if (game_get_state(g, 0, 0) != S_BLACK0) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, (S_BLACK1 | F_ERROR));
|
||||
if (game_get_state(g, 0, 0) != S_BLACK1) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, (S_BLACK2 | F_ERROR));
|
||||
if (game_get_state(g, 0, 0) != S_BLACK2) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, (S_BLACK3 | F_ERROR));
|
||||
if (game_get_state(g, 0, 0) != S_BLACK3) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, (S_BLACK4 | F_ERROR));
|
||||
if (game_get_state(g, 0, 0) != S_BLACK4) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, (S_BLACKU | F_ERROR));
|
||||
if (game_get_state(g, 0, 0) != S_BLACKU) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, (S_LIGHTBULB | F_LIGHTED));
|
||||
if (game_get_state(g, 0, 0) != S_LIGHTBULB) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, (S_BLANK | F_LIGHTED));
|
||||
if (game_get_state(g, 0, 0) != S_BLANK) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, (S_MARK | F_LIGHTED));
|
||||
if (game_get_state(g, 0, 0) != S_MARK) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, (S_LIGHTBULB | F_LIGHTED | F_ERROR));
|
||||
if (game_get_state(g, 0, 0) != S_LIGHTBULB) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, (S_BLANK | F_LIGHTED | F_ERROR));
|
||||
if (game_get_state(g, 0, 0) != S_BLANK) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
game_set_square(g, 0, 0, (S_MARK | F_LIGHTED | F_ERROR));
|
||||
if (game_get_state(g, 0, 0) != S_MARK) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
square list[] = {S_BLANK, S_LIGHTBULB, S_MARK, S_BLACK0, S_BLACK1, S_BLACK2, S_BLACK3, S_BLACK4, S_BLACKU};
|
||||
square list_flag[] = {S_BLANK, F_ERROR, F_LIGHTED, (F_ERROR | F_LIGHTED)};
|
||||
for (uint i = 0; i < DEFAULT_SIZE; i++) {
|
||||
for (uint j = 0; j < DEFAULT_SIZE; j++) {
|
||||
for (uint flag_index = 0; flag_index < sizeof(list_flag) / sizeof(list_flag[0]); flag_index++) {
|
||||
for (uint tab_index = 0; tab_index < sizeof(list) / sizeof(list[0]); tab_index++) {
|
||||
game_set_square(g, i, j, (list[tab_index] | list_flag[flag_index]));
|
||||
if (game_get_state(g, i, j) != list[tab_index]) {
|
||||
game_delete(g);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
game_delete(g);
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user