Did a full code coverage review and improved many of the tests and a bunch of code. I'll do one more final walk through all the code before getting back to work on the new combat system.
This commit is contained in:
parent
113a4a3b3e
commit
d3158291f7
29 changed files with 119 additions and 1218 deletions
|
@ -3,6 +3,7 @@
|
|||
#include "dinkyecs.hpp"
|
||||
#include "config.hpp"
|
||||
#include <iostream>
|
||||
#include "easings.hpp"
|
||||
|
||||
using namespace components;
|
||||
using namespace DinkyECS;
|
||||
|
@ -27,3 +28,66 @@ TEST_CASE("confirm component loading works", "[components]") {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("make sure json_mods works", "[components]") {
|
||||
Config config("assets/bosses.json");
|
||||
// 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"] == "BossFight") {
|
||||
auto comp = components::convert<components::BossFight>(comp_data);
|
||||
// the boss fight for the rat king doesn't have a stage so false=optional
|
||||
REQUIRE(comp.stage == std::nullopt);
|
||||
}
|
||||
}
|
||||
|
||||
// this then confirms everything else about the json conversion
|
||||
|
||||
ComponentMap comp_map;
|
||||
components::configure(comp_map);
|
||||
|
||||
DinkyECS::World world;
|
||||
auto rat_king = world.entity();
|
||||
|
||||
components::configure_entity(comp_map, world, rat_king, config["RAT_KING"]["components"]);
|
||||
|
||||
auto boss = world.get<BossFight>(rat_king);
|
||||
REQUIRE(boss.stage == std::nullopt);
|
||||
|
||||
// now load the other one for the other way optional is used
|
||||
auto devils_fingers = world.entity();
|
||||
components::configure_entity(comp_map, world, devils_fingers, config["DEVILS_FINGERS"]["components"]);
|
||||
auto boss2 = world.get<BossFight>(devils_fingers);
|
||||
REQUIRE(boss2.stage != std::nullopt);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("animation component special cases", "[components]") {
|
||||
Animation anim;
|
||||
|
||||
anim.easing = ease::NONE;
|
||||
float res = anim.twitching();
|
||||
REQUIRE(res == 0.0);
|
||||
|
||||
anim.easing = ease::SINE;
|
||||
anim.subframe = 1.0f;
|
||||
res = anim.twitching();
|
||||
REQUIRE(!std::isnan(res));
|
||||
|
||||
anim.easing = ease::OUT_CIRC;
|
||||
res = anim.twitching();
|
||||
REQUIRE(!std::isnan(res));
|
||||
|
||||
anim.easing = ease::OUT_BOUNCE;
|
||||
res = anim.twitching();
|
||||
REQUIRE(!std::isnan(res));
|
||||
|
||||
anim.easing = ease::IN_OUT_BACK;
|
||||
res = anim.twitching();
|
||||
REQUIRE(!std::isnan(res));
|
||||
|
||||
anim.easing = ease::FUCKFACE;
|
||||
bool throws = false;
|
||||
try { anim.twitching(); } catch(...) { throws = true; }
|
||||
REQUIRE(throws);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
TEST_CASE("confirm basic config loader ops", "[config]") {
|
||||
Config config("assets/devices.json");
|
||||
auto data_list = config.json();
|
||||
auto the_keys = config.keys();
|
||||
|
||||
REQUIRE(the_keys.size() > 0);
|
||||
|
||||
for(auto& [key, data] : data_list.items()) {
|
||||
auto wide1 = config.wstring(key, "name");
|
||||
|
|
17
tests/easings.cpp
Normal file
17
tests/easings.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include <catch2/catch_test_macros.hpp>
|
||||
#include "easings.hpp"
|
||||
#include <cmath>
|
||||
|
||||
TEST_CASE("make sure the easing functions at least run", "[easings]") {
|
||||
double out = ease::sine(1.3);
|
||||
REQUIRE(out <= 1.0);
|
||||
|
||||
out = ease::out_circ(3.444);
|
||||
REQUIRE(std::isnan(out));
|
||||
|
||||
out = ease::out_bounce(1.13);
|
||||
REQUIRE(out <= 10 );
|
||||
|
||||
out = ease::in_out_back(3.4);
|
||||
REQUIRE(out < 250.0);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue