63 lines
1.3 KiB
C++
63 lines
1.3 KiB
C++
#include <fuc2/testing.hpp>
|
|
#include <fmt/core.h>
|
|
#include <string>
|
|
#include "game/inventory.hpp"
|
|
|
|
using namespace fmt;
|
|
using namespace fuc2;
|
|
|
|
namespace inventory_tests {
|
|
void test_base_test() {
|
|
return;
|
|
inventory::Model inv;
|
|
DinkyECS::Entity test_ent = 1;
|
|
|
|
bool good = inv.add("hand_l", test_ent);
|
|
inv.invariant();
|
|
CHECK(good);
|
|
|
|
auto& slot = inv.get(test_ent);
|
|
CHECK(slot == "hand_l");
|
|
|
|
// confirm that we get false when trying to do it again
|
|
// BUG: this dies
|
|
good = inv.add("hand_l", test_ent);
|
|
CHECK(!good);
|
|
|
|
auto ent = inv.get(slot);
|
|
CHECK(ent == test_ent);
|
|
|
|
CHECK(inv.has(ent));
|
|
CHECK(inv.has(slot));
|
|
|
|
// test base remove
|
|
inv.remove(ent);
|
|
CHECK(!inv.has(slot));
|
|
CHECK(!inv.has(ent));
|
|
}
|
|
|
|
void test_test_swapping_items() {
|
|
inventory::Model inv;
|
|
DinkyECS::Entity hand_l_ent = 10;
|
|
DinkyECS::Entity hand_r_ent = 20;
|
|
|
|
inv.add("hand_l", hand_l_ent);
|
|
inv.add("hand_r", hand_r_ent);
|
|
CHECK(inv.count() == 2);
|
|
|
|
inv.swap(hand_l_ent, hand_r_ent);
|
|
|
|
CHECK(inv.get("hand_l") == hand_r_ent);
|
|
CHECK(inv.get("hand_r") == hand_l_ent);
|
|
|
|
CHECK(inv.count() == 2);
|
|
}
|
|
|
|
fuc2::Set TESTS{
|
|
.name="inventory",
|
|
.tests={
|
|
TEST(test_base_test),
|
|
TEST(test_test_swapping_items),
|
|
}
|
|
};
|
|
}
|