From 7baf2aad1ede24f7399202b92ff33feca6dd8f75 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Mon, 25 Nov 2024 16:59:45 +0100 Subject: [PATCH] test: meta_factory::dtor --- test/entt/meta/meta_factory.cpp | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/test/entt/meta/meta_factory.cpp b/test/entt/meta/meta_factory.cpp index a13d32bc4..4e88f63c9 100644 --- a/test/entt/meta/meta_factory.cpp +++ b/test/entt/meta/meta_factory.cpp @@ -9,8 +9,10 @@ #include #include #include "../../common/config.h" +#include "../../common/meta_traits.h" struct base { + char member{}; }; struct clazz: base { @@ -25,6 +27,18 @@ private: int value{}; }; +struct dtor_callback { + dtor_callback(bool &ref) + : cb{&ref} {} + + static void on_destroy(dtor_callback &instance) { + *instance.cb = !*instance.cb; + } + +private: + bool *cb; +}; + std::string clazz_to_string(const clazz &instance) { return std::to_string(static_cast(instance)); } @@ -150,3 +164,43 @@ TEST_F(MetaFactory, Ctor) { ASSERT_EQ(static_cast(instance.cast()), values[0u]); ASSERT_EQ(static_cast(other.cast()), values[1u]); } + +TEST_F(MetaFactory, Dtor) { + bool check = false; + auto factory = entt::meta(); + entt::meta_any any{std::in_place_type, check}; + + any.reset(); + + ASSERT_FALSE(check); + + factory.dtor<&dtor_callback::on_destroy>(); + any.emplace(check); + any.reset(); + + ASSERT_TRUE(check); +} + +TEST_F(MetaFactory, Data) { + // TODO +} + +TEST_F(MetaFactory, Func) { + // TODO +} + +TEST_F(MetaFactory, Traits) { + // TODO +} + +TEST_F(MetaFactory, Custom) { + // TODO +} + +TEST_F(MetaFactory, Meta) { + // TODO +} + +TEST_F(MetaFactory, MetaReset) { + // TODO +}