So far most of the bugs are solved but there's still some edge cases in the inventory dance.

This commit is contained in:
Zed A. Shaw 2025-06-22 23:54:50 -04:00
parent e0588847fa
commit 3c5021e4c9
6 changed files with 40 additions and 25 deletions

View file

@ -9,12 +9,17 @@ TEST_CASE("base test", "[inventory]") {
inventory::Model inv;
DinkyECS::Entity test_ent = 1;
inv.add("hand_l", test_ent);
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);
@ -27,7 +32,8 @@ TEST_CASE("base test", "[inventory]") {
REQUIRE(!inv.has(ent));
// test remove just by slot
inv.add("hand_r", test_ent);
good = inv.add("hand_r", test_ent);
REQUIRE(good);
REQUIRE(inv.has("hand_r"));
REQUIRE(inv.has(test_ent));
inv.invariant();
@ -37,7 +43,8 @@ TEST_CASE("base test", "[inventory]") {
REQUIRE(!inv.has(test_ent));
// test remove just by entity
inv.add("pocket_l", test_ent);
good = inv.add("pocket_l", test_ent);
REQUIRE(good);
REQUIRE(inv.has("pocket_l"));
REQUIRE(inv.has(test_ent));
inv.invariant();