#include #include #include #include #include "pathing.hpp" #include "matrix.hpp" using namespace fmt; using namespace nlohmann; using std::string; json load_test_pathing(const string &fname) { std::ifstream infile(fname); return json::parse(infile); } TEST_CASE("dijkstra algo test", "[pathing]") { json data = load_test_pathing("./tests/dijkstra.json"); for(auto &test : data) { Matrix expected = test["expected"]; Matrix walls = test["walls"]; Pathing pathing(walls[0].size(), walls.size()); pathing.$input = test["input"]; REQUIRE(pathing.INVARIANT()); pathing.compute_paths(walls); REQUIRE(pathing.INVARIANT()); matrix_dump("PATHING RESULT", pathing.$paths); matrix_dump("PATHING EXPECTED", expected); REQUIRE(pathing.$paths == expected); } }