|
|
|
#include <catch2/catch_test_macros.hpp>
|
|
|
|
#include "map.hpp"
|
|
|
|
#include <fmt/core.h>
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
using namespace fmt;
|
|
|
|
using namespace nlohmann;
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
json load_test_data(const string &fname) {
|
|
|
|
std::ifstream infile(fname);
|
|
|
|
return json::parse(infile);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("dijkstra algo test", "[map]") {
|
|
|
|
json data = load_test_data("./tests/dijkstra.json");
|
|
|
|
|
|
|
|
for(auto &test : data) {
|
|
|
|
Matrix expected = test["expected"];
|
|
|
|
Map map(test["input"],
|
|
|
|
test["walls"],
|
|
|
|
test["limit"]);
|
|
|
|
|
|
|
|
map.make_paths();
|
|
|
|
Matrix &paths = map.paths();
|
|
|
|
|
|
|
|
if(paths != expected) {
|
|
|
|
println("ERROR! ------");
|
|
|
|
dump_map("EXPECTED", expected);
|
|
|
|
dump_map("RESULT", paths);
|
|
|
|
}
|
|
|
|
|
|
|
|
REQUIRE(paths == expected);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("bsp algo test", "[map]") {
|
|
|
|
Map map(50, 20);
|
|
|
|
|
|
|
|
map.generate();
|
|
|
|
map.dump();
|
|
|
|
}
|