blob: 522a274ae3a10b7c412ac3a8d97a9e93ee1ac87f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include "engine/graphics/string_matrix.hpp"
#include "engine/data/bounds.hpp"
#include <doctest/doctest.h>
#include <type_traits>
constexpr uint32_t MATRIX_WIDTH = 76;
constexpr uint32_t MATRIX_HEIGHT = 31;
TEST_CASE("String matrix")
{
auto string_matrix =
StringMatrix(Bounds({.width = MATRIX_WIDTH, .height = MATRIX_HEIGHT}));
SUBCASE("Can set & get elements")
{
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
const auto position = Vector2({.x = 56, .y = 20});
string_matrix.set(position, "#");
CHECK(string_matrix.get(position) == "#");
}
SUBCASE("Can iterate")
{
CHECK(std::is_same_v<decltype(string_matrix.begin()),
MatrixIterator<std::string_view>>);
CHECK(std::is_same_v<decltype(string_matrix.end()),
MatrixIterator<std::string_view>>);
uint32_t row_iter_cnt = 0;
for (auto row : string_matrix)
{
row_iter_cnt++;
CHECK(std::is_same_v<decltype(row), MatrixRow<std::string_view>>);
uint32_t col_iter_cnt = 0;
for (auto &col : row)
{
col_iter_cnt++;
}
CHECK(col_iter_cnt == MATRIX_WIDTH);
}
CHECK(row_iter_cnt == MATRIX_HEIGHT);
}
}
|