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/map.cpp

35 lines
794 B

#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 in_map = test["input"];
Matrix walls = test["walls"];
Matrix expected = test["expected"];
int limit = test["limit"];
Matrix res = dijkstra_map(in_map, walls, limit);
if(res != expected) {
println("ERROR! ------");
dump_map("EXPECTED", expected);
dump_map("RESULT", res);
}
REQUIRE(res == expected);
}
}