ソースを参照

test: internal changes to modernize the codebase

skypjack 1 ヶ月 前
コミット
7d4933790b

+ 7 - 7
test/common/aggregate.h

@@ -7,15 +7,15 @@ namespace test {
 
 struct aggregate {
     int value{};
-};
 
-[[nodiscard]] inline bool operator==(const aggregate &lhs, const aggregate &rhs) {
-    return lhs.value == rhs.value;
-}
+    [[nodiscard]] constexpr bool operator==(const aggregate &other) const noexcept {
+        return value == other.value;
+    }
 
-[[nodiscard]] inline bool operator<(const aggregate &lhs, const aggregate &rhs) {
-    return lhs.value < rhs.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");

+ 1 - 1
test/common/basic_test_allocator.hpp

@@ -27,7 +27,7 @@ struct basic_test_allocator: std::allocator<Type> {
         return *this;
     }
 
-    bool operator==(const basic_test_allocator &other) const {
+    [[nodiscard]] bool operator==(const basic_test_allocator &other) const noexcept {
         return (this == &other);
     }
 };

+ 4 - 5
test/common/boxed_type.h

@@ -10,12 +10,11 @@ struct boxed_type {
     operator Type() const noexcept {
         return value;
     }
-};
 
-template<typename Type>
-inline bool operator==(const boxed_type<Type> &lhs, const boxed_type<Type> &rhs) {
-    return lhs.value == rhs.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>;

+ 1 - 1
test/common/non_comparable.h

@@ -4,7 +4,7 @@
 namespace test {
 
 struct non_comparable {
-    bool operator==(const non_comparable &) const = delete;
+    bool operator==(const non_comparable &) const noexcept = delete;
 };
 
 } // namespace test

+ 7 - 7
test/common/pointer_stable.h

@@ -6,15 +6,15 @@ namespace test {
 struct pointer_stable {
     static constexpr auto in_place_delete = true;
     int value{};
-};
 
-[[nodiscard]] inline bool operator==(const pointer_stable &lhs, const pointer_stable &rhs) {
-    return lhs.value == rhs.value;
-}
+    [[nodiscard]] constexpr bool operator==(const pointer_stable &other) const noexcept {
+        return value == other.value;
+    }
 
-[[nodiscard]] inline bool operator<(const pointer_stable &lhs, const pointer_stable &rhs) {
-    return lhs.value < rhs.value;
-}
+    [[nodiscard]] constexpr auto operator<=>(const pointer_stable &other) const noexcept {
+        return value <=> other.value;
+    }
+};
 
 } // namespace test
 

+ 1 - 1
test/common/throwing_allocator.hpp

@@ -74,7 +74,7 @@ public:
         (*config)[entt::type_id<Other>().hash()] = len;
     }
 
-    bool operator==(const throwing_allocator<Type> &) const {
+    [[nodiscard]] bool operator==(const throwing_allocator<Type> &) const noexcept {
         return true;
     }
 

+ 4 - 4
test/common/throwing_type.hpp

@@ -29,14 +29,14 @@ struct throwing_type {
         return trigger;
     }
 
+    [[nodiscard]] bool operator==(const throwing_type &other) const noexcept {
+        return trigger == other.trigger;
+    }
+
 private:
     bool trigger{};
 };
 
-inline bool operator==(const throwing_type &lhs, const throwing_type &rhs) {
-    return lhs.throw_on_copy() == rhs.throw_on_copy();
-}
-
 } // namespace test
 
 #endif

+ 4 - 4
test/entt/entity/registry.cpp

@@ -31,6 +31,10 @@ struct Registry: testing::Test {
 
     struct no_eto_type {
         static constexpr std::size_t page_size = 1024u;
+
+        [[nodiscard]] bool operator==(const no_eto_type &other) const noexcept {
+            return this == &other;
+        }
     };
 
     struct listener {
@@ -85,10 +89,6 @@ struct Registry: testing::Test {
 
 using RegistryDeathTest = Registry;
 
-bool operator==(const Registry::no_eto_type &lhs, const Registry::no_eto_type &rhs) {
-    return &lhs == &rhs;
-}
-
 struct entity_traits {
     using value_type = Registry::my_entity;
     using entity_type = uint32_t;