|
|
|
#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]") {
|
|
|
|
|
|
|
|
}
|