Initial stab at pulling the pathing out.
This commit is contained in:
parent
d515c33afc
commit
e05335b153
5 changed files with 156 additions and 1 deletions
34
tests/pathing.cpp
Normal file
34
tests/pathing.cpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <fmt/core.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <fstream>
|
||||
#include "pathing.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"];
|
||||
int limit = test["limit"];
|
||||
|
||||
Pathing pathing(walls[0].size(), walls.size(), limit);
|
||||
|
||||
pathing.$input = test["input"];
|
||||
|
||||
REQUIRE(pathing.INVARIANT());
|
||||
pathing.compute_paths(walls);
|
||||
|
||||
REQUIRE(pathing.INVARIANT());
|
||||
REQUIRE(pathing.$paths == expected);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue