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.
47 lines
1015 B
47 lines
1015 B
#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;
|
|
|
|
inv.add("hand_l", test_ent);
|
|
inv.invariant();
|
|
|
|
auto& slot = inv.get(test_ent);
|
|
REQUIRE(slot == "hand_l");
|
|
|
|
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
|
|
inv.add("hand_r", test_ent);
|
|
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
|
|
inv.add("pocket_l", test_ent);
|
|
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));
|
|
}
|
|
|