Tests are now clean so next step is to officially nuke the level manager.

This commit is contained in:
Zed A. Shaw 2025-08-20 00:48:20 -04:00
parent 564f9842a2
commit 5aca2fb56a
8 changed files with 47 additions and 72 deletions

View file

@ -1,40 +0,0 @@
#include <catch2/catch_test_macros.hpp>
#include <fmt/core.h>
#include "map.hpp"
#include "dinkyecs.hpp"
#include "worldbuilder.hpp"
#include "save.hpp"
#include "systems.hpp"
#include "spatialmap.hpp"
#include "levelmanager.hpp"
using namespace fmt;
using std::string;
TEST_CASE("basic level manager test", "[levelmanager]") {
LevelManager lm;
// starts off with one already but I need to change that
size_t level1 = lm.current_index();
size_t level2 = lm.create_level();
auto& test1_level = lm.get(level1);
auto& test2_level = lm.get(level2);
REQUIRE(test1_level.map->width() > 0);
REQUIRE(test1_level.map->height() > 0);
REQUIRE(test1_level.index == 0);
REQUIRE(test2_level.map->width() > 0);
REQUIRE(test2_level.map->height() > 0);
REQUIRE(test2_level.index == 1);
auto& cur_level = lm.current();
REQUIRE(cur_level.index == 0);
auto& next_level = lm.next();
REQUIRE(next_level.index == 1);
auto& prev_level = lm.previous();
REQUIRE(prev_level.index == 0);
}

View file

@ -4,15 +4,16 @@
#include <fstream>
#include "map.hpp"
#include "levelmanager.hpp"
#include "game_level.hpp"
#include "lights.hpp"
#include "point.hpp"
using namespace lighting;
TEST_CASE("lighting a map works", "[lighting]") {
LevelManager levels;
GameLevel level = levels.current();
auto &map = *level.map;
Game::init();
auto& level = Game::current();
auto& map = *level.map;
Point light1, light2;

View file

@ -19,9 +19,10 @@ json load_test_data(const string &fname) {
TEST_CASE("camera control", "[map]") {
textures::init();
components::init();
LevelManager levels;
GameLevel level = levels.current();
auto &map = *level.map;
Game::init();
auto& level = Game::current();
auto& map = *level.map;
Point center = map.center_camera({10,10}, 5, 5);
@ -35,21 +36,22 @@ TEST_CASE("camera control", "[map]") {
REQUIRE(translation.y == 2);
}
TEST_CASE("map placement test", "[map]") {
TEST_CASE("map placement test", "[map-fail]") {
textures::init();
components::init();
for(int i = 0; i < 20; i++) {
LevelManager levels;
GameLevel level = levels.current();
auto &map = *level.map;
Game::init();
for(size_t rnum = 0; rnum < map.room_count(); rnum++) {
for(int i = 0; i < 5; i++) {
auto& level = Game::create_level();
for(size_t rnum = 0; rnum < level.map->room_count(); rnum++) {
Point pos;
REQUIRE(map.place_entity(rnum, pos));
REQUIRE(level.map->place_entity(rnum, pos));
REQUIRE(!map.iswall(pos.x, pos.y));
REQUIRE(map.inmap(pos.x, pos.y));
REQUIRE(!level.map->iswall(pos.x, pos.y));
REQUIRE(level.map->inmap(pos.x, pos.y));
}
}
}
@ -87,7 +89,7 @@ TEST_CASE("map image test", "[map]") {
textures::init();
Game::init();
GameLevel level = Game::current();
auto& level = Game::current();
Matrix map_tiles = matrix::make(7,7);
EntityGrid entity_map;

View file

@ -4,20 +4,21 @@
#include "config.hpp"
#include "matrix.hpp"
#include "rand.hpp"
#include "levelmanager.hpp"
#include "game_level.hpp"
#include <nlohmann/json.hpp>
#include <fstream>
#include "map.hpp"
#include <memory>
#include "levelmanager.hpp"
using namespace nlohmann;
using namespace fmt;
using std::string;
using matrix::Matrix;
shared_ptr<Map> make_map() {
// BUG? I mean, it's a shared_ptr so it should keep it around but....
LevelManager levels;
GameLevel level = levels.current();
return level.map;
std::shared_ptr<Map> make_map() {
Game::init();
return Game::current().map;
}
TEST_CASE("basic matrix iterator", "[matrix:basic]") {

View file

@ -2,7 +2,6 @@
#include <iostream>
#include "rituals.hpp"
#include "simplefsm.hpp"
#include "levelmanager.hpp"
#include "ai_debug.hpp"
TEST_CASE("ritual::Engine basic tests", "[rituals]") {