This commit is contained in:
Martin Slachta
2026-07-18 14:31:15 +02:00
commit a04f0dc262
3343 changed files with 1140208 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
#define CR_HOST
#include <gtest/gtest.h>
#include <cr.h>
#include <entt/entity/entity.hpp>
#include <entt/entity/mixin.hpp>
#include <entt/entity/registry.hpp>
#include <entt/entity/view.hpp>
#include "../../../common/boxed_type.h"
#include "../../../common/empty.h"
TEST(Lib, Registry) {
constexpr auto count = 3;
entt::registry registry;
for(auto i = 0; i < count; ++i) {
const auto entity = registry.create();
registry.emplace<test::boxed_int>(entity, i);
}
cr_plugin ctx;
cr_plugin_load(ctx, PLUGIN);
ctx.userdata = &registry;
cr_plugin_update(ctx);
ASSERT_EQ(registry.storage<test::boxed_int>().size(), registry.storage<test::empty>().size());
ASSERT_EQ(registry.storage<test::boxed_int>().size(), registry.storage<entt::entity>().size());
registry.view<test::boxed_int>().each([count](auto entity, auto &elem) {
ASSERT_EQ(elem.value, entt::to_integral(entity) + count);
});
registry = {};
cr_plugin_close(ctx);
}
+34
View File
@@ -0,0 +1,34 @@
#include <cr.h>
#include <entt/entity/mixin.hpp>
#include <entt/entity/registry.hpp>
#include <entt/entity/view.hpp>
#include "../../../common/boxed_type.h"
#include "../../../common/empty.h"
CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) {
constexpr auto count = 3;
switch(operation) {
case CR_STEP: {
// forces things to break
auto &registry = *static_cast<entt::registry *>(ctx->userdata);
// forces the creation of the pool for the empty type
static_cast<void>(registry.storage<test::empty>());
const auto view = registry.view<test::boxed_int>();
registry.insert(view.begin(), view.end(), test::empty{});
registry.view<test::boxed_int, test::empty>().each([cnt = count](test::boxed_int &elem) {
elem.value += cnt;
});
} break;
case CR_CLOSE:
case CR_LOAD:
case CR_UNLOAD:
// nothing to do here, this is only a test.
break;
}
return 0;
}
+22
View File
@@ -0,0 +1,22 @@
#include <entt/core/attribute.h>
#include <entt/entity/mixin.hpp>
#include <entt/entity/registry.hpp>
#include <entt/entity/view.hpp>
#include "../../../common/boxed_type.h"
#include "../../../common/empty.h"
template class entt::basic_registry<entt::entity>;
ENTT_API void update(entt::registry &registry, int value) {
registry.view<test::boxed_int, test::empty>().each([value](auto &elem) {
elem.value += value;
});
}
ENTT_API void insert(entt::registry &registry) {
// forces the creation of the pool for the empty type
static_cast<void>(registry.storage<test::empty>());
const auto view = registry.view<test::boxed_int>();
registry.insert<test::empty>(view.begin(), view.end());
}
+30
View File
@@ -0,0 +1,30 @@
#include <gtest/gtest.h>
#include <entt/core/attribute.h>
#include <entt/entity/entity.hpp>
#include <entt/entity/mixin.hpp>
#include <entt/entity/registry.hpp>
#include <entt/entity/view.hpp>
#include "../../../common/boxed_type.h"
#include "../../../common/empty.h"
ENTT_API void update(entt::registry &, int);
ENTT_API void insert(entt::registry &);
TEST(Lib, Registry) {
constexpr auto count = 3;
entt::registry registry;
for(auto i = 0; i < count; ++i) {
const auto entity = registry.create();
registry.emplace<test::boxed_int>(entity, i);
}
insert(registry);
update(registry, count);
ASSERT_EQ(registry.storage<test::boxed_int>().size(), registry.storage<test::empty>().size());
registry.view<test::boxed_int>().each([count](auto entity, auto &elem) {
ASSERT_EQ(elem.value, static_cast<int>(entt::to_integral(entity) + count));
});
}