test: meta_factory::dtor

This commit is contained in:
Michele Caini
2024-11-25 16:59:45 +01:00
parent bf9ff1a725
commit 7baf2aad1e
+54
View File
@@ -9,8 +9,10 @@
#include <entt/meta/range.hpp>
#include <entt/meta/resolve.hpp>
#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<int>(instance));
}
@@ -150,3 +164,43 @@ TEST_F(MetaFactory, Ctor) {
ASSERT_EQ(static_cast<int>(instance.cast<const clazz &>()), values[0u]);
ASSERT_EQ(static_cast<int>(other.cast<const clazz &>()), values[1u]);
}
TEST_F(MetaFactory, Dtor) {
bool check = false;
auto factory = entt::meta<dtor_callback>();
entt::meta_any any{std::in_place_type<dtor_callback>, check};
any.reset();
ASSERT_FALSE(check);
factory.dtor<&dtor_callback::on_destroy>();
any.emplace<dtor_callback>(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
}