Now fully off catch2. YAY!

This commit is contained in:
Zed A. Shaw 2026-06-17 00:32:31 -04:00
parent 903cf00661
commit 21e7700deb
16 changed files with 610 additions and 498 deletions

View file

@ -1,4 +1,4 @@
#include <catch2/catch_test_macros.hpp>
#include <fuc2/testing.hpp>
#include <fmt/core.h>
#include <nlohmann/json.hpp>
#include <fstream>
@ -13,41 +13,51 @@
#include "constants.hpp"
using namespace fmt;
using namespace fuc2;
using namespace nlohmann;
using std::string;
using namespace components;
using namespace std::chrono_literals;
json load_test_pathing(const string &fname) {
std::ifstream infile(fname);
return json::parse(infile);
}
namespace pathing_tests {
json load_test_pathing(const string &fname) {
std::ifstream infile(fname);
return json::parse(infile);
}
TEST_CASE("multiple targets can path", "[pathing]") {
GameDB::init();
auto level = GameDB::create_level();
auto walls_copy = level.map->$walls;
Pathing paths{matrix::width(walls_copy), matrix::height(walls_copy)};
void test_multiple_targets_can_path() {
GameDB::init();
auto level = GameDB::create_level();
auto walls_copy = level.map->$walls;
Pathing paths{matrix::width(walls_copy), matrix::height(walls_copy)};
System::multi_path<Combat>(level, paths, walls_copy);
System::multi_path<Combat>(level, paths, walls_copy);
bool diag = Random::uniform<int>(0, 1);
auto pos = GameDB::player_position().location;
auto found = paths.find_path(pos, PATHING_TOWARD, diag);
bool diag = Random::uniform<int>(0, 1);
auto pos = GameDB::player_position().location;
auto found = paths.find_path(pos, PATHING_TOWARD, diag);
while(found == PathingResult::CONTINUE) {
// fmt::println("\033[2J\033[1;1H");
// matrix::dump(diag ? "diag" : "simple", paths.$paths, pos.x, pos.y);
// std::this_thread::sleep_for(200ms);
found = paths.find_path(pos, PATHING_TOWARD, diag);
}
while(found == PathingResult::CONTINUE) {
// fmt::println("\033[2J\033[1;1H");
// matrix::dump(diag ? "diag" : "simple", paths.$paths, pos.x, pos.y);
// std::this_thread::sleep_for(200ms);
found = paths.find_path(pos, PATHING_TOWARD, diag);
if(found == PathingResult::FOUND) {
fmt::println("FOUND!");
} else if(found == PathingResult::FAIL && !diag) {
CHECK(found != PathingResult::FAIL);
}
}
// fmt::println("\033[2J\033[1;1H");
// matrix::dump(diag ? "diag" : "simple", paths.$paths, pos.x, pos.y);
if(found == PathingResult::FOUND) {
fmt::println("FOUND!");
} else if(found == PathingResult::FAIL && !diag) {
REQUIRE(found != PathingResult::FAIL);
}
fuc2::Set TESTS{
.name="pathing",
.tests={
TEST(test_multiple_targets_can_path),
}
};
}