Просмотр исходного кода

test: use the mixin design a little more

skypjack 3 дней назад
Родитель
Сommit
e3a736a2a5

+ 0 - 26
test/common/aggregate.h

@@ -1,26 +0,0 @@
-#ifndef ENTT_COMMON_AGGREGATE_H
-#define ENTT_COMMON_AGGREGATE_H
-
-#include <compare>
-#include <type_traits>
-
-namespace test {
-
-struct aggregate {
-    int value{};
-
-    [[nodiscard]] constexpr bool operator==(const aggregate &other) const noexcept {
-        return value == other.value;
-    }
-
-    [[nodiscard]] constexpr auto operator<=>(const aggregate &other) const noexcept {
-        return value <=> other.value;
-    }
-};
-
-// ensure aggregate-ness :)
-static_assert(std::is_aggregate_v<test::aggregate>, "Not an aggregate type");
-
-} // namespace test
-
-#endif

+ 16 - 5
test/common/value_type.h

@@ -47,13 +47,21 @@ struct non_movable_mixin: Type {
 
 struct empty_type {};
 
+struct aggregate_type {
+    [[nodiscard]] constexpr bool operator==(const aggregate_type &) const noexcept = default;
+    [[nodiscard]] constexpr auto operator<=>(const aggregate_type &) const noexcept = default;
+    int value{};
+};
+
 template<typename Type>
 struct value_type {
     constexpr value_type() = default;
     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;
-    operator Type() const noexcept { return value; }
+    operator Type() const noexcept {
+        return value;
+    }
     Type value{};
 };
 
@@ -73,10 +81,13 @@ using boxed_char = internal::value_type<char>;
 using empty = internal::empty_type;
 struct other_empty: internal::empty_type {};
 
-static_assert(std::is_trivially_destructible_v<test::pointer_stable>, "Not a trivially destructible type");
-static_assert(!std::is_trivially_destructible_v<test::non_trivially_destructible>, "Trivially destructible type");
-static_assert(!std::is_trivially_destructible_v<test::pointer_stable_non_trivially_destructible>, "Trivially destructible type");
-static_assert(!std::is_move_constructible_v<test::non_movable> && !std::is_move_assignable_v<test::non_movable>, "Movable type");
+using aggregate = internal::aggregate_type;
+
+static_assert(std::is_trivially_destructible_v<pointer_stable>, "Not a trivially destructible type");
+static_assert(!std::is_trivially_destructible_v<non_trivially_destructible>, "Trivially destructible type");
+static_assert(!std::is_trivially_destructible_v<pointer_stable_non_trivially_destructible>, "Trivially destructible type");
+static_assert(!std::is_move_constructible_v<non_movable> && !std::is_move_assignable_v<non_movable>, "Movable type");
+static_assert(std::is_aggregate_v<aggregate>, "Not an aggregate type");
 
 } // namespace test
 

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

@@ -9,7 +9,6 @@
 #include <gtest/gtest.h>
 #include <entt/core/any.hpp>
 #include <entt/core/type_info.hpp>
-#include "../../common/aggregate.h"
 #include "../../common/config.h"
 #include "../../common/linter.hpp"
 #include "../../common/new_delete.h"

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

@@ -19,7 +19,6 @@
 #include <entt/entity/storage.hpp>
 #include <entt/entity/view.hpp>
 #include <entt/signal/sigh.hpp>
-#include "../../common/aggregate.h"
 #include "../../common/config.h"
 #include "../../common/mixin.hpp"
 #include "../../common/value_type.h"

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

@@ -12,7 +12,6 @@
 #include <entt/entity/component.hpp>
 #include <entt/entity/entity.hpp>
 #include <entt/entity/storage.hpp>
-#include "../../common/aggregate.h"
 #include "../../common/config.h"
 #include "../../common/linter.hpp"
 #include "../../common/new_delete.h"