Make the tests go faster.
This commit is contained in:
parent
6d7a944a7d
commit
738d9a64d3
7 changed files with 6 additions and 222 deletions
|
|
@ -21,64 +21,7 @@ std::shared_ptr<Map> make_map() {
|
|||
return GameDB::current_level().map;
|
||||
}
|
||||
|
||||
TEST_CASE("basic matrix iterator", "[matrix]") {
|
||||
std::ifstream infile("./tests/dijkstra.json");
|
||||
json data = json::parse(infile);
|
||||
auto test = data[0];
|
||||
|
||||
Matrix walls = test["walls"];
|
||||
|
||||
// tests going through straight cells but also
|
||||
// using two iterators on one matrix (or two)
|
||||
matrix::each_cell cells{walls};
|
||||
cells.next(); // kick it off
|
||||
size_t row_count = 0;
|
||||
|
||||
for(matrix::each_row it{walls};
|
||||
it.next(); cells.next())
|
||||
{
|
||||
REQUIRE(walls[cells.y][cells.x] == walls[it.y][it.x]);
|
||||
row_count += it.row;
|
||||
}
|
||||
|
||||
REQUIRE(row_count == walls.size());
|
||||
|
||||
{
|
||||
// test getting the correct height in the middle
|
||||
row_count = 0;
|
||||
matrix::box box{walls, 2,2, 1};
|
||||
|
||||
while(box.next()) {
|
||||
row_count += box.x == box.left;
|
||||
walls[box.y][box.x] = 3;
|
||||
}
|
||||
//matrix::dump("2,2 WALLS", walls, 2, 2);
|
||||
|
||||
REQUIRE(row_count == 3);
|
||||
}
|
||||
|
||||
{
|
||||
// matrix::dump("1:1 POINT", walls, 1,1);
|
||||
// confirm boxes have the right number of rows
|
||||
// when x goes to 0 on first next call
|
||||
row_count = 0;
|
||||
matrix::box box{walls, 1, 1, 1};
|
||||
|
||||
while(box.next()) {
|
||||
row_count += box.x == box.left;
|
||||
}
|
||||
REQUIRE(row_count == 3);
|
||||
}
|
||||
|
||||
{
|
||||
matrix::compass star{walls, 1, 1};
|
||||
while(star.next()) {
|
||||
println("START IS {},{}=={}", star.x, star.y, walls[star.y][star.x]);
|
||||
walls[star.y][star.x] = 11;
|
||||
}
|
||||
// matrix::dump("STAR POINT", walls, 1,1);
|
||||
}
|
||||
}
|
||||
// BUG: create a test that randomizes a map then does matrix ops on it
|
||||
|
||||
inline void random_matrix(Matrix &out) {
|
||||
for(size_t y = 0; y < out.size(); y++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue