The next little game in the series where I make a fancy rogue game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
roguish/tests/matrix.cpp

53 lines
1.1 KiB

#include <catch2/catch_test_macros.hpp>
#include <fmt/core.h>
#include <string>
#include "config.hpp"
#include "matrix.hpp"
#include "components.hpp"
#include <nlohmann/json.hpp>
#include <fstream>
using namespace nlohmann;
using namespace fmt;
using std::string;
using matrix::Matrix;
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"];
matrix::dump("ITERATOR DUMP", walls);
println("VS matrix::each_row ------");
for(matrix::each_row it{walls}; it.next();) {
REQUIRE(walls[it.y][it.x] == it.cell);
print("{} ", it.cell);
if(it.row) print("\n");
}
// 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
for(matrix::each_row it{walls};
it.next(); cells.next())
{
REQUIRE(walls[cells.y][cells.x] == it.cell);
}
println("END TEST=============");
}
TEST_CASE("matrix_assign works", "[matrix]") {
}
TEST_CASE("matrix_dump works", "[matrix]") {
}