More tests converted to fuc2.
This commit is contained in:
parent
b8b42d5681
commit
903cf00661
10 changed files with 671 additions and 556 deletions
|
|
@ -1,52 +1,63 @@
|
|||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <fuc2/testing.hpp>
|
||||
#include <fmt/core.h>
|
||||
#include <string>
|
||||
#include "game/inventory.hpp"
|
||||
|
||||
using namespace fmt;
|
||||
using namespace fuc2;
|
||||
|
||||
TEST_CASE("base test", "[inventory]") {
|
||||
return;
|
||||
inventory::Model inv;
|
||||
DinkyECS::Entity test_ent = 1;
|
||||
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();
|
||||
REQUIRE(good);
|
||||
bool good = inv.add("hand_l", test_ent);
|
||||
inv.invariant();
|
||||
CHECK(good);
|
||||
|
||||
auto& slot = inv.get(test_ent);
|
||||
REQUIRE(slot == "hand_l");
|
||||
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);
|
||||
REQUIRE(!good);
|
||||
// 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);
|
||||
REQUIRE(ent == test_ent);
|
||||
auto ent = inv.get(slot);
|
||||
CHECK(ent == test_ent);
|
||||
|
||||
REQUIRE(inv.has(ent));
|
||||
REQUIRE(inv.has(slot));
|
||||
CHECK(inv.has(ent));
|
||||
CHECK(inv.has(slot));
|
||||
|
||||
// test base remove
|
||||
inv.remove(ent);
|
||||
REQUIRE(!inv.has(slot));
|
||||
REQUIRE(!inv.has(ent));
|
||||
}
|
||||
|
||||
TEST_CASE("test swapping items", "[inventory]") {
|
||||
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);
|
||||
REQUIRE(inv.count() == 2);
|
||||
|
||||
inv.swap(hand_l_ent, hand_r_ent);
|
||||
|
||||
REQUIRE(inv.get("hand_l") == hand_r_ent);
|
||||
REQUIRE(inv.get("hand_r") == hand_l_ent);
|
||||
|
||||
REQUIRE(inv.count() == 2);
|
||||
// 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),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue