Kaynağa Gözat

test: use the mixin design a little more

skypjack 2 gün önce
ebeveyn
işleme
6b8fe4deff

+ 0 - 24
test/common/boxed_type.h

@@ -1,24 +0,0 @@
-#ifndef ENTT_COMMON_BOXED_TYPE_H
-#define ENTT_COMMON_BOXED_TYPE_H
-
-namespace test {
-
-template<typename Type>
-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<int>;
-using boxed_char = boxed_type<char>;
-
-} // namespace test
-
-#endif

+ 13 - 7
test/common/value_type.h

@@ -47,22 +47,28 @@ struct non_movable_mixin: Type {
 
 struct empty_type {};
 
+template<typename Type>
 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<internal::value_type>;
-using non_default_constructible = internal::non_default_constructible_mixin<internal::value_type>;
-using non_trivially_destructible = internal::non_trivially_destructible_mixin<internal::value_type>;
-using pointer_stable_non_trivially_destructible = internal::pointer_stable_mixin<internal::non_trivially_destructible_mixin<internal::value_type>>;
+using pointer_stable = internal::pointer_stable_mixin<internal::value_type<int>>;
+using pointer_stable_non_trivially_destructible = internal::pointer_stable_mixin<internal::non_trivially_destructible_mixin<internal::value_type<int>>>;
+
+using non_default_constructible = internal::non_default_constructible_mixin<internal::value_type<int>>;
+using non_trivially_destructible = internal::non_trivially_destructible_mixin<internal::value_type<int>>;
 using non_comparable = internal::non_comparable_mixin<internal::empty_type>;
-using non_movable = internal::non_movable_mixin<internal::value_type>;
+using non_movable = internal::non_movable_mixin<internal::value_type<int>>;
+
+using boxed_int = internal::value_type<int>;
+using boxed_char = internal::value_type<char>;
 
 using empty = internal::empty_type;
 struct other_empty: internal::empty_type {};

+ 1 - 1
test/entt/core/algorithm.cpp

@@ -3,7 +3,7 @@
 #include <vector>
 #include <gtest/gtest.h>
 #include <entt/core/algorithm.hpp>
-#include "../../common/boxed_type.h"
+#include "../../common/value_type.h"
 
 TEST(Algorithm, StdSort) {
     // well, I'm pretty sure it works, it's std::sort!!

+ 0 - 1
test/entt/core/ident.cpp

@@ -1,7 +1,6 @@
 #include <type_traits>
 #include <gtest/gtest.h>
 #include <entt/core/ident.hpp>
-#include "../../common/boxed_type.h"
 #include "../../common/value_type.h"
 
 TEST(Ident, Uniqueness) {

+ 1 - 1
test/entt/core/iterator.cpp

@@ -3,7 +3,7 @@
 #include <vector>
 #include <gtest/gtest.h>
 #include <entt/core/iterator.hpp>
-#include "../../common/boxed_type.h"
+#include "../../common/value_type.h"
 
 TEST(Iterator, InputIteratorPointer) {
     entt::input_iterator_pointer ptr{test::boxed_int{0}};

+ 0 - 1
test/entt/entity/component.cpp

@@ -2,7 +2,6 @@
 #include <gtest/gtest.h>
 #include <entt/config/config.h>
 #include <entt/entity/component.hpp>
-#include "../../common/boxed_type.h"
 #include "../../common/value_type.h"
 
 struct ComponentBase: testing::Test {

+ 0 - 1
test/entt/entity/group.cpp

@@ -11,7 +11,6 @@
 #include <entt/entity/registry.hpp>
 #include <entt/entity/view.hpp>
 #include <entt/signal/sigh.hpp>
-#include "../../common/boxed_type.h"
 #include "../../common/config.h"
 #include "../../common/value_type.h"
 

+ 0 - 1
test/entt/entity/view.cpp

@@ -8,7 +8,6 @@
 #include <entt/entity/entity.hpp>
 #include <entt/entity/storage.hpp>
 #include <entt/entity/view.hpp>
-#include "../../common/boxed_type.h"
 #include "../../common/value_type.h"
 
 TEST(ViewSingleStorage, Functionalities) {

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

@@ -9,9 +9,9 @@
 #include <entt/meta/meta.hpp>
 #include <entt/meta/range.hpp>
 #include <entt/meta/resolve.hpp>
-#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 {

+ 0 - 1
test/entt/signal/emitter.cpp

@@ -3,7 +3,6 @@
 #include <utility>
 #include <gtest/gtest.h>
 #include <entt/signal/emitter.hpp>
-#include "../../common/boxed_type.h"
 #include "../../common/emitter.h"
 #include "../../common/linter.hpp"
 #include "../../common/value_type.h"

+ 1 - 1
test/lib/dispatcher/plugin/main.cpp

@@ -4,8 +4,8 @@
 #include <cr.h>
 #include <entt/signal/dispatcher.hpp>
 #include <entt/signal/sigh.hpp>
-#include "../../../common/boxed_type.h"
 #include "../../../common/listener.h"
+#include "../../../common/value_type.h"
 
 TEST(Dispatcher, Plugin) {
     entt::dispatcher dispatcher;

+ 0 - 1
test/lib/dispatcher/plugin/plugin.cpp

@@ -1,6 +1,5 @@
 #include <cr.h>
 #include <entt/signal/dispatcher.hpp>
-#include "../../../common/boxed_type.h"
 #include "../../../common/value_type.h"
 
 CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) {

+ 0 - 1
test/lib/dispatcher/shared/lib.cpp

@@ -1,6 +1,5 @@
 #include <entt/config/config.h>
 #include <entt/signal/dispatcher.hpp>
-#include "../../../common/boxed_type.h"
 #include "../../../common/value_type.h"
 #include "lib.h"
 

+ 1 - 1
test/lib/dispatcher/shared/main.cpp

@@ -3,8 +3,8 @@
 #include <entt/core/utility.hpp>
 #include <entt/signal/dispatcher.hpp>
 #include <entt/signal/sigh.hpp>
-#include "../../../common/boxed_type.h"
 #include "../../../common/listener.h"
+#include "../../../common/value_type.h"
 #include "lib.h"
 
 TEST(Dispatcher, Shared) {

+ 1 - 1
test/lib/emitter/plugin/main.cpp

@@ -3,8 +3,8 @@
 #include <functional>
 #include <gtest/gtest.h>
 #include <cr.h>
-#include "../../../common/boxed_type.h"
 #include "../../../common/emitter.h"
+#include "../../../common/value_type.h"
 
 TEST(Emitter, Plugin) {
     test::emitter emitter;

+ 0 - 1
test/lib/emitter/plugin/plugin.cpp

@@ -1,5 +1,4 @@
 #include <cr.h>
-#include "../../../common/boxed_type.h"
 #include "../../../common/emitter.h"
 #include "../../../common/value_type.h"
 

+ 0 - 1
test/lib/emitter/shared/lib.cpp

@@ -1,5 +1,4 @@
 #include <entt/config/config.h>
-#include "../../../common/boxed_type.h"
 #include "../../../common/emitter.h"
 #include "../../../common/value_type.h"
 #include "lib.h"

+ 1 - 1
test/lib/emitter/shared/main.cpp

@@ -1,8 +1,8 @@
 #include <functional>
 #include <gtest/gtest.h>
 #include <entt/config/config.h>
-#include "../../../common/boxed_type.h"
 #include "../../../common/emitter.h"
+#include "../../../common/value_type.h"
 #include "lib.h"
 
 TEST(Emitter, Shared) {

+ 1 - 1
test/lib/locator/plugin/main.cpp

@@ -3,7 +3,7 @@
 #include <gtest/gtest.h>
 #include <cr.h>
 #include <entt/locator/locator.hpp>
-#include "../../../common/boxed_type.h"
+#include "../../../common/value_type.h"
 #include "userdata.h"
 
 TEST(Locator, Plugin) {

+ 1 - 1
test/lib/locator/plugin/plugin.cpp

@@ -1,6 +1,6 @@
 #include <cr.h>
 #include <entt/locator/locator.hpp>
-#include "../../../common/boxed_type.h"
+#include "../../../common/value_type.h"
 #include "userdata.h"
 
 CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) {

+ 1 - 1
test/lib/locator/plugin/userdata.h

@@ -2,7 +2,7 @@
 #define ENTT_LIB_LOCATOR_PLUGIN_USERDATA_H
 
 #include <entt/locator/locator.hpp>
-#include "../../../common/boxed_type.h"
+#include "../../../common/value_type.h"
 
 struct userdata {
     entt::locator<test::boxed_int>::node_type handle{};

+ 1 - 1
test/lib/locator/shared/lib.cpp

@@ -1,6 +1,6 @@
 #include <entt/config/config.h>
 #include <entt/locator/locator.hpp>
-#include "../../../common/boxed_type.h"
+#include "../../../common/value_type.h"
 #include "lib.h"
 
 ENTT_API void set_up(const entt::locator<test::boxed_int>::node_type &handle) {

+ 1 - 1
test/lib/locator/shared/lib.h

@@ -1,6 +1,6 @@
 #include <entt/config/config.h>
 #include <entt/locator/locator.hpp>
-#include "../../../common/boxed_type.h"
+#include "../../../common/value_type.h"
 
 ENTT_API void set_up(const entt::locator<test::boxed_int>::node_type &);
 ENTT_API void use_service(int);

+ 1 - 1
test/lib/locator/shared/main.cpp

@@ -1,7 +1,7 @@
 #include <gtest/gtest.h>
 #include <entt/config/config.h>
 #include <entt/locator/locator.hpp>
-#include "../../../common/boxed_type.h"
+#include "../../../common/value_type.h"
 #include "lib.h"
 
 TEST(Locator, Shared) {

+ 0 - 1
test/lib/meta/plugin/plugin.cpp

@@ -4,7 +4,6 @@
 #include <entt/meta/context.hpp>
 #include <entt/meta/factory.hpp>
 #include <entt/meta/meta.hpp>
-#include "../../../common/boxed_type.h"
 #include "../../../common/value_type.h"
 #include "userdata.h"
 

+ 0 - 1
test/lib/meta/plugin_std/plugin.cpp

@@ -4,7 +4,6 @@
 #include <entt/meta/context.hpp>
 #include <entt/meta/factory.hpp>
 #include <entt/meta/meta.hpp>
-#include "../../../common/boxed_type.h"
 #include "../../../common/value_type.h"
 #include "userdata.h"
 

+ 0 - 1
test/lib/meta/plugin_std/userdata.h

@@ -6,7 +6,6 @@
 #include <entt/core/type_info.hpp>
 #include <entt/meta/context.hpp>
 #include <entt/meta/meta.hpp>
-#include "../../../common/boxed_type.h"
 #include "../../../common/value_type.h"
 
 #define ASSIGN_TYPE_ID(clazz) \

+ 0 - 1
test/lib/meta/shared/lib.cpp

@@ -4,7 +4,6 @@
 #include <entt/meta/context.hpp>
 #include <entt/meta/factory.hpp>
 #include <entt/meta/meta.hpp>
-#include "../../../common/boxed_type.h"
 #include "../../../common/value_type.h"
 #include "lib.h"
 

+ 0 - 1
test/lib/meta/shared/main.cpp

@@ -5,7 +5,6 @@
 #include <entt/meta/context.hpp>
 #include <entt/meta/meta.hpp>
 #include <entt/meta/resolve.hpp>
-#include "../../../common/boxed_type.h"
 #include "../../../common/value_type.h"
 #include "lib.h"
 

+ 0 - 1
test/lib/registry/plugin/main.cpp

@@ -6,7 +6,6 @@
 #include <entt/entity/mixin.hpp>
 #include <entt/entity/registry.hpp>
 #include <entt/entity/view.hpp>
-#include "../../../common/boxed_type.h"
 #include "../../../common/value_type.h"
 
 TEST(Registry, Plugin) {

+ 0 - 1
test/lib/registry/plugin/plugin.cpp

@@ -2,7 +2,6 @@
 #include <entt/entity/mixin.hpp>
 #include <entt/entity/registry.hpp>
 #include <entt/entity/view.hpp>
-#include "../../../common/boxed_type.h"
 #include "../../../common/value_type.h"
 
 CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) {

+ 0 - 1
test/lib/registry/shared/lib.cpp

@@ -2,7 +2,6 @@
 #include <entt/entity/mixin.hpp>
 #include <entt/entity/registry.hpp>
 #include <entt/entity/view.hpp>
-#include "../../../common/boxed_type.h"
 #include "../../../common/value_type.h"
 #include "lib.h"
 

+ 0 - 1
test/lib/registry/shared/main.cpp

@@ -4,7 +4,6 @@
 #include <entt/entity/mixin.hpp>
 #include <entt/entity/registry.hpp>
 #include <entt/entity/view.hpp>
-#include "../../../common/boxed_type.h"
 #include "../../../common/value_type.h"
 #include "lib.h"