From 6b8fe4deff4e6506dffaa3bd869be40b19be7c0d Mon Sep 17 00:00:00 2001 From: skypjack Date: Tue, 3 Mar 2026 10:10:46 +0100 Subject: [PATCH] test: use the mixin design a little more --- test/common/boxed_type.h | 24 ------------------------ test/common/value_type.h | 20 +++++++++++++------- test/entt/core/algorithm.cpp | 2 +- test/entt/core/ident.cpp | 1 - test/entt/core/iterator.cpp | 2 +- test/entt/entity/component.cpp | 1 - test/entt/entity/group.cpp | 1 - test/entt/entity/view.cpp | 1 - test/entt/meta/meta_factory.cpp | 2 +- test/entt/signal/emitter.cpp | 1 - test/lib/dispatcher/plugin/main.cpp | 2 +- test/lib/dispatcher/plugin/plugin.cpp | 1 - test/lib/dispatcher/shared/lib.cpp | 1 - test/lib/dispatcher/shared/main.cpp | 2 +- test/lib/emitter/plugin/main.cpp | 2 +- test/lib/emitter/plugin/plugin.cpp | 1 - test/lib/emitter/shared/lib.cpp | 1 - test/lib/emitter/shared/main.cpp | 2 +- test/lib/locator/plugin/main.cpp | 2 +- test/lib/locator/plugin/plugin.cpp | 2 +- test/lib/locator/plugin/userdata.h | 2 +- test/lib/locator/shared/lib.cpp | 2 +- test/lib/locator/shared/lib.h | 2 +- test/lib/locator/shared/main.cpp | 2 +- test/lib/meta/plugin/plugin.cpp | 1 - test/lib/meta/plugin_std/plugin.cpp | 1 - test/lib/meta/plugin_std/userdata.h | 1 - test/lib/meta/shared/lib.cpp | 1 - test/lib/meta/shared/main.cpp | 1 - test/lib/registry/plugin/main.cpp | 1 - test/lib/registry/plugin/plugin.cpp | 1 - test/lib/registry/shared/lib.cpp | 1 - test/lib/registry/shared/main.cpp | 1 - 33 files changed, 26 insertions(+), 62 deletions(-) delete mode 100644 test/common/boxed_type.h diff --git a/test/common/boxed_type.h b/test/common/boxed_type.h deleted file mode 100644 index 7f96cd9f1..000000000 --- a/test/common/boxed_type.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef ENTT_COMMON_BOXED_TYPE_H -#define ENTT_COMMON_BOXED_TYPE_H - -namespace test { - -template -struct boxed_type { - Type value{}; - - operator Type() const noexcept { - return value; - } - - [[nodiscard]] bool operator==(const boxed_type &other) const noexcept { - return value == other.value; - } -}; - -using boxed_int = boxed_type; -using boxed_char = boxed_type; - -} // namespace test - -#endif diff --git a/test/common/value_type.h b/test/common/value_type.h index 2fb76809b..768fbac33 100644 --- a/test/common/value_type.h +++ b/test/common/value_type.h @@ -47,22 +47,28 @@ struct non_movable_mixin: Type { struct empty_type {}; +template struct value_type { constexpr value_type() = default; - constexpr value_type(int elem): value{elem} {} + constexpr value_type(Type elem): value{elem} {} [[nodiscard]] constexpr bool operator==(const value_type &) const noexcept = default; [[nodiscard]] constexpr auto operator<=>(const value_type &) const noexcept = default; - int value{}; + operator Type() const noexcept { return value; } + Type value{}; }; } // namespace internal -using pointer_stable = internal::pointer_stable_mixin; -using non_default_constructible = internal::non_default_constructible_mixin; -using non_trivially_destructible = internal::non_trivially_destructible_mixin; -using pointer_stable_non_trivially_destructible = internal::pointer_stable_mixin>; +using pointer_stable = internal::pointer_stable_mixin>; +using pointer_stable_non_trivially_destructible = internal::pointer_stable_mixin>>; + +using non_default_constructible = internal::non_default_constructible_mixin>; +using non_trivially_destructible = internal::non_trivially_destructible_mixin>; using non_comparable = internal::non_comparable_mixin; -using non_movable = internal::non_movable_mixin; +using non_movable = internal::non_movable_mixin>; + +using boxed_int = internal::value_type; +using boxed_char = internal::value_type; using empty = internal::empty_type; struct other_empty: internal::empty_type {}; diff --git a/test/entt/core/algorithm.cpp b/test/entt/core/algorithm.cpp index 0271f6bde..360cd349f 100644 --- a/test/entt/core/algorithm.cpp +++ b/test/entt/core/algorithm.cpp @@ -3,7 +3,7 @@ #include #include #include -#include "../../common/boxed_type.h" +#include "../../common/value_type.h" TEST(Algorithm, StdSort) { // well, I'm pretty sure it works, it's std::sort!! diff --git a/test/entt/core/ident.cpp b/test/entt/core/ident.cpp index 8531fa3ba..5aceac554 100644 --- a/test/entt/core/ident.cpp +++ b/test/entt/core/ident.cpp @@ -1,7 +1,6 @@ #include #include #include -#include "../../common/boxed_type.h" #include "../../common/value_type.h" TEST(Ident, Uniqueness) { diff --git a/test/entt/core/iterator.cpp b/test/entt/core/iterator.cpp index 8b2cb75cc..bb195f12f 100644 --- a/test/entt/core/iterator.cpp +++ b/test/entt/core/iterator.cpp @@ -3,7 +3,7 @@ #include #include #include -#include "../../common/boxed_type.h" +#include "../../common/value_type.h" TEST(Iterator, InputIteratorPointer) { entt::input_iterator_pointer ptr{test::boxed_int{0}}; diff --git a/test/entt/entity/component.cpp b/test/entt/entity/component.cpp index f87b0cc41..bc793d39e 100644 --- a/test/entt/entity/component.cpp +++ b/test/entt/entity/component.cpp @@ -2,7 +2,6 @@ #include #include #include -#include "../../common/boxed_type.h" #include "../../common/value_type.h" struct ComponentBase: testing::Test { diff --git a/test/entt/entity/group.cpp b/test/entt/entity/group.cpp index 93bc10c9a..18a6abb6f 100644 --- a/test/entt/entity/group.cpp +++ b/test/entt/entity/group.cpp @@ -11,7 +11,6 @@ #include #include #include -#include "../../common/boxed_type.h" #include "../../common/config.h" #include "../../common/value_type.h" diff --git a/test/entt/entity/view.cpp b/test/entt/entity/view.cpp index 5b11da7d5..da538f28c 100644 --- a/test/entt/entity/view.cpp +++ b/test/entt/entity/view.cpp @@ -8,7 +8,6 @@ #include #include #include -#include "../../common/boxed_type.h" #include "../../common/value_type.h" TEST(ViewSingleStorage, Functionalities) { diff --git a/test/entt/meta/meta_factory.cpp b/test/entt/meta/meta_factory.cpp index 72e4cfb55..92db290ae 100644 --- a/test/entt/meta/meta_factory.cpp +++ b/test/entt/meta/meta_factory.cpp @@ -9,9 +9,9 @@ #include #include #include -#include "../../common/boxed_type.h" #include "../../common/config.h" #include "../../common/meta_traits.h" +#include "../../common/value_type.h" struct MetaFactory: ::testing::Test { struct base { diff --git a/test/entt/signal/emitter.cpp b/test/entt/signal/emitter.cpp index 8d0069ae2..9dbbbba18 100644 --- a/test/entt/signal/emitter.cpp +++ b/test/entt/signal/emitter.cpp @@ -3,7 +3,6 @@ #include #include #include -#include "../../common/boxed_type.h" #include "../../common/emitter.h" #include "../../common/linter.hpp" #include "../../common/value_type.h" diff --git a/test/lib/dispatcher/plugin/main.cpp b/test/lib/dispatcher/plugin/main.cpp index 83f1bce39..ce0c5d3c4 100644 --- a/test/lib/dispatcher/plugin/main.cpp +++ b/test/lib/dispatcher/plugin/main.cpp @@ -4,8 +4,8 @@ #include #include #include -#include "../../../common/boxed_type.h" #include "../../../common/listener.h" +#include "../../../common/value_type.h" TEST(Dispatcher, Plugin) { entt::dispatcher dispatcher; diff --git a/test/lib/dispatcher/plugin/plugin.cpp b/test/lib/dispatcher/plugin/plugin.cpp index 758064b3a..eece2f2df 100644 --- a/test/lib/dispatcher/plugin/plugin.cpp +++ b/test/lib/dispatcher/plugin/plugin.cpp @@ -1,6 +1,5 @@ #include #include -#include "../../../common/boxed_type.h" #include "../../../common/value_type.h" CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) { diff --git a/test/lib/dispatcher/shared/lib.cpp b/test/lib/dispatcher/shared/lib.cpp index 1a6354f34..a4aee24a5 100644 --- a/test/lib/dispatcher/shared/lib.cpp +++ b/test/lib/dispatcher/shared/lib.cpp @@ -1,6 +1,5 @@ #include #include -#include "../../../common/boxed_type.h" #include "../../../common/value_type.h" #include "lib.h" diff --git a/test/lib/dispatcher/shared/main.cpp b/test/lib/dispatcher/shared/main.cpp index 8b4ad0a39..6f54ae477 100644 --- a/test/lib/dispatcher/shared/main.cpp +++ b/test/lib/dispatcher/shared/main.cpp @@ -3,8 +3,8 @@ #include #include #include -#include "../../../common/boxed_type.h" #include "../../../common/listener.h" +#include "../../../common/value_type.h" #include "lib.h" TEST(Dispatcher, Shared) { diff --git a/test/lib/emitter/plugin/main.cpp b/test/lib/emitter/plugin/main.cpp index 4c0be18cc..25387a50a 100644 --- a/test/lib/emitter/plugin/main.cpp +++ b/test/lib/emitter/plugin/main.cpp @@ -3,8 +3,8 @@ #include #include #include -#include "../../../common/boxed_type.h" #include "../../../common/emitter.h" +#include "../../../common/value_type.h" TEST(Emitter, Plugin) { test::emitter emitter; diff --git a/test/lib/emitter/plugin/plugin.cpp b/test/lib/emitter/plugin/plugin.cpp index 85db7ec1c..43f768100 100644 --- a/test/lib/emitter/plugin/plugin.cpp +++ b/test/lib/emitter/plugin/plugin.cpp @@ -1,5 +1,4 @@ #include -#include "../../../common/boxed_type.h" #include "../../../common/emitter.h" #include "../../../common/value_type.h" diff --git a/test/lib/emitter/shared/lib.cpp b/test/lib/emitter/shared/lib.cpp index 86e6e55bf..36109925f 100644 --- a/test/lib/emitter/shared/lib.cpp +++ b/test/lib/emitter/shared/lib.cpp @@ -1,5 +1,4 @@ #include -#include "../../../common/boxed_type.h" #include "../../../common/emitter.h" #include "../../../common/value_type.h" #include "lib.h" diff --git a/test/lib/emitter/shared/main.cpp b/test/lib/emitter/shared/main.cpp index 71ee8bff6..fb8fe6425 100644 --- a/test/lib/emitter/shared/main.cpp +++ b/test/lib/emitter/shared/main.cpp @@ -1,8 +1,8 @@ #include #include #include -#include "../../../common/boxed_type.h" #include "../../../common/emitter.h" +#include "../../../common/value_type.h" #include "lib.h" TEST(Emitter, Shared) { diff --git a/test/lib/locator/plugin/main.cpp b/test/lib/locator/plugin/main.cpp index 57c2b8f93..957756dcc 100644 --- a/test/lib/locator/plugin/main.cpp +++ b/test/lib/locator/plugin/main.cpp @@ -3,7 +3,7 @@ #include #include #include -#include "../../../common/boxed_type.h" +#include "../../../common/value_type.h" #include "userdata.h" TEST(Locator, Plugin) { diff --git a/test/lib/locator/plugin/plugin.cpp b/test/lib/locator/plugin/plugin.cpp index 96ec57de6..3d94f77ee 100644 --- a/test/lib/locator/plugin/plugin.cpp +++ b/test/lib/locator/plugin/plugin.cpp @@ -1,6 +1,6 @@ #include #include -#include "../../../common/boxed_type.h" +#include "../../../common/value_type.h" #include "userdata.h" CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) { diff --git a/test/lib/locator/plugin/userdata.h b/test/lib/locator/plugin/userdata.h index aa35a3d4d..682618f77 100644 --- a/test/lib/locator/plugin/userdata.h +++ b/test/lib/locator/plugin/userdata.h @@ -2,7 +2,7 @@ #define ENTT_LIB_LOCATOR_PLUGIN_USERDATA_H #include -#include "../../../common/boxed_type.h" +#include "../../../common/value_type.h" struct userdata { entt::locator::node_type handle{}; diff --git a/test/lib/locator/shared/lib.cpp b/test/lib/locator/shared/lib.cpp index c3ae4d361..68fe370c0 100644 --- a/test/lib/locator/shared/lib.cpp +++ b/test/lib/locator/shared/lib.cpp @@ -1,6 +1,6 @@ #include #include -#include "../../../common/boxed_type.h" +#include "../../../common/value_type.h" #include "lib.h" ENTT_API void set_up(const entt::locator::node_type &handle) { diff --git a/test/lib/locator/shared/lib.h b/test/lib/locator/shared/lib.h index 09aa1e568..1e9cbef4d 100644 --- a/test/lib/locator/shared/lib.h +++ b/test/lib/locator/shared/lib.h @@ -1,6 +1,6 @@ #include #include -#include "../../../common/boxed_type.h" +#include "../../../common/value_type.h" ENTT_API void set_up(const entt::locator::node_type &); ENTT_API void use_service(int); diff --git a/test/lib/locator/shared/main.cpp b/test/lib/locator/shared/main.cpp index ac5e5343d..dbdc8b42f 100644 --- a/test/lib/locator/shared/main.cpp +++ b/test/lib/locator/shared/main.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "../../../common/boxed_type.h" +#include "../../../common/value_type.h" #include "lib.h" TEST(Locator, Shared) { diff --git a/test/lib/meta/plugin/plugin.cpp b/test/lib/meta/plugin/plugin.cpp index 75eab38ca..fc55d0a08 100644 --- a/test/lib/meta/plugin/plugin.cpp +++ b/test/lib/meta/plugin/plugin.cpp @@ -4,7 +4,6 @@ #include #include #include -#include "../../../common/boxed_type.h" #include "../../../common/value_type.h" #include "userdata.h" diff --git a/test/lib/meta/plugin_std/plugin.cpp b/test/lib/meta/plugin_std/plugin.cpp index 75eab38ca..fc55d0a08 100644 --- a/test/lib/meta/plugin_std/plugin.cpp +++ b/test/lib/meta/plugin_std/plugin.cpp @@ -4,7 +4,6 @@ #include #include #include -#include "../../../common/boxed_type.h" #include "../../../common/value_type.h" #include "userdata.h" diff --git a/test/lib/meta/plugin_std/userdata.h b/test/lib/meta/plugin_std/userdata.h index 5c89067c5..e8548897e 100644 --- a/test/lib/meta/plugin_std/userdata.h +++ b/test/lib/meta/plugin_std/userdata.h @@ -6,7 +6,6 @@ #include #include #include -#include "../../../common/boxed_type.h" #include "../../../common/value_type.h" #define ASSIGN_TYPE_ID(clazz) \ diff --git a/test/lib/meta/shared/lib.cpp b/test/lib/meta/shared/lib.cpp index 31f78c05e..e13fe0ee8 100644 --- a/test/lib/meta/shared/lib.cpp +++ b/test/lib/meta/shared/lib.cpp @@ -4,7 +4,6 @@ #include #include #include -#include "../../../common/boxed_type.h" #include "../../../common/value_type.h" #include "lib.h" diff --git a/test/lib/meta/shared/main.cpp b/test/lib/meta/shared/main.cpp index c298e1ca9..9d8f0bef2 100644 --- a/test/lib/meta/shared/main.cpp +++ b/test/lib/meta/shared/main.cpp @@ -5,7 +5,6 @@ #include #include #include -#include "../../../common/boxed_type.h" #include "../../../common/value_type.h" #include "lib.h" diff --git a/test/lib/registry/plugin/main.cpp b/test/lib/registry/plugin/main.cpp index f767f32db..253e0fb66 100644 --- a/test/lib/registry/plugin/main.cpp +++ b/test/lib/registry/plugin/main.cpp @@ -6,7 +6,6 @@ #include #include #include -#include "../../../common/boxed_type.h" #include "../../../common/value_type.h" TEST(Registry, Plugin) { diff --git a/test/lib/registry/plugin/plugin.cpp b/test/lib/registry/plugin/plugin.cpp index 48331463f..57da1b692 100644 --- a/test/lib/registry/plugin/plugin.cpp +++ b/test/lib/registry/plugin/plugin.cpp @@ -2,7 +2,6 @@ #include #include #include -#include "../../../common/boxed_type.h" #include "../../../common/value_type.h" CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) { diff --git a/test/lib/registry/shared/lib.cpp b/test/lib/registry/shared/lib.cpp index 1cb134907..851e0ba73 100644 --- a/test/lib/registry/shared/lib.cpp +++ b/test/lib/registry/shared/lib.cpp @@ -2,7 +2,6 @@ #include #include #include -#include "../../../common/boxed_type.h" #include "../../../common/value_type.h" #include "lib.h" diff --git a/test/lib/registry/shared/main.cpp b/test/lib/registry/shared/main.cpp index 2a1fef753..ad89c2b42 100644 --- a/test/lib/registry/shared/main.cpp +++ b/test/lib/registry/shared/main.cpp @@ -4,7 +4,6 @@ #include #include #include -#include "../../../common/boxed_type.h" #include "../../../common/value_type.h" #include "lib.h"