feat: apply clang-format and remove nested repo
This commit is contained in:
parent
d4d99109fa
commit
532ca2e5ee
7 changed files with 464 additions and 466 deletions
|
|
@ -101,14 +101,14 @@ dist: clean
|
|||
|
||||
style:
|
||||
@if [ -f ../materials/linters/.clang-format ]; then \
|
||||
clang-format -n $(TETRIS_SRC) $(CLI_SRC); \
|
||||
clang-format -n $(TETRIS_SRC) $(CLI_SRC) $(TEST_SRC); \
|
||||
else \
|
||||
echo ".clang-format not found"; \
|
||||
fi
|
||||
|
||||
format:
|
||||
@if [ -f ../materials/linters/.clang-format ]; then \
|
||||
clang-format -i $(TETRIS_SRC) $(CLI_SRC); \
|
||||
clang-format -i $(TETRIS_SRC) $(CLI_SRC) $(TEST_SRC); \
|
||||
else \
|
||||
echo ".clang-format not found"; \
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
START_TEST(test_collision_bottom) {
|
||||
test_setup();
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
|
||||
state->curr.y = FIELD_HEIGHT;
|
||||
state->curr.x = 5;
|
||||
|
|
@ -14,7 +14,7 @@ END_TEST
|
|||
|
||||
START_TEST(test_collision_left) {
|
||||
test_setup();
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
|
||||
state->curr.x = -1;
|
||||
state->curr.y = 5;
|
||||
|
|
@ -26,7 +26,7 @@ END_TEST
|
|||
|
||||
START_TEST(test_collision_right) {
|
||||
test_setup();
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
|
||||
state->curr.x = FIELD_WIDTH;
|
||||
state->curr.y = 5;
|
||||
|
|
@ -38,7 +38,7 @@ END_TEST
|
|||
|
||||
START_TEST(test_collision_placed_block) {
|
||||
test_setup();
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
|
||||
state->field[10][5] = 2;
|
||||
state->curr.y = 10;
|
||||
|
|
@ -51,7 +51,7 @@ END_TEST
|
|||
|
||||
START_TEST(test_no_collision) {
|
||||
test_setup();
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
|
||||
state->curr.y = 5;
|
||||
state->curr.x = 5;
|
||||
|
|
@ -61,9 +61,9 @@ START_TEST(test_no_collision) {
|
|||
}
|
||||
END_TEST
|
||||
|
||||
Suite* collision_suite(void) {
|
||||
Suite* s = suite_create("Collision");
|
||||
TCase* tc = tcase_create("Core");
|
||||
Suite *collision_suite(void) {
|
||||
Suite *s = suite_create("Collision");
|
||||
TCase *tc = tcase_create("Core");
|
||||
|
||||
tcase_add_test(tc, test_collision_bottom);
|
||||
tcase_add_test(tc, test_collision_left);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
START_TEST(test_generate_figure) {
|
||||
generate_next_figure();
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
|
||||
ck_assert(state->next.sprite >= I && state->next.sprite < FIGURE_COUNT);
|
||||
ck_assert_int_eq(state->next.rotation, 0);
|
||||
|
|
@ -12,7 +12,7 @@ END_TEST
|
|||
START_TEST(test_all_shapes_exist) {
|
||||
for (int sprite = I; sprite < FIGURE_COUNT; sprite++) {
|
||||
for (int rotation = 0; rotation < 4; rotation++) {
|
||||
const int (*shape)[4] = get_figure_shape(sprite, rotation);
|
||||
const int(*shape)[4] = get_figure_shape(sprite, rotation);
|
||||
ck_assert_ptr_nonnull(shape);
|
||||
}
|
||||
}
|
||||
|
|
@ -20,19 +20,20 @@ START_TEST(test_all_shapes_exist) {
|
|||
END_TEST
|
||||
|
||||
START_TEST(test_i_figure_horizontal) {
|
||||
const int (*shape)[4] = get_figure_shape(I, 0);
|
||||
const int(*shape)[4] = get_figure_shape(I, 0);
|
||||
|
||||
int count = 0;
|
||||
for (int j = 0; j < 4; j++) {
|
||||
if (shape[1][j]) count++;
|
||||
if (shape[1][j])
|
||||
count++;
|
||||
}
|
||||
ck_assert_int_eq(count, 4);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_o_figure_unchanged) {
|
||||
const int (*s1)[4] = get_figure_shape(O, 0);
|
||||
const int (*s2)[4] = get_figure_shape(O, 2);
|
||||
const int(*s1)[4] = get_figure_shape(O, 0);
|
||||
const int(*s2)[4] = get_figure_shape(O, 2);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
|
|
@ -42,9 +43,9 @@ START_TEST(test_o_figure_unchanged) {
|
|||
}
|
||||
END_TEST
|
||||
|
||||
Suite* figures_suite(void) {
|
||||
Suite* s = suite_create("Figures");
|
||||
TCase* tc = tcase_create("Core");
|
||||
Suite *figures_suite(void) {
|
||||
Suite *s = suite_create("Figures");
|
||||
TCase *tc = tcase_create("Core");
|
||||
|
||||
tcase_add_test(tc, test_generate_figure);
|
||||
tcase_add_test(tc, test_all_shapes_exist);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include <check.h>
|
||||
#include "test_helper.h"
|
||||
#include <check.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// ============================================================================
|
||||
|
|
@ -134,7 +134,7 @@ START_TEST(test_instant_drop_down_key) {
|
|||
userInput(Start, false);
|
||||
updateCurrentState();
|
||||
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
state->down_key_was_released = 1;
|
||||
|
||||
userInput(Down, false);
|
||||
|
|
@ -147,7 +147,7 @@ START_TEST(test_up_key_release) {
|
|||
userInput(Start, false);
|
||||
updateCurrentState();
|
||||
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
state->down_key_was_released = 0;
|
||||
|
||||
userInput(Up, false);
|
||||
|
|
@ -161,7 +161,7 @@ START_TEST(test_terminate_with_high_score) {
|
|||
userInput(Start, false);
|
||||
updateCurrentState();
|
||||
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
state->info->high_score = 100;
|
||||
state->info->score = 500;
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ START_TEST(test_game_over_state) {
|
|||
userInput(Start, false);
|
||||
updateCurrentState();
|
||||
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int j = 0; j < FIELD_WIDTH; j++) {
|
||||
|
|
@ -195,7 +195,7 @@ START_TEST(test_do_gameover_clears_next) {
|
|||
userInput(Start, false);
|
||||
updateCurrentState();
|
||||
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int j = 0; j < FIELD_WIDTH; j++) {
|
||||
|
|
@ -222,7 +222,7 @@ START_TEST(test_do_gameover_clears_next) {
|
|||
END_TEST
|
||||
|
||||
START_TEST(test_place_figure_directly) {
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
|
||||
for (int i = 0; i < FIELD_HEIGHT; i++)
|
||||
for (int j = 0; j < FIELD_WIDTH; j++)
|
||||
|
|
@ -247,7 +247,7 @@ START_TEST(test_attach_state_transition) {
|
|||
userInput(Start, false);
|
||||
updateCurrentState();
|
||||
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
|
||||
state->state = Attaching;
|
||||
state->attach_start_time = 0;
|
||||
|
|
@ -263,7 +263,7 @@ START_TEST(test_moving_to_down) {
|
|||
userInput(Start, false);
|
||||
updateCurrentState();
|
||||
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
|
||||
state->curr.y = 5;
|
||||
state->curr.x = 5;
|
||||
|
|
@ -286,12 +286,11 @@ START_TEST(test_moving_to_down) {
|
|||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST(test_moving_do_nothing) {
|
||||
userInput(Start, false);
|
||||
updateCurrentState();
|
||||
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
|
||||
state->state = Moving;
|
||||
state->moving_type = DoNothing;
|
||||
|
|
@ -305,7 +304,7 @@ START_TEST(test_automatic_falling) {
|
|||
userInput(Start, false);
|
||||
updateCurrentState();
|
||||
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
|
||||
state->curr.y = 5;
|
||||
state->curr.x = 5;
|
||||
|
|
@ -325,10 +324,9 @@ START_TEST(test_automatic_falling) {
|
|||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
Suite* fsm_suite(void) {
|
||||
Suite* s = suite_create("FSM");
|
||||
TCase* tc = tcase_create("Core");
|
||||
Suite *fsm_suite(void) {
|
||||
Suite *s = suite_create("FSM");
|
||||
TCase *tc = tcase_create("Core");
|
||||
|
||||
tcase_add_test(tc, test_game_start);
|
||||
tcase_add_test(tc, test_pause_toggle);
|
||||
|
|
@ -354,4 +352,3 @@ Suite* fsm_suite(void) {
|
|||
suite_add_tcase(s, tc);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ END_TEST
|
|||
|
||||
START_TEST(test_incomplete_line) {
|
||||
test_setup();
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
|
||||
// Не полная линия
|
||||
for (int j = 0; j < FIELD_WIDTH - 1; j++) {
|
||||
|
|
@ -61,9 +61,9 @@ START_TEST(test_incomplete_line) {
|
|||
}
|
||||
END_TEST
|
||||
|
||||
Suite* lines_suite(void) {
|
||||
Suite* s = suite_create("ClearLines");
|
||||
TCase* tc = tcase_create("Core");
|
||||
Suite *lines_suite(void) {
|
||||
Suite *s = suite_create("ClearLines");
|
||||
TCase *tc = tcase_create("Core");
|
||||
|
||||
tcase_add_test(tc, test_clear_one_line);
|
||||
tcase_add_test(tc, test_clear_two_lines);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
#include <check.h>
|
||||
|
||||
Suite* collision_suite(void);
|
||||
Suite* lines_suite(void);
|
||||
Suite* figures_suite(void);
|
||||
Suite* score_suite(void);
|
||||
Suite* fsm_suite(void);
|
||||
Suite *collision_suite(void);
|
||||
Suite *lines_suite(void);
|
||||
Suite *figures_suite(void);
|
||||
Suite *score_suite(void);
|
||||
Suite *fsm_suite(void);
|
||||
|
||||
int main(void) {
|
||||
SRunner* sr = srunner_create(collision_suite());
|
||||
SRunner *sr = srunner_create(collision_suite());
|
||||
srunner_add_suite(sr, lines_suite());
|
||||
srunner_add_suite(sr, figures_suite());
|
||||
srunner_add_suite(sr, score_suite());
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
START_TEST(test_level_up) {
|
||||
test_setup();
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
|
||||
fill_line(FIELD_HEIGHT - 1);
|
||||
clear_lines();
|
||||
|
|
@ -21,7 +21,7 @@ END_TEST
|
|||
|
||||
START_TEST(test_max_level) {
|
||||
test_setup();
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
|
||||
state->info->score = 10000;
|
||||
fill_line(FIELD_HEIGHT - 1);
|
||||
|
|
@ -39,16 +39,16 @@ END_TEST
|
|||
|
||||
START_TEST(test_game_over_top) {
|
||||
test_setup();
|
||||
GameState_t* state = get_game_state();
|
||||
GameState_t *state = get_game_state();
|
||||
|
||||
state->field[0][5] = 2;
|
||||
ck_assert_int_eq(is_game_over(), 1);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
Suite* score_suite(void) {
|
||||
Suite* s = suite_create("Score");
|
||||
TCase* tc = tcase_create("Core");
|
||||
Suite *score_suite(void) {
|
||||
Suite *s = suite_create("Score");
|
||||
TCase *tc = tcase_create("Core");
|
||||
|
||||
tcase_add_test(tc, test_level_up);
|
||||
tcase_add_test(tc, test_max_level);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue