test: use the mixin design a little more

This commit is contained in:
skypjack
2026-03-03 10:10:46 +01:00
parent 3cf061201a
commit 6b8fe4deff
33 changed files with 26 additions and 62 deletions

View File

@@ -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

View File

@@ -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 {};

View File

@@ -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!!

View File

@@ -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) {

View File

@@ -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}};

View File

@@ -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 {

View File

@@ -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"

View File

@@ -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) {

View File

@@ -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 {

View File

@@ -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"

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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"

View File

@@ -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) {

View File

@@ -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;

View File

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

View File

@@ -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"

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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{};

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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"

View File

@@ -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"

View File

@@ -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) \

View File

@@ -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"

View File

@@ -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"

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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"

View File

@@ -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"