Skip to content

Commit bf94c61

Browse files
author
richelbilderbeek
committed
Increase codecov
1 parent cab334c commit bf94c61

File tree

8 files changed

+76
-1
lines changed

8 files changed

+76
-1
lines changed

game_coordinat.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ bool is_forward(
103103
void test_game_coordinat()
104104
{
105105
#ifndef NDEBUG
106+
// center_on_center
107+
{
108+
const game_coordinat c(3.2, 4.7);
109+
const game_coordinat expected(3.5, 4.6);
110+
const game_coordinat created(center_on_center(c));
111+
assert(expected == created);
112+
}
106113
// get
107114
{
108115
const double x{12.34};

game_rect.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ bool is_in(const game_coordinat& pos, const game_rect& r) noexcept;
3333
void test_game_rect();
3434

3535
bool operator==(const game_rect& lhs, const game_rect& rhs) noexcept;
36-
game_rect& operator+=(game_rect& rect, const game_coordinat& delta) noexcept;
3736

3837
std::ostream& operator<<(std::ostream& os, const game_rect& r) noexcept;
3938

game_view_layout.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,18 @@ void test_game_view_layout()
272272
assert(tl_board.get_x() == layout.get_board().get_tl().get_x());
273273
assert(tl_board.get_y() == layout.get_board().get_tl().get_y());
274274
}
275+
// convert_to_screen_rect
276+
{
277+
const game_view_layout layout;
278+
const auto board_rect = convert_to_screen_rect(
279+
game_rect(
280+
game_coordinat(0.0, 0.0),
281+
game_coordinat(8.0, 8.0)
282+
),
283+
layout
284+
);
285+
assert(board_rect == layout.get_board());
286+
}
275287
// in-game (8,8) must be bottom-right of screen board
276288
// (no piece can ever have its top-right at the bottom-right of the board)
277289
{

piece.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ void test_piece()
243243
p.add_action(piece_action(piece_action_type::attack, square("a3")));
244244
assert(!describe_actions(p).empty());
245245
}
246+
// piece::get_current_square
247+
{
248+
const auto p{get_test_white_king()};
249+
assert(p.get_current_square() == square("e1"));
250+
}
246251
// get_health
247252
{
248253
const auto p{get_test_white_king()};
@@ -258,6 +263,11 @@ void test_piece()
258263
const auto p{get_test_white_king()};
259264
assert(p.get_max_health() > 0.0);
260265
}
266+
// get_occupied_square
267+
{
268+
const auto p{get_test_white_king()};
269+
assert(get_occupied_square(p) == square("e1"));
270+
}
261271
// has_actions
262272
{
263273
const auto p{get_test_white_king()};

piece_action.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ void test_piece_action()
6767
{
6868
const piece_action a(piece_action_type::attack, square("e3"));
6969
assert(!to_str(piece_action(a)).empty());
70+
const piece_action b(piece_action_type::move, square("e2"), square("e4"));
71+
assert(!to_str(piece_action(a)).empty());
7072
}
7173
// operator<<
7274
{

pieces.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,17 @@ void test_pieces()
313313
auto& piece{get_piece_at(pieces, square("d1"))};
314314
piece.set_selected(true); // Just needs to compile
315315
}
316+
// get_pieces_before_scholars_mate
317+
{
318+
const auto pieces{get_pieces_before_scholars_mate()};
319+
assert(pieces.size() == 32);
320+
}
321+
// get_pieces_bishop_and_knight_end_game
322+
{
323+
const auto pieces{get_pieces_bishop_and_knight_end_game()};
324+
assert(pieces.size() == 4);
325+
}
326+
316327
// is_piece_at, const
317328
{
318329
const auto pieces{get_standard_starting_pieces()};

square.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,16 @@ void test_square()
293293
const auto a8_expected{game_rect(game_coordinat(7.0, 0.0), game_coordinat(8.0, 1.0))};
294294
assert(a8_created == a8_expected);
295295
}
296+
// to_str, square
297+
{
298+
const auto s{square("a1")};
299+
assert(!to_str(s).empty());
300+
}
301+
// to_str, std::vector<square>
302+
{
303+
const std::vector<square> squares{square("a1"), square("b2")};
304+
assert(!to_str(squares).empty());
305+
}
296306
// operator==
297307
{
298308
const square a("a1");

test_game.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ void test_game_class()
1515
////////////////////////////////////////////////////////////////////////////
1616
// Member functions
1717
////////////////////////////////////////////////////////////////////////////
18+
// game::get_layout, const
19+
{
20+
const auto g{get_default_game()};
21+
assert(get_width(g.get_layout().get_board()) > 0);
22+
}
1823
// game::get_options, const
1924
{
2025
const auto g{get_default_game()};
@@ -57,6 +62,11 @@ void test_game_functions()
5762
g.tick();
5863
assert(g.get_mouse_player_pos() == black_king.get_coordinat());
5964
assert(can_player_select_piece_at_cursor_pos(g, chess_color::black));
65+
66+
assert(can_player_select_piece_at_cursor_pos(g, chess_color::white));
67+
g.add_action(create_press_left_action()); // cursor to d8
68+
g.tick();
69+
assert(!can_player_select_piece_at_cursor_pos(g, chess_color::white));
6070
}
6171
// clear_sound_effects
6272
{
@@ -144,6 +154,20 @@ void test_game_functions()
144154
const auto pos_after{get_keyboard_player_pos(g)};
145155
assert(pos_before != pos_after);
146156
}
157+
// get_mouse_player_pos, left == keyboard
158+
{
159+
game_options options = get_default_game_options();
160+
options.set_left_controller_type(controller_type::keyboard);
161+
const game g(options);
162+
assert(get_mouse_player_pos(g) == g.get_player_2_pos());
163+
}
164+
// get_mouse_player_pos, left == mouse
165+
{
166+
game_options options = get_default_game_options();
167+
options.set_left_controller_type(controller_type::mouse);
168+
const game g(options);
169+
assert(get_mouse_player_pos(g) == g.get_player_1_pos());
170+
}
147171
// get_piece_at, const
148172
{
149173
const game g;

0 commit comments

Comments
 (0)