فهرست منبع

build: refine meta tests

skypjack 2 ماه پیش
والد
کامیت
21a9525b44

+ 20 - 16
test/CMakeLists.txt

@@ -294,22 +294,26 @@ SETUP_BASIC_TEST(
 
 # Test meta
 
-SETUP_BASIC_TEST_DEPRECATED(meta_any entt/meta/meta_any.cpp)
-SETUP_BASIC_TEST_DEPRECATED(meta_base entt/meta/meta_base.cpp)
-SETUP_BASIC_TEST_DEPRECATED(meta_container entt/meta/meta_container.cpp)
-SETUP_BASIC_TEST_DEPRECATED(meta_context entt/meta/meta_context.cpp)
-SETUP_BASIC_TEST_DEPRECATED(meta_conv entt/meta/meta_conv.cpp)
-SETUP_BASIC_TEST_DEPRECATED(meta_ctor entt/meta/meta_ctor.cpp)
-SETUP_BASIC_TEST_DEPRECATED(meta_custom entt/meta/meta_custom.cpp)
-SETUP_BASIC_TEST_DEPRECATED(meta_data entt/meta/meta_data.cpp)
-SETUP_BASIC_TEST_DEPRECATED(meta_factory entt/meta/meta_factory.cpp)
-SETUP_BASIC_TEST_DEPRECATED(meta_func entt/meta/meta_func.cpp)
-SETUP_BASIC_TEST_DEPRECATED(meta_handle entt/meta/meta_handle.cpp)
-SETUP_BASIC_TEST_DEPRECATED(meta_pointer entt/meta/meta_pointer.cpp)
-SETUP_BASIC_TEST_DEPRECATED(meta_range entt/meta/meta_range.cpp)
-SETUP_BASIC_TEST_DEPRECATED(meta_template entt/meta/meta_template.cpp)
-SETUP_BASIC_TEST_DEPRECATED(meta_type entt/meta/meta_type.cpp)
-SETUP_BASIC_TEST_DEPRECATED(meta_utility entt/meta/meta_utility.cpp)
+SETUP_BASIC_TEST(
+    NAME meta
+    SOURCES
+        entt/meta/meta_any.cpp
+        entt/meta/meta_base.cpp
+        entt/meta/meta_container.cpp
+        entt/meta/meta_context.cpp
+        entt/meta/meta_conv.cpp
+        entt/meta/meta_ctor.cpp
+        entt/meta/meta_custom.cpp
+        entt/meta/meta_data.cpp
+        entt/meta/meta_factory.cpp
+        entt/meta/meta_func.cpp
+        entt/meta/meta_handle.cpp
+        entt/meta/meta_pointer.cpp
+        entt/meta/meta_range.cpp
+        entt/meta/meta_template.cpp
+        entt/meta/meta_type.cpp
+        entt/meta/meta_utility.cpp
+)
 
 # Test poly
 

+ 49 - 49
test/entt/meta/meta_any.cpp

@@ -16,75 +16,75 @@
 #include "../../common/linter.hpp"
 #include "../../common/non_comparable.h"
 
-struct clazz {
-    void member(int iv) {
-        value = iv;
-    }
+struct MetaAny: ::testing::Test {
+    struct clazz {
+        void member(int iv) {
+            value = iv;
+        }
 
-    static char func() {
-        return 'c';
-    }
+        static char func() {
+            return 'c';
+        }
 
-    operator int() const {
-        return value;
-    }
+        operator int() const {
+            return value;
+        }
 
-    int value{0};
-};
+        int value{0};
+    };
 
-struct empty {
-    empty() = default;
+    struct empty {
+        empty() = default;
 
-    empty(const empty &) = default;
-    empty &operator=(const empty &) = default;
+        empty(const empty &) = default;
+        empty &operator=(const empty &) = default;
 
-    virtual ~empty() {
-        ++counter;
-    }
+        virtual ~empty() {
+            ++counter;
+        }
 
-    inline static int counter = 0; // NOLINT
-};
+        inline static int counter = 0; // NOLINT
+    };
 
-struct fat: empty {
-    fat()
-        : value{.0, .0, .0, .0} {}
+    struct fat: empty {
+        fat()
+            : value{.0, .0, .0, .0} {}
 
-    fat(double v1, double v2, double v3, double v4)
-        : value{v1, v2, v3, v4} {}
+        fat(double v1, double v2, double v3, double v4)
+            : value{v1, v2, v3, v4} {}
 
-    ~fat() override = default;
+        ~fat() override = default;
 
-    fat(const fat &) = default;
-    fat &operator=(const fat &) = default;
+        fat(const fat &) = default;
+        fat &operator=(const fat &) = default;
 
-    bool operator==(const fat &other) const {
-        return (value == other.value);
-    }
+        bool operator==(const fat &other) const {
+            return (value == other.value);
+        }
 
-    std::array<double, 4u> value{};
-};
+        std::array<double, 4u> value{};
+    };
 
-enum class enum_class : std::uint8_t {
-    foo = 0u,
-    bar = 1u
-};
+    enum class enum_class : std::uint8_t {
+        foo = 0u,
+        bar = 1u
+    };
 
-struct unmanageable {
-    unmanageable()
-        : value{std::make_unique<int>(3)} {}
+    struct unmanageable {
+        unmanageable()
+            : value{std::make_unique<int>(3)} {}
 
-    ~unmanageable() = default;
+        ~unmanageable() = default;
 
-    unmanageable(const unmanageable &) = delete;
-    unmanageable(unmanageable &&) = delete;
+        unmanageable(const unmanageable &) = delete;
+        unmanageable(unmanageable &&) = delete;
 
-    unmanageable &operator=(const unmanageable &) = delete;
-    unmanageable &operator=(unmanageable &&) = delete;
+        unmanageable &operator=(const unmanageable &) = delete;
+        unmanageable &operator=(unmanageable &&) = delete;
 
-    std::unique_ptr<int> value;
-};
+        std::unique_ptr<int> value;
+    };
 
-struct MetaAny: ::testing::Test {
     void SetUp() override {
         using namespace entt::literals;
 

+ 20 - 20
test/entt/meta/meta_base.cpp

@@ -8,32 +8,32 @@
 #include <entt/meta/node.hpp>
 #include <entt/meta/resolve.hpp>
 
-struct base_1 {
-    base_1() = default;
-    int value_1{};
-};
+struct MetaBase: ::testing::Test {
+    struct base_1 {
+        base_1() = default;
+        int value_1{};
+    };
 
-struct base_2 {
-    base_2() = default;
+    struct base_2 {
+        base_2() = default;
 
-    operator int() const {
-        return value_2;
-    }
+        operator int() const {
+            return value_2;
+        }
 
-    int value_2{};
-};
+        int value_2{};
+    };
 
-struct base_3: base_2 {
-    base_3() = default;
-    int value_3{};
-};
+    struct base_3: base_2 {
+        base_3() = default;
+        int value_3{};
+    };
 
-struct derived: base_1, base_3 {
-    derived() = default;
-    int value{};
-};
+    struct derived: base_1, base_3 {
+        derived() = default;
+        int value{};
+    };
 
-struct MetaBase: ::testing::Test {
     void SetUp() override {
         using namespace entt::literals;
 

+ 60 - 60
test/entt/meta/meta_context.cpp

@@ -14,66 +14,6 @@
 #include <entt/meta/template.hpp>
 #include "../../common/empty.h"
 
-struct base {
-    base() = default;
-
-    base(char cv)
-        : value{cv} {}
-
-    [[nodiscard]] char get() const {
-        return value;
-    }
-
-    char value;
-};
-
-struct clazz: base {
-    clazz()
-        : base{} {}
-
-    clazz(int iv)
-        : base{},
-          value{iv} {}
-
-    clazz(char cv, int iv) // NOLINT
-        : base{cv},
-          value{iv} {}
-
-    [[nodiscard]] int func(int iv) {
-        return (value = iv);
-    }
-
-    [[nodiscard]] int cfunc(int) const {
-        return value;
-    }
-
-    static void move_to_bucket(const clazz &instance) {
-        bucket = instance.value;
-    }
-
-    int value{};
-    inline static int bucket{}; // NOLINT
-};
-
-struct argument {
-    argument(int val)
-        : value{val} {}
-
-    [[nodiscard]] int get() const {
-        return value;
-    }
-
-    [[nodiscard]] int get_mul() const {
-        return value * 2;
-    }
-
-private:
-    int value{};
-};
-
-template<typename...>
-struct template_clazz {};
-
 class MetaContext: public ::testing::Test {
     static void init_global_context() {
         using namespace entt::literals;
@@ -126,6 +66,66 @@ class MetaContext: public ::testing::Test {
     }
 
 public:
+    struct base {
+        base() = default;
+
+        base(char cv)
+            : value{cv} {}
+
+        [[nodiscard]] char get() const {
+            return value;
+        }
+
+        char value;
+    };
+
+    struct clazz: base {
+        clazz()
+            : base{} {}
+
+        clazz(int iv)
+            : base{},
+              value{iv} {}
+
+        clazz(char cv, int iv) // NOLINT
+            : base{cv},
+              value{iv} {}
+
+        [[nodiscard]] int func(int iv) {
+            return (value = iv);
+        }
+
+        [[nodiscard]] int cfunc(int) const {
+            return value;
+        }
+
+        static void move_to_bucket(const clazz &instance) {
+            bucket = instance.value;
+        }
+
+        int value{};
+        inline static int bucket{}; // NOLINT
+    };
+
+    struct argument {
+        argument(int val)
+            : value{val} {}
+
+        [[nodiscard]] int get() const {
+            return value;
+        }
+
+        [[nodiscard]] int get_mul() const {
+            return value * 2;
+        }
+
+    private:
+        int value{};
+    };
+
+    template<typename...>
+    struct template_clazz {};
+
     void SetUp() override {
         init_global_context();
         init_local_context();

+ 14 - 14
test/entt/meta/meta_conv.cpp

@@ -8,25 +8,25 @@
 #include <entt/meta/node.hpp>
 #include <entt/meta/resolve.hpp>
 
-struct clazz {
-    clazz() = default;
+struct MetaConv: ::testing::Test {
+    struct clazz {
+        clazz() = default;
 
-    operator int() const {
-        return value;
-    }
+        operator int() const {
+            return value;
+        }
 
-    [[nodiscard]] bool to_bool() const {
-        return (value != 0);
-    }
+        [[nodiscard]] bool to_bool() const {
+            return (value != 0);
+        }
 
-    int value{};
-};
+        int value{};
+    };
 
-double conv_to_double(const clazz &instance) {
-    return instance.value * 2.;
-}
+    static double conv_to_double(const clazz &instance) {
+        return instance.value * 2.;
+    }
 
-struct MetaConv: ::testing::Test {
     void SetUp() override {
         using namespace entt::literals;
 

+ 28 - 28
test/entt/meta/meta_ctor.cpp

@@ -10,43 +10,43 @@
 #include <entt/meta/policy.hpp>
 #include <entt/meta/resolve.hpp>
 
-struct base {
-    char value{'c'};
-};
+struct MetaCtor: ::testing::Test {
+    struct base {
+        char value{'c'};
+    };
 
-struct derived: base {
-    derived()
-        : base{} {}
-};
+    struct derived: base {
+        derived()
+            : base{} {}
+    };
 
-struct clazz {
-    clazz(const base &other, int &iv)
-        : clazz{iv, other.value} {}
+    struct clazz {
+        clazz(const base &other, int &iv)
+            : clazz{iv, other.value} {}
 
-    clazz(const int &iv, char cv)
-        : i{iv}, c{cv} {}
+        clazz(const int &iv, char cv)
+            : i{iv}, c{cv} {}
 
-    operator int() const {
-        return i;
-    }
+        operator int() const {
+            return i;
+        }
 
-    static clazz factory(int value) {
-        return {value, 'c'};
-    }
+        static clazz factory(int value) {
+            return {value, 'c'};
+        }
 
-    static clazz factory(base other, int value, int mul) {
-        return {value * mul, other.value};
-    }
+        static clazz factory(base other, int value, int mul) {
+            return {value * mul, other.value};
+        }
 
-    int i{};
-    char c{};
-};
+        int i{};
+        char c{};
+    };
 
-double double_factory() {
-    return 1.;
-}
+    static double double_factory() {
+        return 1.;
+    }
 
-struct MetaCtor: ::testing::Test {
     void SetUp() override {
         using namespace entt::literals;
 

+ 11 - 11
test/entt/meta/meta_custom.cpp

@@ -5,20 +5,20 @@
 #include <entt/meta/resolve.hpp>
 #include "../../common/config.h"
 
-struct clazz {
-    int i{2};
-    char j{'c'};
+struct MetaCustom: ::testing::Test {
+    struct clazz {
+        int i{2};
+        char j{'c'};
 
-    [[nodiscard]] int f(int) const {
-        return i;
-    }
+        [[nodiscard]] int f(int) const {
+            return i;
+        }
 
-    [[nodiscard]] char g(char) const {
-        return j;
-    }
-};
+        [[nodiscard]] char g(char) const {
+            return j;
+        }
+    };
 
-struct MetaCustom: ::testing::Test {
     void SetUp() override {
         using namespace entt::literals;
 

+ 52 - 52
test/entt/meta/meta_data.cpp

@@ -15,59 +15,59 @@
 #include "../../common/config.h"
 #include "../../common/meta_traits.h"
 
-struct base {
-    virtual ~base() = default;
-    int value{3};
-};
-
-struct derived: base {};
-
-struct clazz {
-    operator int() const {
-        return h;
-    }
-
-    int i{0};
-    const int j{1}; // NOLINT
-    base instance{};
-    inline static int h{2};       // NOLINT
-    inline static const int k{3}; // NOLINT
-};
-
-struct setter_getter {
-    int setter(double val) {
-        return value = static_cast<int>(val);
-    }
-
-    [[nodiscard]] int getter() const {
-        return value;
-    }
-
-    int setter_with_ref(const int &val) {
-        return value = val;
-    }
-
-    [[nodiscard]] const int &getter_with_ref() const {
-        return value;
-    }
-
-    static int static_setter(setter_getter &type, int value) {
-        return type.value = value;
-    }
-
-    static int static_getter(const setter_getter &type) {
-        return type.value;
-    }
-
-    int value{0};
-};
-
-struct array {
-    inline static int global[2]; // NOLINT
-    int local[4];                // NOLINT
-};
-
 struct MetaData: ::testing::Test {
+    struct base {
+        virtual ~base() = default;
+        int value{3};
+    };
+
+    struct derived: base {};
+
+    struct clazz {
+        operator int() const {
+            return h;
+        }
+
+        int i{0};
+        const int j{1}; // NOLINT
+        base instance{};
+        inline static int h{2};       // NOLINT
+        inline static const int k{3}; // NOLINT
+    };
+
+    struct setter_getter {
+        int setter(double val) {
+            return value = static_cast<int>(val);
+        }
+
+        [[nodiscard]] int getter() const {
+            return value;
+        }
+
+        int setter_with_ref(const int &val) {
+            return value = val;
+        }
+
+        [[nodiscard]] const int &getter_with_ref() const {
+            return value;
+        }
+
+        static int static_setter(setter_getter &type, int value) {
+            return type.value = value;
+        }
+
+        static int static_getter(const setter_getter &type) {
+            return type.value;
+        }
+
+        int value{0};
+    };
+
+    struct array {
+        inline static int global[2]; // NOLINT
+        int local[4];                // NOLINT
+    };
+
     void SetUp() override {
         using namespace entt::literals;
 

+ 28 - 28
test/entt/meta/meta_factory.cpp

@@ -13,43 +13,43 @@
 #include "../../common/config.h"
 #include "../../common/meta_traits.h"
 
-struct base {
-    char member{};
-};
+struct MetaFactory: ::testing::Test {
+    struct base {
+        char member{};
+    };
 
-struct clazz: base {
-    clazz(int val)
-        : value{val} {}
+    struct clazz: base {
+        clazz(int val)
+            : value{val} {}
 
-    [[nodiscard]] explicit operator int() const noexcept {
-        return get_int();
-    }
+        [[nodiscard]] explicit operator int() const noexcept {
+            return get_int();
+        }
 
-    void set_int(int val) noexcept {
-        value = val;
-    }
+        void set_int(int val) noexcept {
+            value = val;
+        }
 
-    void set_boxed_int(test::boxed_int val) noexcept {
-        value = val.value;
-    }
+        void set_boxed_int(test::boxed_int val) noexcept {
+            value = val.value;
+        }
 
-    [[nodiscard]] int get_int() const noexcept {
-        return value;
-    }
+        [[nodiscard]] int get_int() const noexcept {
+            return value;
+        }
 
-    [[nodiscard]] static std::string to_string(const clazz &instance) {
-        return std::to_string(instance.get_int());
-    }
+        [[nodiscard]] static std::string to_string(const clazz &instance) {
+            return std::to_string(instance.get_int());
+        }
 
-    [[nodiscard]] static clazz from_string(const std::string &value) {
-        return clazz{std::stoi(value)};
-    }
+        [[nodiscard]] static clazz from_string(const std::string &value) {
+            return clazz{std::stoi(value)};
+        }
 
-private:
-    int value{};
-};
+    private:
+        int value{};
+    };
 
-struct MetaFactory: ::testing::Test {
     void TearDown() override {
         entt::meta_reset();
     }

+ 61 - 61
test/entt/meta/meta_func.cpp

@@ -13,87 +13,87 @@
 #include "../../common/config.h"
 #include "../../common/meta_traits.h"
 
-struct base {
-    base() = default;
-    virtual ~base() = default;
+struct MetaFunc: ::testing::Test {
+    struct base {
+        base() = default;
+        virtual ~base() = default;
 
-    void setter(int iv) {
-        value = iv;
-    }
+        void setter(int iv) {
+            value = iv;
+        }
 
-    [[nodiscard]] int getter() const {
-        return value;
-    }
+        [[nodiscard]] int getter() const {
+            return value;
+        }
 
-    static void static_setter(base &ref, int iv) {
-        ref.value = iv;
-    }
+        static void static_setter(base &ref, int iv) {
+            ref.value = iv;
+        }
 
-    int value{3};
-};
+        int value{3};
+    };
 
-void fake_member(base &instance, int value) {
-    instance.value = value;
-}
+    static void fake_member(base &instance, int value) {
+        instance.value = value;
+    }
 
-[[nodiscard]] int fake_const_member(const base &instance) {
-    return instance.value;
-}
+    [[nodiscard]] static int fake_const_member(const base &instance) {
+        return instance.value;
+    }
 
-struct derived: base {
-    derived() = default;
-};
+    struct derived: base {
+        derived() = default;
+    };
 
-struct function {
-    [[nodiscard]] int f(const base &, int val, int other) {
-        return f(val, other);
-    }
+    struct function {
+        [[nodiscard]] int f(const base &, int val, int other) {
+            return f(val, other);
+        }
 
-    [[nodiscard]] int f(int val, const int other) {
-        value = val;
-        return other * other;
-    }
+        [[nodiscard]] int f(int val, const int other) {
+            value = val;
+            return other * other;
+        }
 
-    [[nodiscard]] int f(int iv) const {
-        return value * iv;
-    }
+        [[nodiscard]] int f(int iv) const {
+            return value * iv;
+        }
 
-    [[nodiscard]] int f(int iv) {
-        return (value += iv);
-    }
+        [[nodiscard]] int f(int iv) {
+            return (value += iv);
+        }
 
-    void g(int iv) {
-        value = iv * iv;
-    }
+        void g(int iv) {
+            value = iv * iv;
+        }
 
-    [[nodiscard]] static int h(int &iv, const function &instance) {
-        return (iv *= instance.value);
-    }
+        [[nodiscard]] static int h(int &iv, const function &instance) {
+            return (iv *= instance.value);
+        }
 
-    static void k(int iv, function &instance) {
-        instance.value = iv;
-    }
+        static void k(int iv, function &instance) {
+            instance.value = iv;
+        }
 
-    [[nodiscard]] const int &v(int &iv) const {
-        return (iv = value);
-    }
+        [[nodiscard]] const int &v(int &iv) const {
+            return (iv = value);
+        }
 
-    [[nodiscard]] int &a() {
-        return value;
-    }
+        [[nodiscard]] int &a() {
+            return value;
+        }
 
-    [[nodiscard]] operator int() const {
-        return value;
-    }
+        [[nodiscard]] operator int() const {
+            return value;
+        }
 
-    int value{};
-};
+        int value{};
+    };
 
-double double_member(const double &value) {
-    return value * value;
-}
+    static double double_member(const double &value) {
+        return value * value;
+    }
 
-struct MetaFunc: ::testing::Test {
     void SetUp() override {
         using namespace entt::literals;
 

+ 10 - 10
test/entt/meta/meta_handle.cpp

@@ -6,19 +6,19 @@
 #include <entt/meta/factory.hpp>
 #include <entt/meta/meta.hpp>
 
-struct clazz {
-    void incr() {
-        ++value;
-    }
+struct MetaHandle: ::testing::Test {
+    struct clazz {
+        void incr() {
+            ++value;
+        }
 
-    void decr() {
-        --value;
-    }
+        void decr() {
+            --value;
+        }
 
-    int value{};
-};
+        int value{};
+    };
 
-struct MetaHandle: ::testing::Test {
     void SetUp() override {
         using namespace entt::literals;
 

+ 78 - 68
test/entt/meta/meta_pointer.cpp

@@ -3,76 +3,86 @@
 #include <utility>
 #include <gtest/gtest.h>
 #include <entt/meta/adl_pointer.hpp>
+#include <entt/meta/factory.hpp>
 #include <entt/meta/meta.hpp>
 #include <entt/meta/pointer.hpp>
 #include <entt/meta/resolve.hpp>
+#include <entt/meta/template.hpp>
 #include <entt/meta/type_traits.hpp>
 #include "../../common/config.h"
 
-template<typename Type>
-struct wrapped_shared_ptr {
-    wrapped_shared_ptr(Type init)
-        : ptr{new Type{init}} {}
+struct MetaPointer: ::testing::Test {
+    template<typename Type>
+    struct wrapped_shared_ptr {
+        wrapped_shared_ptr(Type init)
+            : ptr{new Type{init}} {}
 
-    [[nodiscard]] Type &deref() const {
-        return *ptr;
-    }
+        [[nodiscard]] Type &deref() const {
+            return *ptr;
+        }
 
-private:
-    std::shared_ptr<Type> ptr;
-};
+    private:
+        std::shared_ptr<Type> ptr;
+    };
 
-struct self_ptr {
-    using element_type = self_ptr;
+    struct self_ptr {
+        using element_type = self_ptr;
 
-    self_ptr(int val)
-        : value{val} {}
+        self_ptr(int val)
+            : value{val} {}
 
-    const self_ptr &operator*() const {
-        return *this;
-    }
+        const self_ptr &operator*() const {
+            return *this;
+        }
 
-    int value;
-};
+        int value;
+    };
 
-struct proxy_ptr {
-    using element_type = proxy_ptr;
+    struct proxy_ptr {
+        using element_type = proxy_ptr;
 
-    proxy_ptr(int &val)
-        : value{&val} {}
+        proxy_ptr(int &val)
+            : value{&val} {}
 
-    proxy_ptr operator*() const {
-        return *this;
-    }
+        proxy_ptr operator*() const {
+            return *this;
+        }
 
-    int *value;
-};
+        int *value;
+    };
 
-template<typename Type>
-struct adl_wrapped_shared_ptr: wrapped_shared_ptr<Type> {
-    using is_meta_pointer_like = void;
-};
+    template<typename Type>
+    struct adl_wrapped_shared_ptr: wrapped_shared_ptr<Type> {
+        using is_meta_pointer_like = void;
+    };
 
-template<typename Type>
-struct spec_wrapped_shared_ptr: wrapped_shared_ptr<Type> {
-    using is_meta_pointer_like = void;
+    template<typename Type>
+    struct spec_wrapped_shared_ptr: wrapped_shared_ptr<Type> {
+        using is_meta_pointer_like = void;
+    };
+
+    void TearDown() override {
+        entt::meta_reset();
+    }
 };
 
+using MetaPointerDeathTest = MetaPointer;
+
 template<>
-struct entt::is_meta_pointer_like<self_ptr>: std::true_type {};
+struct entt::is_meta_pointer_like<MetaPointer::self_ptr>: std::true_type {};
 
 template<>
-struct entt::is_meta_pointer_like<proxy_ptr>: std::true_type {};
+struct entt::is_meta_pointer_like<MetaPointer::proxy_ptr>: std::true_type {};
 
 template<typename Type>
-struct entt::adl_meta_pointer_like<spec_wrapped_shared_ptr<Type>> {
-    static decltype(auto) dereference(const spec_wrapped_shared_ptr<Type> &ptr) {
+struct entt::adl_meta_pointer_like<MetaPointer::spec_wrapped_shared_ptr<Type>> {
+    static decltype(auto) dereference(const MetaPointer::spec_wrapped_shared_ptr<Type> &ptr) {
         return ptr.deref();
     }
 };
 
 template<typename Type>
-Type &dereference_meta_pointer_like(const adl_wrapped_shared_ptr<Type> &ptr) {
+Type &dereference_meta_pointer_like(const MetaPointer::adl_wrapped_shared_ptr<Type> &ptr) {
     return ptr.deref();
 }
 
@@ -80,7 +90,7 @@ int test_function() {
     return 3;
 }
 
-TEST(MetaPointerLike, DereferenceOperatorInvalidType) {
+TEST_F(MetaPointer, DereferenceOperatorInvalidType) {
     const int value = 0;
     const entt::meta_any any{value};
 
@@ -93,7 +103,7 @@ TEST(MetaPointerLike, DereferenceOperatorInvalidType) {
     ASSERT_FALSE(deref);
 }
 
-TEST(MetaPointerLike, DereferenceOperatorConstType) {
+TEST_F(MetaPointer, DereferenceOperatorConstType) {
     const int value = 3;
     const entt::meta_any any{&value};
 
@@ -113,7 +123,7 @@ TEST(MetaPointerLike, DereferenceOperatorConstType) {
     ASSERT_EQ(deref.cast<const int &>(), 3);
 }
 
-ENTT_DEBUG_TEST(MetaPointerLikeDeathTest, DereferenceOperatorConstType) {
+ENTT_DEBUG_TEST_F(MetaPointerDeathTest, DereferenceOperatorConstType) {
     const int value = 3;
     const entt::meta_any any{&value};
     auto deref = *any;
@@ -122,7 +132,7 @@ ENTT_DEBUG_TEST(MetaPointerLikeDeathTest, DereferenceOperatorConstType) {
     ASSERT_DEATH(deref.cast<int &>() = 0, "");
 }
 
-TEST(MetaPointerLike, DereferenceOperatorConstAnyNonConstType) {
+TEST_F(MetaPointer, DereferenceOperatorConstAnyNonConstType) {
     int value = 3;
     const entt::meta_any any{&value};
     auto deref = *any;
@@ -138,7 +148,7 @@ TEST(MetaPointerLike, DereferenceOperatorConstAnyNonConstType) {
     ASSERT_EQ(deref.cast<const int &>(), 3);
 }
 
-TEST(MetaPointerLike, DereferenceOperatorConstAnyConstType) {
+TEST_F(MetaPointer, DereferenceOperatorConstAnyConstType) {
     const int value = 3;
     const entt::meta_any any{&value};
     auto deref = *any;
@@ -153,7 +163,7 @@ TEST(MetaPointerLike, DereferenceOperatorConstAnyConstType) {
     ASSERT_EQ(deref.cast<const int &>(), 3);
 }
 
-ENTT_DEBUG_TEST(MetaPointerLikeDeathTest, DereferenceOperatorConstAnyConstType) {
+ENTT_DEBUG_TEST_F(MetaPointerDeathTest, DereferenceOperatorConstAnyConstType) {
     const int value = 3;
     const entt::meta_any any{&value};
     auto deref = *any;
@@ -162,7 +172,7 @@ ENTT_DEBUG_TEST(MetaPointerLikeDeathTest, DereferenceOperatorConstAnyConstType)
     ASSERT_DEATH(deref.cast<int &>() = 0, "");
 }
 
-TEST(MetaPointerLike, DereferenceOperatorRawPointer) {
+TEST_F(MetaPointer, DereferenceOperatorRawPointer) {
     int value = 0;
     entt::meta_any any{&value};
 
@@ -183,7 +193,7 @@ TEST(MetaPointerLike, DereferenceOperatorRawPointer) {
     ASSERT_EQ(value, 3);
 }
 
-TEST(MetaPointerLike, DereferenceOperatorSmartPointer) {
+TEST_F(MetaPointer, DereferenceOperatorSmartPointer) {
     auto value = std::make_shared<int>(0);
     entt::meta_any any{value};
 
@@ -204,7 +214,7 @@ TEST(MetaPointerLike, DereferenceOperatorSmartPointer) {
     ASSERT_EQ(*value, 3);
 }
 
-TEST(MetaPointerLike, PointerToConstMoveOnlyType) {
+TEST_F(MetaPointer, PointerToConstMoveOnlyType) {
     const std::unique_ptr<int> instance;
     const entt::meta_any any{&instance};
     auto deref = *any;
@@ -217,7 +227,7 @@ TEST(MetaPointerLike, PointerToConstMoveOnlyType) {
     ASSERT_EQ(&deref.cast<const std::unique_ptr<int> &>(), &instance);
 }
 
-TEST(MetaPointerLike, AsRef) {
+TEST_F(MetaPointer, AsRef) {
     int value = 0;
     int *ptr = &value;
     entt::meta_any any{entt::forward_as_meta(ptr)};
@@ -239,7 +249,7 @@ TEST(MetaPointerLike, AsRef) {
     ASSERT_EQ(value, 3);
 }
 
-TEST(MetaPointerLike, AsConstRef) {
+TEST_F(MetaPointer, AsConstRef) {
     int value = 3;
     int *const ptr = &value;
     entt::meta_any any{entt::forward_as_meta(ptr)};
@@ -261,7 +271,7 @@ TEST(MetaPointerLike, AsConstRef) {
     ASSERT_EQ(value, 3);
 }
 
-TEST(MetaPointerLike, DereferenceOverloadAdl) {
+TEST_F(MetaPointer, DereferenceOverloadAdl) {
     const entt::meta_any any{adl_wrapped_shared_ptr<int>{3}};
 
     ASSERT_FALSE(any.type().is_pointer());
@@ -278,7 +288,7 @@ TEST(MetaPointerLike, DereferenceOverloadAdl) {
     ASSERT_EQ(deref.cast<const int &>(), 3);
 }
 
-TEST(MetaPointerLike, DereferenceOverloadSpec) {
+TEST_F(MetaPointer, DereferenceOverloadSpec) {
     const entt::meta_any any{spec_wrapped_shared_ptr<int>{3}};
 
     ASSERT_FALSE(any.type().is_pointer());
@@ -295,7 +305,7 @@ TEST(MetaPointerLike, DereferenceOverloadSpec) {
     ASSERT_EQ(deref.cast<const int &>(), 3);
 }
 
-TEST(MetaPointerLike, DereferencePointerToConstOverloadAdl) {
+TEST_F(MetaPointer, DereferencePointerToConstOverloadAdl) {
     const entt::meta_any any{adl_wrapped_shared_ptr<const int>{3}};
 
     ASSERT_FALSE(any.type().is_pointer());
@@ -310,7 +320,7 @@ TEST(MetaPointerLike, DereferencePointerToConstOverloadAdl) {
     ASSERT_EQ(deref.cast<const int &>(), 3);
 }
 
-TEST(MetaPointerLike, DereferencePointerToConstOverloadSpec) {
+TEST_F(MetaPointer, DereferencePointerToConstOverloadSpec) {
     const entt::meta_any any{spec_wrapped_shared_ptr<const int>{3}};
 
     ASSERT_FALSE(any.type().is_pointer());
@@ -325,7 +335,7 @@ TEST(MetaPointerLike, DereferencePointerToConstOverloadSpec) {
     ASSERT_EQ(deref.cast<const int &>(), 3);
 }
 
-ENTT_DEBUG_TEST(MetaPointerLikeDeathTest, DereferencePointerToConstOverloadAdl) {
+ENTT_DEBUG_TEST_F(MetaPointerDeathTest, DereferencePointerToConstOverloadAdl) {
     const entt::meta_any any{adl_wrapped_shared_ptr<const int>{3}};
 
     auto deref = *any;
@@ -334,7 +344,7 @@ ENTT_DEBUG_TEST(MetaPointerLikeDeathTest, DereferencePointerToConstOverloadAdl)
     ASSERT_DEATH(deref.cast<int &>() = 3, "");
 }
 
-ENTT_DEBUG_TEST(MetaPointerLikeDeathTest, DereferencePointerToConstOverloadSpec) {
+ENTT_DEBUG_TEST_F(MetaPointerDeathTest, DereferencePointerToConstOverloadSpec) {
     const entt::meta_any any{spec_wrapped_shared_ptr<const int>{3}};
 
     auto deref = *any;
@@ -343,7 +353,7 @@ ENTT_DEBUG_TEST(MetaPointerLikeDeathTest, DereferencePointerToConstOverloadSpec)
     ASSERT_DEATH(deref.cast<int &>() = 3, "");
 }
 
-TEST(MetaPointerLike, DereferencePointerToVoid) {
+TEST_F(MetaPointer, DereferencePointerToVoid) {
     const entt::meta_any any{static_cast<void *>(nullptr)};
 
     ASSERT_TRUE(any.type().is_pointer());
@@ -354,7 +364,7 @@ TEST(MetaPointerLike, DereferencePointerToVoid) {
     ASSERT_FALSE(deref);
 }
 
-TEST(MetaPointerLike, DereferencePointerToConstVoid) {
+TEST_F(MetaPointer, DereferencePointerToConstVoid) {
     const entt::meta_any any{static_cast<const void *>(nullptr)};
 
     ASSERT_TRUE(any.type().is_pointer());
@@ -365,7 +375,7 @@ TEST(MetaPointerLike, DereferencePointerToConstVoid) {
     ASSERT_FALSE(deref);
 }
 
-TEST(MetaPointerLike, DereferenceSharedPointerToVoid) {
+TEST_F(MetaPointer, DereferenceSharedPointerToVoid) {
     const entt::meta_any any{std::shared_ptr<void>{}};
 
     ASSERT_TRUE(any.type().is_class());
@@ -377,7 +387,7 @@ TEST(MetaPointerLike, DereferenceSharedPointerToVoid) {
     ASSERT_FALSE(deref);
 }
 
-TEST(MetaPointerLike, DereferenceUniquePointerToVoid) {
+TEST_F(MetaPointer, DereferenceUniquePointerToVoid) {
     const entt::meta_any any{std::unique_ptr<void, void (*)(void *)>{nullptr, nullptr}};
 
     ASSERT_TRUE(any.type().is_class());
@@ -389,7 +399,7 @@ TEST(MetaPointerLike, DereferenceUniquePointerToVoid) {
     ASSERT_FALSE(deref);
 }
 
-TEST(MetaPointerLike, DereferencePointerToFunction) {
+TEST_F(MetaPointer, DereferencePointerToFunction) {
     entt::meta_any any{&test_function};
 
     ASSERT_TRUE(any.type().is_pointer());
@@ -398,7 +408,7 @@ TEST(MetaPointerLike, DereferencePointerToFunction) {
     ASSERT_EQ((***std::as_const(any)).cast<int (*)()>()(), 3);
 }
 
-TEST(MetaPointerLike, DereferenceSelfPointer) {
+TEST_F(MetaPointer, DereferenceSelfPointer) {
     self_ptr obj{3};
     const entt::meta_any any{entt::forward_as_meta(obj)};
     entt::meta_any deref = *any;
@@ -409,7 +419,7 @@ TEST(MetaPointerLike, DereferenceSelfPointer) {
     ASSERT_FALSE(deref.try_cast<self_ptr>());
 }
 
-TEST(MetaPointerLike, DereferenceProxyPointer) {
+TEST_F(MetaPointer, DereferenceProxyPointer) {
     int value = 3;
     const proxy_ptr obj{value};
     const entt::meta_any any{obj};
@@ -425,7 +435,7 @@ TEST(MetaPointerLike, DereferenceProxyPointer) {
     ASSERT_EQ(value, 3);
 }
 
-TEST(MetaPointerLike, DereferenceArray) {
+TEST_F(MetaPointer, DereferenceArray) {
     // NOLINTBEGIN(*-avoid-c-arrays)
     const entt::meta_any array{std::in_place_type<int[3]>};
     const entt::meta_any array_of_array{std::in_place_type<int[3][3]>};
@@ -440,21 +450,21 @@ TEST(MetaPointerLike, DereferenceArray) {
     ASSERT_FALSE(*array_of_array);
 }
 
-TEST(MetaPointerLike, DereferencePlainNullPointer) {
+TEST_F(MetaPointer, DereferencePlainNullPointer) {
     const entt::meta_any any{static_cast<int *>(nullptr)};
 
     ASSERT_TRUE(any);
     ASSERT_FALSE(*any);
 }
 
-TEST(MetaPointerLike, DereferenceSharedNullPointer) {
+TEST_F(MetaPointer, DereferenceSharedNullPointer) {
     const entt::meta_any any{std::shared_ptr<int>{}};
 
     ASSERT_TRUE(any);
     ASSERT_FALSE(*any);
 }
 
-TEST(MetaPointerLike, DereferenceUniqueNullPointer) {
+TEST_F(MetaPointer, DereferenceUniqueNullPointer) {
     const entt::meta_any any{std::unique_ptr<int>{}};
 
     ASSERT_TRUE(any);

+ 11 - 9
test/entt/meta/meta_template.cpp

@@ -5,19 +5,21 @@
 #include <entt/meta/template.hpp>
 #include <entt/meta/type_traits.hpp>
 
-template<typename>
-struct function_type;
+struct MetaTemplate: ::testing::Test {
+    template<typename>
+    struct function_type;
 
-template<typename Ret, typename... Args>
-struct function_type<Ret(Args...)> {};
+    template<typename Ret, typename... Args>
+    struct function_type<Ret(Args...)> {};
+};
 
 template<typename Ret, typename... Args>
-struct entt::meta_template_traits<function_type<Ret(Args...)>> {
-    using class_type = meta_class_template_tag<function_type>;
+struct entt::meta_template_traits<MetaTemplate::function_type<Ret(Args...)>> {
+    using class_type = meta_class_template_tag<MetaTemplate::function_type>;
     using args_type = type_list<Ret, Args...>;
 };
 
-TEST(MetaTemplate, Invalid) {
+TEST_F(MetaTemplate, Invalid) {
     const auto type = entt::resolve<int>();
 
     ASSERT_FALSE(type.is_template_specialization());
@@ -26,7 +28,7 @@ TEST(MetaTemplate, Invalid) {
     ASSERT_EQ(type.template_arg(0u), entt::meta_type{});
 }
 
-TEST(MetaTemplate, Valid) {
+TEST_F(MetaTemplate, Valid) {
     const auto type = entt::resolve<entt::type_list<int, char>>();
 
     ASSERT_TRUE(type.is_template_specialization());
@@ -37,7 +39,7 @@ TEST(MetaTemplate, Valid) {
     ASSERT_EQ(type.template_arg(2u), entt::meta_type{});
 }
 
-TEST(MetaTemplate, CustomTraits) {
+TEST_F(MetaTemplate, CustomTraits) {
     const auto type = entt::resolve<function_type<void(int, const char &)>>();
 
     ASSERT_TRUE(type.is_template_specialization());

+ 77 - 77
test/entt/meta/meta_type.cpp

@@ -20,108 +20,108 @@
 #include "../../common/config.h"
 #include "../../common/meta_traits.h"
 
-template<typename Type>
-void set(Type &elem, Type value) {
-    elem = value;
-}
+struct MetaType: ::testing::Test {
+    template<typename Type>
+    static void set(Type &elem, Type value) {
+        elem = value;
+    }
 
-template<typename Type>
-Type get(Type &elem) {
-    return elem;
-}
+    template<typename Type>
+    static Type get(Type &elem) {
+        return elem;
+    }
 
-struct base {
-    char value{'c'};
+    struct base {
+        char value{'c'};
 
-    static int f() {
-        return 0;
-    }
-};
+        static int f() {
+            return 0;
+        }
+    };
 
-struct derived: base {
-    derived()
-        : base{} {}
-};
+    struct derived: base {
+        derived()
+            : base{} {}
+    };
 
-struct abstract {
-    virtual ~abstract() = default;
+    struct abstract {
+        virtual ~abstract() = default;
 
-    virtual void func(int) {}
-    void base_only(int) {}
-};
+        virtual void func(int) {}
+        void base_only(int) {}
+    };
 
-struct concrete: base, abstract {
-    void func(int val) override {
-        abstract::func(val);
-        value = val;
-    }
+    struct concrete: base, abstract {
+        void func(int val) override {
+            abstract::func(val);
+            value = val;
+        }
 
-    int value{3};
-};
+        int value{3};
+    };
 
-struct clazz {
-    clazz() = default;
+    struct clazz {
+        clazz() = default;
 
-    clazz(const base &, int val)
-        : value{val} {}
+        clazz(const base &, int val)
+            : value{val} {}
 
-    void member() {}
-    static void func() {}
+        void member() {}
+        static void func() {}
 
-    [[nodiscard]] operator int() const {
-        return value;
-    }
+        [[nodiscard]] operator int() const {
+            return value;
+        }
 
-    int value{};
-};
+        int value{};
+    };
 
-struct overloaded_func {
-    [[nodiscard]] int f(const base &, int first, int second) {
-        return f(first, second);
-    }
+    struct overloaded_func {
+        [[nodiscard]] int f(const base &, int first, int second) {
+            return f(first, second);
+        }
 
-    [[nodiscard]] int f(int first, const int second) {
-        value = first;
-        return second * second;
-    }
+        [[nodiscard]] int f(int first, const int second) {
+            value = first;
+            return second * second;
+        }
 
-    [[nodiscard]] int f(int val) {
-        return 2 * std::as_const(*this).f(val);
-    }
+        [[nodiscard]] int f(int val) {
+            return 2 * std::as_const(*this).f(val);
+        }
 
-    [[nodiscard]] int f(int val) const {
-        return val * value;
-    }
+        [[nodiscard]] int f(int val) const {
+            return val * value;
+        }
 
-    [[nodiscard]] float f(int first, const float second) {
-        value = first;
-        return second + second;
-    }
+        [[nodiscard]] float f(int first, const float second) {
+            value = first;
+            return second + second;
+        }
 
-    int value{};
-};
+        int value{};
+    };
 
-struct from_void_callback {
-    from_void_callback(bool &ref)
-        : cb{&ref} {}
+    struct from_void_callback {
+        from_void_callback(bool &ref)
+            : cb{&ref} {}
 
-    from_void_callback(const from_void_callback &) = delete;
-    from_void_callback &operator=(const from_void_callback &) = delete;
+        from_void_callback(const from_void_callback &) = delete;
+        from_void_callback &operator=(const from_void_callback &) = delete;
 
-    ~from_void_callback() {
-        *cb = !*cb;
-    }
+        ~from_void_callback() {
+            *cb = !*cb;
+        }
 
-private:
-    bool *cb;
-};
+    private:
+        bool *cb;
+    };
 
-enum class property_type : std::uint8_t {
-    value,
-    other
-};
+    enum class property_type : std::uint8_t {
+        value,
+        other
+    };
 
-struct MetaType: ::testing::Test {
     void SetUp() override {
         using namespace entt::literals;
 

+ 38 - 38
test/entt/meta/meta_utility.cpp

@@ -10,45 +10,45 @@
 #include "../../common/config.h"
 #include "../../common/empty.h"
 
-struct clazz {
-    void setter(int iv) {
-        member = iv;
-    }
-
-    [[nodiscard]] int getter() const {
-        return member;
-    }
-
-    static void static_setter(clazz &instance, int iv) {
-        instance.member = iv;
-    }
-
-    [[nodiscard]] static int static_getter(const clazz &instance) {
-        return instance.member;
-    }
-
-    static void reset_value() {
-        value = 0;
-    }
-
-    [[nodiscard]] static int get_value() {
-        return value;
-    }
-
-    [[nodiscard]] static clazz factory(int iv) {
-        clazz instance{};
-        instance.member = iv;
-        return instance;
-    }
-
-    int member{};
-    const int cmember{};              // NOLINT
-    inline static int value{};        // NOLINT
-    inline static const int cvalue{}; // NOLINT
-    inline static int arr[3u]{};      // NOLINT
-};
-
 struct MetaUtility: ::testing::Test {
+    struct clazz {
+        void setter(int iv) {
+            member = iv;
+        }
+
+        [[nodiscard]] int getter() const {
+            return member;
+        }
+
+        static void static_setter(clazz &instance, int iv) {
+            instance.member = iv;
+        }
+
+        [[nodiscard]] static int static_getter(const clazz &instance) {
+            return instance.member;
+        }
+
+        static void reset_value() {
+            value = 0;
+        }
+
+        [[nodiscard]] static int get_value() {
+            return value;
+        }
+
+        [[nodiscard]] static clazz factory(int iv) {
+            clazz instance{};
+            instance.member = iv;
+            return instance;
+        }
+
+        int member{};
+        const int cmember{};              // NOLINT
+        inline static int value{};        // NOLINT
+        inline static const int cvalue{}; // NOLINT
+        inline static int arr[3u]{};      // NOLINT
+    };
+
     void SetUp() override {
         clazz::value = 0;
     }