2025-02-14 21:35:40 +03:00
|
|
|
#include <catch2/catch_test_macros.hpp>
|
2025-02-14 21:01:46 +03:00
|
|
|
#define CATCH_CONFIG_MAIN
|
|
|
|
#include <catch2/catch_all.hpp>
|
2025-02-14 22:18:00 +03:00
|
|
|
|
|
|
|
#define MAX_ZECSY_ENTITIES 4
|
2025-02-14 21:35:40 +03:00
|
|
|
#include "../zecsy.hpp"
|
2025-02-14 21:01:46 +03:00
|
|
|
|
2025-02-14 21:35:40 +03:00
|
|
|
using namespace zecsy;
|
|
|
|
|
|
|
|
TEST_CASE("Create a single entity and verify its existence")
|
2025-02-14 21:01:46 +03:00
|
|
|
{
|
2025-02-14 21:35:40 +03:00
|
|
|
world w;
|
2025-02-14 21:41:36 +03:00
|
|
|
|
2025-02-14 21:35:40 +03:00
|
|
|
auto e = w.make_entity();
|
2025-02-14 21:47:16 +03:00
|
|
|
|
2025-02-14 21:35:40 +03:00
|
|
|
REQUIRE(w.is_alive(e));
|
2025-02-14 22:18:00 +03:00
|
|
|
REQUIRE(e.is_alive());
|
2025-02-14 21:01:46 +03:00
|
|
|
}
|
2025-02-14 21:41:36 +03:00
|
|
|
|
|
|
|
TEST_CASE("Destroy an entity and ensure it no longer exists in the world")
|
|
|
|
{
|
|
|
|
world w;
|
2025-02-14 21:47:16 +03:00
|
|
|
|
2025-02-14 21:41:36 +03:00
|
|
|
auto e = w.make_entity();
|
|
|
|
w.destroy_entity(e);
|
2025-02-14 21:47:16 +03:00
|
|
|
|
2025-02-14 21:41:36 +03:00
|
|
|
REQUIRE_FALSE(w.is_alive(e));
|
2025-02-14 22:18:00 +03:00
|
|
|
REQUIRE_FALSE(e.is_alive());
|
2025-02-14 21:41:36 +03:00
|
|
|
}
|
2025-02-14 21:47:16 +03:00
|
|
|
|
|
|
|
TEST_CASE("Entity #0 should be reserved and never used")
|
|
|
|
{
|
|
|
|
world w;
|
|
|
|
|
|
|
|
auto e = w.make_entity();
|
|
|
|
|
|
|
|
REQUIRE(e != 0);
|
2025-02-14 22:18:00 +03:00
|
|
|
REQUIRE(entity() == 0);
|
|
|
|
REQUIRE_FALSE(entity().is_alive());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("World should throw on id overflow")
|
|
|
|
{
|
|
|
|
world w;
|
|
|
|
|
|
|
|
for(int i = 0; i < MAX_ZECSY_ENTITIES; ++i)
|
|
|
|
{
|
|
|
|
REQUIRE_NOTHROW(w.make_entity());
|
|
|
|
}
|
|
|
|
|
|
|
|
REQUIRE_THROWS(w.make_entity());
|
2025-02-14 21:47:16 +03:00
|
|
|
}
|