Started to convert from catch2 to fuc2.
This commit is contained in:
parent
4deda37665
commit
b8b42d5681
10 changed files with 615 additions and 493 deletions
|
|
@ -1,4 +1,4 @@
|
|||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <fuc2/testing.hpp>
|
||||
#include "game/components.hpp"
|
||||
#include "algos/dinkyecs.hpp"
|
||||
#include "game/config.hpp"
|
||||
|
|
@ -7,44 +7,56 @@
|
|||
using namespace components;
|
||||
using namespace DinkyECS;
|
||||
|
||||
TEST_CASE("confirm component loading works", "[components]") {
|
||||
std::vector<std::string> test_list{
|
||||
"assets/enemies.json", "assets/items.json", "assets/devices.json"};
|
||||
using namespace fuc2;
|
||||
|
||||
components::init();
|
||||
DinkyECS::World world;
|
||||
namespace component_tests {
|
||||
void test_confirm_component_loading_works() {
|
||||
std::vector<std::string> test_list{
|
||||
"assets/enemies.json", "assets/items.json", "assets/devices.json"};
|
||||
|
||||
for(auto test_data : test_list) {
|
||||
auto config = settings::get(test_data);
|
||||
auto data_list = config.json();
|
||||
components::init();
|
||||
DinkyECS::World world;
|
||||
|
||||
for(auto& [key, data] : data_list.items()) {
|
||||
auto& components = data["components"];
|
||||
fmt::println("TEST COMPONENT: {} from file {}", key, test_data);
|
||||
auto ent = world.entity();
|
||||
components::configure_entity(world, ent, components);
|
||||
auto tile = components::get<Tile>(components[0]);
|
||||
REQUIRE(tile.display != L' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
for(auto test_data : test_list) {
|
||||
auto config = settings::get(test_data);
|
||||
auto data_list = config.json();
|
||||
|
||||
TEST_CASE("make sure json_mods works", "[components]") {
|
||||
auto config = settings::get("bosses");
|
||||
// this confirms that loading something with an optional
|
||||
// field works with the json conversions in json_mods.hpp
|
||||
for(auto& comp_data : config["RAT_KING"]["components"]) {
|
||||
if(comp_data["_type"] == "AnimatedScene") {
|
||||
auto comp = components::convert<components::AnimatedScene>(comp_data);
|
||||
for(auto& [key, data] : data_list.items()) {
|
||||
auto& components = data["components"];
|
||||
fmt::println("TEST COMPONENT: {} from file {}", key, test_data);
|
||||
auto ent = world.entity();
|
||||
components::configure_entity(world, ent, components);
|
||||
auto tile = components::get<Tile>(components[0]);
|
||||
CHECK(tile.display != L' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this then confirms everything else about the json conversion
|
||||
components::init();
|
||||
void test_make_sure_json_mods_works() {
|
||||
auto config = settings::get("bosses");
|
||||
// this confirms that loading something with an optional
|
||||
// field works with the json conversions in json_mods.hpp
|
||||
for(auto& comp_data : config["RAT_KING"]["components"]) {
|
||||
if(comp_data["_type"] == "AnimatedScene") {
|
||||
auto comp = components::convert<components::AnimatedScene>(comp_data);
|
||||
}
|
||||
}
|
||||
|
||||
DinkyECS::World world;
|
||||
auto rat_king = world.entity();
|
||||
// this then confirms everything else about the json conversion
|
||||
components::init();
|
||||
|
||||
components::configure_entity(world, rat_king, config["RAT_KING"]["components"]);
|
||||
auto boss = world.get<AnimatedScene>(rat_king);
|
||||
DinkyECS::World world;
|
||||
auto rat_king = world.entity();
|
||||
|
||||
components::configure_entity(world, rat_king, config["RAT_KING"]["components"]);
|
||||
auto boss = world.get<AnimatedScene>(rat_king);
|
||||
}
|
||||
|
||||
fuc2::Set TESTS{
|
||||
.name="components",
|
||||
.tests={
|
||||
TEST(test_make_sure_json_mods_works),
|
||||
TEST(test_confirm_component_loading_works),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue