test: internal changes to modernize the codebase

This commit is contained in:
skypjack
2026-01-09 15:32:42 +01:00
parent ad147da839
commit 7d4933790b
8 changed files with 31 additions and 32 deletions

View File

@@ -7,16 +7,16 @@ 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;
}
};
[[nodiscard]] inline bool operator==(const aggregate &lhs, const aggregate &rhs) {
return lhs.value == rhs.value;
}
[[nodiscard]] inline bool operator<(const aggregate &lhs, const aggregate &rhs) {
return lhs.value < rhs.value;
}
// ensure aggregate-ness :)
static_assert(std::is_aggregate_v<test::aggregate>, "Not an aggregate type");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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