Exploring raycasters and possibly make a little "doom like" game based on it.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
raycaster/tests/inventory.cpp

54 lines
1.2 KiB

#include <catch2/catch_test_macros.hpp>
#include <fmt/core.h>
#include <string>
#include "inventory.hpp"
using namespace fmt;
TEST_CASE("base test", "[inventory]") {
inventory::Model inv;
DinkyECS::Entity test_ent = 1;
bool good = inv.add("hand_l", test_ent);
inv.invariant();
REQUIRE(good);
auto& slot = inv.get(test_ent);
REQUIRE(slot == "hand_l");
// confirm that we get false when trying to do it again
good = inv.add("hand_l", test_ent);
REQUIRE(!good);
auto ent = inv.get(slot);
REQUIRE(ent == test_ent);
REQUIRE(inv.has(ent));
REQUIRE(inv.has(slot));
// test base remove
inv.remove(slot, ent);
REQUIRE(!inv.has(slot));
REQUIRE(!inv.has(ent));
// test remove just by slot
good = inv.add("hand_r", test_ent);
REQUIRE(good);
REQUIRE(inv.has("hand_r"));
REQUIRE(inv.has(test_ent));
inv.invariant();
inv.remove("hand_r");
REQUIRE(!inv.has("hand_r"));
REQUIRE(!inv.has(test_ent));
// test remove just by entity
good = inv.add("pocket_l", test_ent);
REQUIRE(good);
REQUIRE(inv.has("pocket_l"));
REQUIRE(inv.has(test_ent));
inv.invariant();
inv.remove(test_ent);
REQUIRE(!inv.has("pocket_l"));
REQUIRE(!inv.has(test_ent));
}