Jelajahi Sumber

test: use the mixin design a little more

skypjack 3 hari lalu
induk
melakukan
b5797912d3

+ 0 - 12
test/common/non_comparable.h

@@ -1,12 +0,0 @@
-#ifndef ENTT_COMMON_NON_COMPARABLE_H
-#define ENTT_COMMON_NON_COMPARABLE_H
-
-namespace test {
-
-struct non_comparable {
-    bool operator==(const non_comparable &) const noexcept = delete;
-};
-
-} // namespace test
-
-#endif

+ 13 - 5
test/common/value_type.h

@@ -19,16 +19,23 @@ template<typename Type>
 struct non_trivially_destructible_mixin: Type {
     using Type::Type;
     using Type::operator=;
-    virtual ~non_trivially_destructible_mixin() = default;
+    virtual ~non_trivially_destructible_mixin() noexcept = default;
+};
+
+template<typename Type>
+struct non_comparable_mixin: Type {
+    using Type::Type;
+    using Type::operator=;
+    bool operator==(const non_comparable_mixin &) const noexcept = delete;
 };
 
 template<typename Type>
 struct non_movable_mixin: Type {
     using Type::Type;
-    non_movable_mixin(non_movable_mixin &&) = delete;
-    non_movable_mixin(const non_movable_mixin &) = default;
-    non_movable_mixin &operator=(non_movable_mixin &&) = delete;
-    non_movable_mixin &operator=(const non_movable_mixin &) = default;
+    non_movable_mixin(non_movable_mixin &&) noexcept = delete;
+    non_movable_mixin(const non_movable_mixin &) noexcept = default;
+    non_movable_mixin &operator=(non_movable_mixin &&) noexcept = delete;
+    non_movable_mixin &operator=(const non_movable_mixin &) noexcept = default;
 };
 
 struct value_type {
@@ -44,6 +51,7 @@ struct value_type {
 using pointer_stable = internal::pointer_stable_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 non_comparable = internal::non_comparable_mixin<internal::value_type>;
 using non_movable = internal::non_movable_mixin<internal::value_type>;
 
 static_assert(std::is_trivially_destructible_v<test::pointer_stable>, "Not a trivially destructible type");

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

@@ -13,7 +13,6 @@
 #include "../../common/config.h"
 #include "../../common/linter.hpp"
 #include "../../common/new_delete.h"
-#include "../../common/non_comparable.h"
 #include "../../common/value_type.h"
 
 template<std::size_t Len>

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

@@ -8,7 +8,7 @@
 #include <gtest/gtest.h>
 #include <entt/core/hashed_string.hpp>
 #include <entt/core/type_traits.hpp>
-#include "../../common/non_comparable.h"
+#include "../../common/value_type.h"
 
 struct nlohmann_json_like final {
     using value_type = nlohmann_json_like;

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

@@ -14,7 +14,7 @@
 #include <entt/meta/resolve.hpp>
 #include "../../common/config.h"
 #include "../../common/linter.hpp"
-#include "../../common/non_comparable.h"
+#include "../../common/value_type.h"
 
 struct MetaAny: ::testing::Test {
     struct clazz {