diff --git a/.clang-format b/.clang-format index 659ec45..0a8e9f1 100644 --- a/.clang-format +++ b/.clang-format @@ -1,7 +1,7 @@ --- Language: Cpp AccessModifierOffset: -2 -AlignAfterOpenBracket: Align +AlignAfterOpenBracket: BlockIndent AlignArrayOfStructures: Right AlignConsecutiveAssignments: None AlignConsecutiveBitFields: Consecutive diff --git a/CMakeLists.txt b/CMakeLists.txt index 47eb644..b766c70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.20) -project(hyperion_platform LANGUAGES CXX VERSION 0.5.4) +project(hyperion_platform LANGUAGES CXX VERSION 0.5.5) include(CTest) diff --git a/include/hyperion/platform.h b/include/hyperion/platform.h index 36be886..3306d51 100644 --- a/include/hyperion/platform.h +++ b/include/hyperion/platform.h @@ -2,11 +2,11 @@ /// @author Braxton Salyer /// @brief This module includes macro definitions for identifying the platform being compiled for /// (operating system, compiler, etc) -/// @version 0.4.0 -/// @date 2024-04-20 +/// @version 0.4.1 +/// @date 2025-11-25 /// /// MIT License -/// @copyright Copyright (c) 2024 Braxton Salyer +/// @copyright Copyright (c) 2025 Braxton Salyer /// /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal @@ -47,8 +47,7 @@ #if !((defined(__MSC_VER) || defined(_MSC_VER)) && !defined(__clang__)) // NOLINTNEXTLINE #define HYPERION_IGNORE_UNUSED_MACROS_WARNING_START \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wunused-macros\"") + _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wunused-macros\"") #else // NOLINTNEXTLINE #define HYPERION_IGNORE_UNUSED_MACROS_WARNING_START @@ -174,7 +173,7 @@ HYPERION_IGNORE_UNUSED_MACROS_WARNING_START; /// @brief Whether the current compiler is GCC /// @ingroup platform /// @headerfile hyperion/platform.h -#if(defined(__MSC_VER) || defined(_MSC_VER)) && !HYPERION_PLATFORM_COMPILER_IS_CLANG +#if (defined(__MSC_VER) || defined(_MSC_VER)) && !HYPERION_PLATFORM_COMPILER_IS_CLANG // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define HYPERION_PLATFORM_COMPILER_IS_MSVC true #else diff --git a/include/hyperion/platform/compare.h b/include/hyperion/platform/compare.h index 4bf8626..4118e9f 100644 --- a/include/hyperion/platform/compare.h +++ b/include/hyperion/platform/compare.h @@ -2,11 +2,11 @@ /// @author Braxton Salyer /// @brief Comparison functions that are safe regardless of the being-compared types, /// including the floating point types -/// @version 0.5.2 -/// @date 2024-09-22 +/// @version 0.5.3 +/// @date 2025-11-25 /// /// MIT License -/// @copyright Copyright (c) 2024 Braxton Salyer +/// @copyright Copyright (c) 2025 Braxton Salyer /// /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal @@ -127,11 +127,13 @@ namespace hyperion::platform::compare { /// @headerfile hyperion/platform/compare.h template concept Arithmetic = std::is_arithmetic_v> - && !(std::same_as, bool> - || std::same_as, char> - || std::same_as, char8_t> - || std::same_as, char16_t> - || std::same_as, char32_t>); + && !( + std::same_as, bool> + || std::same_as, char> + || std::same_as, char8_t> + || std::same_as, char16_t> + || std::same_as, char32_t> + ); /// @brief Types of epsilons usable in floating point comparisons, /// either `Absolute`, i.e. a fixed magnitude difference, or `Relative`, @@ -169,15 +171,19 @@ namespace hyperion::platform::compare { requires(Arithmetic && std::convertible_to, std::remove_cvref_t>) || (Arithmetic - && std::convertible_to, - std::remove_cvref_t>) + && std:: + convertible_to, std::remove_cvref_t>) struct common_type : public std::common_type { }; template using common_type_t = typename common_type::type; template - static inline constexpr auto default_epsilon = []() { + static inline constexpr auto default_epsilon + = []() -> std::conditional_t< + std::same_as, std::nullptr_t>, + fmax, + common_type_t> { using common_t = common_type_t; if constexpr(TType == EpsilonType::Absolute && not std::same_as) @@ -187,13 +193,16 @@ namespace hyperion::platform::compare { else { return static_cast< std::conditional_t, fmax, common_t>>( - 0.001_fmax); + 0.001_fmax + ); } }(); - constexpr auto safe_float_equality(std::floating_point auto lhs, - std::floating_point auto rhs, - std::floating_point auto error) noexcept -> bool { + constexpr auto safe_float_equality( + std::floating_point auto lhs, + std::floating_point auto rhs, + std::floating_point auto error + ) noexcept -> bool { using common_t = common_type_t, decltype(error)>; @@ -212,9 +221,11 @@ namespace hyperion::platform::compare { return detail::abs(diff) <= err; } - constexpr auto safe_float_inequality(std::floating_point auto lhs, - std::floating_point auto rhs, - std::floating_point auto error) noexcept -> bool { + constexpr auto safe_float_inequality( + std::floating_point auto lhs, + std::floating_point auto rhs, + std::floating_point auto error + ) noexcept -> bool { using common_t = common_type_t, decltype(error)>; @@ -280,7 +291,8 @@ namespace hyperion::platform::compare { using common_type = std::common_type_t; return static_cast( static_cast(m_epsilon) - * static_cast(detail::max(detail::abs(lhs), detail::abs(rhs)))); + * static_cast(detail::max(detail::abs(lhs), detail::abs(rhs))) + ); } } @@ -298,9 +310,10 @@ namespace hyperion::platform::compare { template constexpr auto make_epsilon() noexcept -> Epsilon< TType, - std::conditional_t, std::nullptr_t>, - fmax, - detail::common_type_t>> { + std::conditional_t< + std::same_as, std::nullptr_t>, + fmax, + detail::common_type_t>> { return {detail::default_epsilon}; } } // namespace detail @@ -380,16 +393,16 @@ namespace hyperion::platform::compare { /// @return Whether `lhs` and `rhs` are equal /// @ingroup comparison /// @headerfile hyperion/platform/compare.h - template())> + template< + typename TLhs, + typename TRhs, + EpsilonKind TEpsilon = decltype(detail::make_epsilon())> requires EqualityComparable constexpr auto equality_compare( TLhs&& lhs, TRhs&& rhs, - TEpsilon epsilon - = detail::make_epsilon()) noexcept(noexcept(lhs == rhs) && noexcept(rhs == lhs)) - -> bool { + TEpsilon epsilon = detail::make_epsilon() + ) noexcept(noexcept(lhs == rhs) && noexcept(rhs == lhs)) -> bool { #if HYPERION_PLATFORM_COMPILER_IS_CLANG _Pragma("GCC diagnostic pop"); @@ -402,7 +415,8 @@ namespace hyperion::platform::compare { std::numeric_limits::is_iec559 || (!std::floating_point && !std::floating_point), "Hyperion's safe comparisons require the platform to be one that uses IEEE754 " - "floating point numbers"); + "floating point numbers" + ); if constexpr(std::integral && std::integral) { if constexpr(std::is_signed_v && !std::is_signed_v) { @@ -425,14 +439,18 @@ namespace hyperion::platform::compare { } else if constexpr(std::floating_point || std::floating_point) { if constexpr(std::integral) { - return equality_compare(static_cast(lhs), - std::forward(rhs), - std::move(epsilon)); + return equality_compare( + static_cast(lhs), + std::forward(rhs), + std::move(epsilon) + ); } else if constexpr(std::integral) { - return equality_compare(std::forward(lhs), - static_cast(rhs), - std::move(epsilon)); + return equality_compare( + std::forward(lhs), + static_cast(rhs), + std::move(epsilon) + ); } else { if(std::isnan(lhs) || std::isinf(lhs) || std::isnan(rhs) || std::isinf(rhs)) { @@ -478,16 +496,16 @@ namespace hyperion::platform::compare { /// @return Whether `lhs` and `rhs` are _not_ equal /// @ingroup comparison /// @headerfile hyperion/platform/compare.h - template())> + template< + typename TLhs, + typename TRhs, + EpsilonKind TEpsilon = decltype(detail::make_epsilon())> requires InequalityComparable constexpr auto inequality_compare( TLhs&& lhs, TRhs&& rhs, - TEpsilon epsilon - = detail::make_epsilon()) noexcept(noexcept(lhs == rhs) && noexcept(rhs == lhs)) - -> bool { + TEpsilon epsilon = detail::make_epsilon() + ) noexcept(noexcept(lhs == rhs) && noexcept(rhs == lhs)) -> bool { #if HYPERION_PLATFORM_COMPILER_IS_CLANG _Pragma("GCC diagnostic pop"); @@ -500,7 +518,8 @@ namespace hyperion::platform::compare { std::numeric_limits::is_iec559 || (!std::floating_point && !std::floating_point), "Hyperion's safe comparisons require the platform to be one that uses IEEE754 " - "floating point numbers"); + "floating point numbers" + ); if constexpr(std::integral && std::integral) { if constexpr(std::is_signed_v && !std::is_signed_v) { @@ -523,14 +542,18 @@ namespace hyperion::platform::compare { } else if constexpr(std::floating_point || std::floating_point) { if constexpr(std::integral) { - return inequality_compare(static_cast(lhs), - std::forward(rhs), - std::move(epsilon)); + return inequality_compare( + static_cast(lhs), + std::forward(rhs), + std::move(epsilon) + ); } else if constexpr(std::integral) { - return inequality_compare(std::forward(lhs), - static_cast(rhs), - std::move(epsilon)); + return inequality_compare( + std::forward(lhs), + static_cast(rhs), + std::move(epsilon) + ); } else { if(std::isnan(lhs) || std::isinf(lhs) || std::isnan(rhs) || std::isinf(rhs)) { @@ -576,17 +599,18 @@ namespace hyperion::platform::compare { /// @return Whether `lhs` is less than `rhs` /// @ingroup comparison /// @headerfile hyperion/platform/compare.h - template())> + template< + typename TLhs, + typename TRhs, + EpsilonKind TEpsilon = decltype(detail::make_epsilon())> requires LessThanComparable + constexpr auto // NOLINTNEXTLINE(*-cognitive-complexity) - constexpr auto less_than_compare( + less_than_compare( TLhs&& lhs, TRhs&& rhs, - TEpsilon epsilon - = detail::make_epsilon()) noexcept(noexcept(lhs == rhs) && noexcept(rhs == lhs)) - -> bool { + TEpsilon epsilon = detail::make_epsilon() + ) noexcept(noexcept(lhs == rhs) && noexcept(rhs == lhs)) -> bool { #if HYPERION_PLATFORM_COMPILER_IS_CLANG _Pragma("GCC diagnostic pop"); @@ -599,7 +623,8 @@ namespace hyperion::platform::compare { std::numeric_limits::is_iec559 || (!std::floating_point && !std::floating_point), "Hyperion's safe comparisons require the platform to be one that uses IEEE754 " - "floating point numbers"); + "floating point numbers" + ); if constexpr(std::integral && std::integral) { if constexpr(std::is_signed_v && !std::is_signed_v) { @@ -622,14 +647,18 @@ namespace hyperion::platform::compare { } else if constexpr(std::floating_point || std::floating_point) { if constexpr(std::integral) { - return less_than_compare(static_cast(lhs), - std::forward(rhs), - std::move(epsilon)); + return less_than_compare( + static_cast(lhs), + std::forward(rhs), + std::move(epsilon) + ); } else if constexpr(std::integral) { - return less_than_compare(std::forward(lhs), - static_cast(rhs), - std::move(epsilon)); + return less_than_compare( + std::forward(lhs), + static_cast(rhs), + std::move(epsilon) + ); } else { if(std::isinf(lhs) && std::signbit(lhs)) { @@ -691,17 +720,17 @@ namespace hyperion::platform::compare { /// @return Whether `lhs` is less than or equal to `rhs` /// @ingroup comparison /// @headerfile hyperion/platform/compare.h - template())> + template< + typename TLhs, + typename TRhs, + EpsilonKind TEpsilon = decltype(detail::make_epsilon())> requires LessThanOrEqualComparable // NOLINTNEXTLINE(*-cognitive-complexity) constexpr auto less_than_or_equal_compare( TLhs&& lhs, TRhs&& rhs, - TEpsilon epsilon - = detail::make_epsilon()) noexcept(noexcept(lhs == rhs) && noexcept(rhs == lhs)) - -> bool { + TEpsilon epsilon = detail::make_epsilon() + ) noexcept(noexcept(lhs == rhs) && noexcept(rhs == lhs)) -> bool { #if HYPERION_PLATFORM_COMPILER_IS_CLANG _Pragma("GCC diagnostic pop"); @@ -714,7 +743,8 @@ namespace hyperion::platform::compare { std::numeric_limits::is_iec559 || (!std::floating_point && !std::floating_point), "Hyperion's safe comparisons require the platform to be one that uses IEEE754 " - "floating point numbers"); + "floating point numbers" + ); if constexpr(std::integral && std::integral) { if constexpr(std::is_signed_v && !std::is_signed_v) { @@ -737,14 +767,18 @@ namespace hyperion::platform::compare { } else if constexpr(std::floating_point || std::floating_point) { if constexpr(std::integral) { - return less_than_or_equal_compare(static_cast(lhs), - std::forward(rhs), - std::move(epsilon)); + return less_than_or_equal_compare( + static_cast(lhs), + std::forward(rhs), + std::move(epsilon) + ); } else if constexpr(std::integral) { - return less_than_or_equal_compare(std::forward(lhs), - static_cast(rhs), - std::move(epsilon)); + return less_than_or_equal_compare( + std::forward(lhs), + static_cast(rhs), + std::move(epsilon) + ); } else { if(std::isinf(lhs) && std::signbit(lhs)) { @@ -804,17 +838,18 @@ namespace hyperion::platform::compare { /// @return Whether `lhs` is greater than `rhs` /// @ingroup comparison /// @headerfile hyperion/platform/compare.h - template())> + template< + typename TLhs, + typename TRhs, + EpsilonKind TEpsilon = decltype(detail::make_epsilon())> requires LessThanComparable + constexpr auto // NOLINTNEXTLINE(*-cognitive-complexity) - constexpr auto greater_than_compare( + greater_than_compare( TLhs&& lhs, TRhs&& rhs, - TEpsilon epsilon - = detail::make_epsilon()) noexcept(noexcept(lhs == rhs) && noexcept(rhs == lhs)) - -> bool { + TEpsilon epsilon = detail::make_epsilon() + ) noexcept(noexcept(lhs == rhs) && noexcept(rhs == lhs)) -> bool { #if HYPERION_PLATFORM_COMPILER_IS_CLANG _Pragma("GCC diagnostic pop"); @@ -827,7 +862,8 @@ namespace hyperion::platform::compare { std::numeric_limits::is_iec559 || (!std::floating_point && !std::floating_point), "Hyperion's safe comparisons require the platform to be one that uses IEEE754 " - "floating point numbers"); + "floating point numbers" + ); if constexpr(std::integral && std::integral) { if constexpr(std::is_signed_v && !std::is_signed_v) { @@ -850,14 +886,18 @@ namespace hyperion::platform::compare { } else if constexpr(std::floating_point || std::floating_point) { if constexpr(std::integral) { - return greater_than_compare(static_cast(lhs), - std::forward(rhs), - std::move(epsilon)); + return greater_than_compare( + static_cast(lhs), + std::forward(rhs), + std::move(epsilon) + ); } else if constexpr(std::integral) { - return greater_than_compare(std::forward(lhs), - static_cast(rhs), - std::move(epsilon)); + return greater_than_compare( + std::forward(lhs), + static_cast(rhs), + std::move(epsilon) + ); } else { if(std::isinf(lhs) && std::signbit(lhs)) { @@ -918,17 +958,17 @@ namespace hyperion::platform::compare { /// @return Whether `lhs` is greater than or equal to `rhs` /// @ingroup comparison /// @headerfile hyperion/platform/compare.h - template())> + template< + typename TLhs, + typename TRhs, + EpsilonKind TEpsilon = decltype(detail::make_epsilon())> requires LessThanOrEqualComparable // NOLINTNEXTLINE(*-cognitive-complexity) constexpr auto greater_than_or_equal_compare( TLhs&& lhs, TRhs&& rhs, - TEpsilon epsilon - = detail::make_epsilon()) noexcept(noexcept(lhs == rhs) && noexcept(rhs == lhs)) - -> bool { + TEpsilon epsilon = detail::make_epsilon() + ) noexcept(noexcept(lhs == rhs) && noexcept(rhs == lhs)) -> bool { #if HYPERION_PLATFORM_COMPILER_IS_CLANG _Pragma("GCC diagnostic pop"); @@ -941,7 +981,8 @@ namespace hyperion::platform::compare { std::numeric_limits::is_iec559 || (!std::floating_point && !std::floating_point), "Hyperion's safe comparisons require the platform to be one that uses IEEE754 " - "floating point numbers"); + "floating point numbers" + ); if constexpr(std::integral && std::integral) { if constexpr(std::is_signed_v && !std::is_signed_v) { @@ -964,14 +1005,18 @@ namespace hyperion::platform::compare { } else if constexpr(std::floating_point || std::floating_point) { if constexpr(std::integral) { - return greater_than_or_equal_compare(static_cast(lhs), - std::forward(rhs), - std::move(epsilon)); + return greater_than_or_equal_compare( + static_cast(lhs), + std::forward(rhs), + std::move(epsilon) + ); } else if constexpr(std::integral) { - return greater_than_or_equal_compare(std::forward(lhs), - static_cast(rhs), - std::move(epsilon)); + return greater_than_or_equal_compare( + std::forward(lhs), + static_cast(rhs), + std::move(epsilon) + ); } else { if(std::isinf(lhs) && std::signbit(lhs)) { diff --git a/include/hyperion/platform/def.h b/include/hyperion/platform/def.h index 4ad491c..613ce6c 100644 --- a/include/hyperion/platform/def.h +++ b/include/hyperion/platform/def.h @@ -2,11 +2,11 @@ /// @author Braxton Salyer /// @brief Provides various macro definitions for things like compiler-specific attributes, /// feature enablement, and warning suppression -/// @version 0.4.0 -/// @date 2024-04-20 +/// @version 0.4.1 +/// @date 2025-11-25 /// /// MIT License -/// @copyright Copyright (c) 2024 Braxton Salyer +/// @copyright Copyright (c) 2025 Braxton Salyer /// /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal @@ -38,6 +38,7 @@ #define HYPERION_PLATFORM_DEF_H #include + #include HYPERION_IGNORE_UNUSED_MACROS_WARNING_START; @@ -93,7 +94,7 @@ HYPERION_IGNORE_UNUSED_MACROS_WARNING_START; /// @brief if `std::jthread` is available, this will be defined as true, otherwise it will be false. /// @ingroup defines /// @headerfile hyperion/platform/def.h -#if(defined(__cpp_lib_jthread) && __cpp_lib_jthread >= 201911L) +#if (defined(__cpp_lib_jthread) && __cpp_lib_jthread >= 201911L) #define HYPERION_STD_LIB_HAS_JTHREAD true #else #define HYPERION_STD_LIB_HAS_JTHREAD false @@ -180,7 +181,7 @@ HYPERION_IGNORE_UNUSED_MACROS_WARNING_START; /// @ingroup defines /// @headerfile hyperion/platform/def.h #if defined(__cpp_lib_constexpr_string) - #if(__cpp_lib_constexpr_string >= 201907L) + #if (__cpp_lib_constexpr_string >= 201907L) #define HYPERION_CONSTEXPR_STRINGS constexpr #else #define HYPERION_CONSTEXPR_STRINGS diff --git a/include/hyperion/platform/types.h b/include/hyperion/platform/types.h index 228fa89..8a20ce2 100644 --- a/include/hyperion/platform/types.h +++ b/include/hyperion/platform/types.h @@ -1,11 +1,11 @@ /// @file types.h /// @author Braxton Salyer /// @brief various type aliases for builtin types and user defined literals for them -/// @version 0.5.3 -/// @date 2024-09-25 +/// @version 0.5.4 +/// @date 2025-11-25 /// /// MIT License -/// @copyright Copyright (c) 2024 Braxton Salyer +/// @copyright Copyright (c) 2025 Braxton Salyer /// /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal @@ -129,21 +129,27 @@ namespace hyperion { }; template - constexpr auto trim_separators([[maybe_unused]] string_literal literal) noexcept { - constexpr auto new_size = []() { - constexpr auto array = std::array{Chars...}; - auto size = array.size(); - for(const auto& c : array) { - if(c == '\'') { - size--; - } + constexpr auto + get_size([[maybe_unused]] string_literal literal) noexcept -> usize { + auto size = literal.array.size(); + // NOLINTNEXTLINE(readability-identifier-length) + for(const auto& c : literal.array) { + if(c == '\'') { + size--; } - return size; - }(); + } + return size; + } + template + constexpr auto trim_separators([[maybe_unused]] string_literal literal) noexcept + -> std::array{})> { + constexpr auto new_size = get_size(string_literal{}); constexpr auto array = std::array{Chars...}; std::array new_array = {}; + // NOLINTNEXTLINE(readability-identifier-length) auto i = 0UL; + // NOLINTNEXTLINE(readability-identifier-length) for(const auto& c : array) { if(c != '\'') { new_array[i] = c; @@ -163,12 +169,18 @@ namespace hyperion { template static constexpr auto check_literal_status() noexcept -> void { - static_assert(status != detail::literal_status::OutOfRange, - "Invalid Literal: Literal out of numeric range for type"); - static_assert(status != detail::literal_status::InvalidCharacterSequence, - "Invalid Literal: Literal contains invalid character sequence for type"); - static_assert(status != detail::literal_status::InvalidLiteralType, - "Invalid Literal: Requested type is not a valid numeric literal type"); + static_assert( + status != detail::literal_status::OutOfRange, + "Invalid Literal: Literal out of numeric range for type" + ); + static_assert( + status != detail::literal_status::InvalidCharacterSequence, + "Invalid Literal: Literal contains invalid character sequence for type" + ); + static_assert( + status != detail::literal_status::InvalidLiteralType, + "Invalid Literal: Requested type is not a valid numeric literal type" + ); } HYPERION_IGNORE_PADDING_WARNING_START @@ -191,9 +203,11 @@ namespace hyperion { Type sum = 0; const auto& str = literal.array; const auto is_hex + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index) = str.size() > 2 && str[0] == '0' && (str[1] == 'x' || str[1] == 'X'); const auto is_binary + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index) = str.size() > 2 && str[0] == '0' && (str[1] == 'b' || str[1] == 'B'); if constexpr(std::is_floating_point_v @@ -226,30 +240,36 @@ namespace hyperion { const auto is_octal = str.size() > 1 && str[0] == '0' && !is_hex && !is_binary && !std::is_floating_point_v; + // NOLINTNEXTLINE(readability-avoid-nested-conditional-operator) const auto offset = is_hex || is_binary ? 2U : (is_octal ? 1U : 0U); - constexpr auto to_number = [](char digit) { + constexpr auto to_number = [](char digit) -> Type { if(digit >= '0' && digit <= '9') { return static_cast(digit - '0'); } if(digit >= 'a' && digit <= 'f') { - // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) - return static_cast(static_cast(digit - 'a') - + static_cast(10)); + return static_cast( + static_cast(digit - 'a') + // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + + static_cast(10) + ); } if(digit >= 'A' && digit <= 'F') { - // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) - return static_cast(static_cast(digit - 'A') - + static_cast(10)); + return static_cast( + static_cast(digit - 'A') + // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + + static_cast(10) + ); } return static_cast(0); }; - // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers,readability-avoid-nested-conditional-operator) [[maybe_unused]] const usize base + // NOLINTNEXTLINE(readability-avoid-nested-conditional-operator) = is_hex ? 16U : (is_binary ? 2U : (is_octal ? 8U : 10U)); [[maybe_unused]] bool found_decimal = false; [[maybe_unused]] usize current_multiplier = 1U; @@ -312,16 +332,19 @@ namespace hyperion { } else { if(digit != '\'') { + // NOLINTNEXTLINE(cppcoreguidelines-narrowing-conversions) Type value = to_number(digit) * static_cast(current_multiplier); current_multiplier *= base; if(sum > std::numeric_limits::max() - value) { return {.status = literal_status::OutOfRange}; } + // NOLINTNEXTLINE(cppcoreguidelines-narrowing-conversions) sum += value; } } } + // NOLINTNEXTLINE(readability-redundant-casting) auto result = static_cast(sum); if constexpr(std::is_floating_point_v) { if(found_decimal && num_before_decimal != 0U) { @@ -611,48 +634,68 @@ namespace hyperion { static_assert(static_cast(8) == 8_i8, "i8 literal operator broken"); // NOLINTNEXTLINE static_assert(static_cast(8) == 8_i16, "i16 literal operator broken"); - // NOLINTNEXTLINE - static_assert(static_cast(-64'123'456) == -64'123'456_i64, - "i64 literal operator broken!"); - // NOLINTNEXTLINE - static_assert(-static_cast(0xDEAD'BEEF) == -0xDEAD'BEEF_i64, - "i64 literal operator broken!"); + static_assert( + // NOLINTNEXTLINE + static_cast(-64'123'456) == -64'123'456_i64, + "i64 literal operator broken!" + ); + static_assert( + // NOLINTNEXTLINE + -static_cast(0xDEAD'BEEF) == -0xDEAD'BEEF_i64, + "i64 literal operator broken!" + ); // NOLINTNEXTLINE static_assert(-static_cast(012345) == -012345_i64, "i64 literal operator broken!"); - // NOLINTNEXTLINE - static_assert(static_cast(0b0011001100) == 0b0011001100_i64, - "i64 literal operator broken!"); + static_assert( + // NOLINTNEXTLINE + static_cast(0b0011001100) == 0b0011001100_i64, + "i64 literal operator broken!" + ); static inline constexpr auto acceptable_deviation = static_cast(0.000000000001261213356); - // NOLINTNEXTLINE - static_assert(static_cast(64.123456789) - 64.123456789_fmax < acceptable_deviation, - "fmax literal operator broken!"); - // NOLINTNEXTLINE - static_assert(static_cast(64'000) - 64'000_fmax < acceptable_deviation, - "fmax literal operator broken!"); - // NOLINTNEXTLINE - static_assert(static_cast(1) - 1_fmax < acceptable_deviation, - "fmax literal operator broken!"); - // NOLINTNEXTLINE - static_assert(static_cast(64'000.123456789) - 64'000.123456789_fmax - < acceptable_deviation, - "fmax literal operator broken!"); - // NOLINTNEXTLINE - static_assert(static_cast(-64'000.123456789) - -64'000.123456789_fmax - < acceptable_deviation, - "fmax literal operator broken!"); - // NOLINTNEXTLINE - static_assert(static_cast(0.5) - 0.5_fmax < acceptable_deviation, - "fmax literal operator broken!"); + static_assert( + // NOLINTNEXTLINE + static_cast(64.123456789) - 64.123456789_fmax < acceptable_deviation, + "fmax literal operator broken!" + ); + static_assert( + // NOLINTNEXTLINE + static_cast(64'000) - 64'000_fmax < acceptable_deviation, + "fmax literal operator broken!" + ); + static_assert( + // NOLINTNEXTLINE + static_cast(1) - 1_fmax < acceptable_deviation, + "fmax literal operator broken!" + ); + static_assert( + // NOLINTNEXTLINE + static_cast(64'000.123456789) - 64'000.123456789_fmax < acceptable_deviation, + "fmax literal operator broken!" + ); + static_assert( + // NOLINTNEXTLINE + static_cast(-64'000.123456789) - -64'000.123456789_fmax < acceptable_deviation, + "fmax literal operator broken!" + ); + static_assert( + // NOLINTNEXTLINE + static_cast(0.5) - 0.5_fmax < acceptable_deviation, + "fmax literal operator broken!" + ); // NOLINTNEXTLINE static_assert(static_cast(0.5) == 0.5_fmax, "fmax literal operator broken!"); - // NOLINTNEXTLINE - static_assert(static_cast(1.0e10) == 10'000'000'000.0_fmax, - "fmax literal operator broken!"); - // NOLINTNEXTLINE - static_assert(static_cast(1.0e18) == 1'000'000'000'000'000'000.0_fmax, - "fmax literal operator broken!"); + static_assert( + // NOLINTNEXTLINE + static_cast(1.0e10) == 10'000'000'000.0_fmax, + "fmax literal operator broken!" + ); + static_assert( + // NOLINTNEXTLINE + static_cast(1.0e18) == 1'000'000'000'000'000'000.0_fmax, + "fmax literal operator broken!" + ); #if HYPERION_PLATFORM_COMPILER_IS_CLANG || HYPERION_PLATFORM_COMPILER_IS_GCC _Pragma("GCC diagnostic pop") diff --git a/src/test/compare.h b/src/test/compare.h index 292beeb..cd51928 100644 --- a/src/test/compare.h +++ b/src/test/compare.h @@ -1,11 +1,11 @@ /// @file compare.h /// @author Braxton Salyer /// @brief Tests for safe comparison functions -/// @version 0.5.2 -/// @date 2024-09-22 +/// @version 0.5.3 +/// @date 2025-11-25 /// /// MIT License -/// @copyright Copyright (c) 2024 Braxton Salyer +/// @copyright Copyright (c) 2025 Braxton Salyer /// /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal @@ -47,7 +47,7 @@ namespace hyperion::_test::platform::compare { using namespace hyperion::platform::compare; // NOLINTNEXTLINE(cert-err58-cpp) - static const suite<"hyperion::platform::compare"> compare_tests = [] { + static const suite<"hyperion::platform::compare"> compare_tests = []() -> void { static constexpr auto f32_epsilon = std::numeric_limits::epsilon(); static constexpr auto f64_epsilon = std::numeric_limits::epsilon(); static constexpr auto fmax_epsilon = std::numeric_limits::epsilon(); @@ -75,7 +75,7 @@ namespace hyperion::_test::platform::compare { // NOLINTNEXTLINE(*-use-nullptr): false positive from clang-tidy 15 as well = default; - #if HYPERION_PLATFORM_COMPILER_IS_CLANG && __clang_major == 15 + #if HYPERION_PLATFORM_COMPILER_IS_CLANG && __clang_major__ == 15 #pragma GCC diagnostic pop @@ -102,16 +102,16 @@ namespace hyperion::_test::platform::compare { #endif // HYPERION_PLATFORM_STD_LIB_HAS_COMPARE }; - "equality_compare"_test = [] { - "equal_integers_are_equal"_test = [] { + "equality_compare"_test = []() -> void { + "equal_integers_are_equal"_test = []() -> void { expect(that % equality_compare(1, 1)); }; - "inequal_integers_are_not_equal"_test = [] { + "inequal_integers_are_not_equal"_test = []() -> void { expect(that % not equality_compare(1, 2)); }; - "integer_equivalent_floats_are_equal"_test = [] { + "integer_equivalent_floats_are_equal"_test = []() -> void { auto result = equality_compare(1, 1.0_f32); expect(that % result); expect(that % equality_compare(1, 1.0_f64)); @@ -121,7 +121,7 @@ namespace hyperion::_test::platform::compare { expect(that % equality_compare(1'000_i32, 1'000.0_fmax)); }; - "noninteger_equivalent_floats_are_not_equal"_test = [] { + "noninteger_equivalent_floats_are_not_equal"_test = []() -> void { expect(that % not equality_compare(1, 2.0_f32)); expect(that % not equality_compare(1, 2.0_f64)); expect(that % not equality_compare(1, 2.0_fmax)); @@ -130,25 +130,25 @@ namespace hyperion::_test::platform::compare { expect(that % not equality_compare(1'000_i32, 1'001.0_fmax)); }; - "equivalent_floats_are_equal"_test = [] { + "equivalent_floats_are_equal"_test = []() -> void { expect(that % equality_compare(1.0_f32, 1.0_f32)); expect(that % equality_compare(1.0_f64, 1.0_f64)); expect(that % equality_compare(1.0_fmax, 1.0_fmax)); }; - "nonequivalent_floats_are_not_equal"_test = [] { + "nonequivalent_floats_are_not_equal"_test = []() -> void { expect(that % not equality_compare(1.0_f32, 2.0_f32)); expect(that % not equality_compare(1.0_f64, 2.0_f64)); expect(that % not equality_compare(1.0_fmax, 2.0_fmax)); }; - "floats_differing_by_only_1_epsilon_are_equal"_test = [] { + "floats_differing_by_only_1_epsilon_are_equal"_test = []() -> void { expect(that % equality_compare(1.0_f32, 1.0_f32 + f32_epsilon)); expect(that % equality_compare(1.0_f64, 1.0_f64 + f64_epsilon)); expect(that % equality_compare(1.0_fmax, 1.0_fmax + fmax_epsilon)); }; - "large_floats_with_equal_resolution_are_approximately_equal"_test = [] { + "large_floats_with_equal_resolution_are_approximately_equal"_test = []() -> void { // NOLINTNEXTLINE(*-magic-numbers) expect(that % equality_compare(1.0e10F, 10'000'000'001.0_f32)); // NOLINTNEXTLINE(*-magic-numbers) @@ -157,7 +157,7 @@ namespace hyperion::_test::platform::compare { expect(that % equality_compare(1.0e22L, 10'000'000'000'000'000'000'001.0L)); }; - "significantly_different_large_floats_are_not_approximately_equal"_test = [] { + "significantly_different_large_floats_are_not_approximately_equal"_test = []() -> void { // NOLINTNEXTLINE(*-magic-numbers) expect(that % not equality_compare(1.0e10F, 10'000'001'000.0_f32)); // NOLINTNEXTLINE(*-magic-numbers) @@ -166,8 +166,9 @@ namespace hyperion::_test::platform::compare { expect(that % not equality_compare(1.0e10L, 10'000'001'000.0_fmax)); }; - "comparisons_are_mathematically_consistent"_test = [] { - "values_calculated_from_addition_and_subtraction_compare_correctly"_test = [] { + "comparisons_are_mathematically_consistent"_test = []() -> void { + "values_calculated_from_addition_and_subtraction_compare_correctly"_test + = []() -> void { const auto one_tenth = 0.1_f64; const auto two_tenths = 0.2_f64; const auto three_tenths = 0.3_f64; @@ -177,80 +178,151 @@ namespace hyperion::_test::platform::compare { expect(that % equality_compare(three_tenths - calculated, 0.0_f64)); }; - "negated_values_compare_correctly"_test = [] { + "negated_values_compare_correctly"_test = []() -> void { expect(that % equality_compare(-0.0_f64, 0.0_f64)); expect(that % not equality_compare(-1.0_f64, 1.0_f64)); }; - "identity_operations_compare_correctly"_test = [] { + "identity_operations_compare_correctly"_test = []() -> void { const auto test_value = 1.23456_f64; - expect(that - % equality_compare(std::abs(test_value - 0.0_f64) - / (std::abs(test_value) + 0.0_f64), - 1.0_f64)); + expect( + that + % equality_compare( + std::abs(test_value - 0.0_f64) / (std::abs(test_value) + 0.0_f64), + 1.0_f64 + ) + ); }; - "limits_compare_correctly"_test = [] { - expect(that - % equality_compare(std::numeric_limits::max(), - std::numeric_limits::max())); - expect(that - % equality_compare(std::numeric_limits::max(), - std::numeric_limits::max())); - expect(that - % equality_compare(std::numeric_limits::max(), - std::numeric_limits::max())); - expect(that - % not equality_compare(std::numeric_limits::max(), - std::numeric_limits::max())); - expect(that - % not equality_compare(std::numeric_limits::max(), - std::numeric_limits::max())); - - expect(that - % equality_compare(std::numeric_limits::min(), - std::numeric_limits::min())); - expect(that - % equality_compare(std::numeric_limits::min(), - std::numeric_limits::min())); - expect(that - % equality_compare(std::numeric_limits::min(), - std::numeric_limits::min())); - expect(that - % equality_compare(std::numeric_limits::min(), - std::numeric_limits::min())); - expect(that - % equality_compare(std::numeric_limits::min(), - std::numeric_limits::min())); - expect(that - % equality_compare(std::numeric_limits::min(), - std::numeric_limits::min())); - - expect(that - % equality_compare(std::numeric_limits::denorm_min(), - std::numeric_limits::denorm_min())); - expect(that - % equality_compare(std::numeric_limits::denorm_min(), - std::numeric_limits::denorm_min())); - expect(that - % equality_compare(std::numeric_limits::denorm_min(), - std::numeric_limits::denorm_min())); - expect(that - % equality_compare(std::numeric_limits::denorm_min(), - std::numeric_limits::denorm_min())); - expect(that - % equality_compare(std::numeric_limits::denorm_min(), - std::numeric_limits::denorm_min())); - expect(that - % equality_compare(std::numeric_limits::denorm_min(), - std::numeric_limits::denorm_min())); + "limits_compare_correctly"_test = []() -> void { + expect( + that + % equality_compare( + std::numeric_limits::max(), + std::numeric_limits::max() + ) + ); + expect( + that + % equality_compare( + std::numeric_limits::max(), + std::numeric_limits::max() + ) + ); + expect( + that + % equality_compare( + std::numeric_limits::max(), + std::numeric_limits::max() + ) + ); + expect( + that + % not equality_compare( + std::numeric_limits::max(), + std::numeric_limits::max() + ) + ); + expect( + that + % not equality_compare( + std::numeric_limits::max(), + std::numeric_limits::max() + ) + ); + + expect( + that + % equality_compare( + std::numeric_limits::min(), + std::numeric_limits::min() + ) + ); + expect( + that + % equality_compare( + std::numeric_limits::min(), + std::numeric_limits::min() + ) + ); + expect( + that + % equality_compare( + std::numeric_limits::min(), + std::numeric_limits::min() + ) + ); + expect( + that + % equality_compare( + std::numeric_limits::min(), + std::numeric_limits::min() + ) + ); + expect( + that + % equality_compare( + std::numeric_limits::min(), + std::numeric_limits::min() + ) + ); + expect( + that + % equality_compare( + std::numeric_limits::min(), + std::numeric_limits::min() + ) + ); + + expect( + that + % equality_compare( + std::numeric_limits::denorm_min(), + std::numeric_limits::denorm_min() + ) + ); + expect( + that + % equality_compare( + std::numeric_limits::denorm_min(), + std::numeric_limits::denorm_min() + ) + ); + expect( + that + % equality_compare( + std::numeric_limits::denorm_min(), + std::numeric_limits::denorm_min() + ) + ); + expect( + that + % equality_compare( + std::numeric_limits::denorm_min(), + std::numeric_limits::denorm_min() + ) + ); + expect( + that + % equality_compare( + std::numeric_limits::denorm_min(), + std::numeric_limits::denorm_min() + ) + ); + expect( + that + % equality_compare( + std::numeric_limits::denorm_min(), + std::numeric_limits::denorm_min() + ) + ); expect(that % not equality_compare(std::numeric_limits::min(), 1.0)); expect(that % not equality_compare(std::numeric_limits::min(), 1.0)); expect(that % not equality_compare(std::numeric_limits::min(), 1.0)); }; - "math_results_compare_correctly"_test = [] { + "math_results_compare_correctly"_test = []() -> void { const auto sine1 = std::sin(0.0_f64); const auto sine2 = std::sin(f64_epsilon); expect(that % equality_compare(sine1, 0.0)); @@ -259,7 +331,7 @@ namespace hyperion::_test::platform::compare { }; }; - "non_arithmetic_types_compare_correctly"_test = [] { + "non_arithmetic_types_compare_correctly"_test = []() -> void { const auto val1 = non_arithmetic{0_i32}; const auto val2 = non_arithmetic{1_i32}; const auto val3 = non_arithmetic{0_i32}; @@ -269,45 +341,57 @@ namespace hyperion::_test::platform::compare { expect(that % not equality_compare(val1, val2)); }; - "custom_absolute_epsilon"_test = [] { + "custom_absolute_epsilon"_test = []() -> void { expect(that % equality_compare(1.0_f64, 1.0_f64, custom_absolute_epsilon)); - expect(that - % equality_compare(1.0_f64, - 1.0_f64 + custom_absolute_epsilon.value(), - custom_absolute_epsilon)); - expect(that - % not equality_compare(1.0_f64, - 1.0_f64 + custom_absolute_epsilon.value() - + custom_absolute_epsilon.value(), - custom_absolute_epsilon)); - }; - - "custom_relative_epsilon"_test = [] { + expect( + that + % equality_compare( + 1.0_f64, + 1.0_f64 + custom_absolute_epsilon.value(), + custom_absolute_epsilon + ) + ); + expect( + that + % not equality_compare( + 1.0_f64, + 1.0_f64 + custom_absolute_epsilon.value() + custom_absolute_epsilon.value(), + custom_absolute_epsilon + ) + ); + }; + + "custom_relative_epsilon"_test = []() -> void { expect(that % equality_compare(1.0_f64, 1.0_f64, custom_relative_epsilon)); - expect(that - % equality_compare(1.0_f64, 1.0_f64 + 0.1_f64, custom_relative_epsilon)); - expect(that - % not equality_compare(1.0_f64, 1.0_f64 + 0.2_f64, custom_relative_epsilon)); - - expect(that - % equality_compare(2.0_f64, 2.0_f64 + 0.1_f64, custom_relative_epsilon)); - expect(that - % equality_compare(2.0_f64, 2.0_f64 + 0.2_f64, custom_relative_epsilon)); - expect(that - % not equality_compare(2.0_f64, 2.0_f64 + 0.3_f64, custom_relative_epsilon)); + expect( + that % equality_compare(1.0_f64, 1.0_f64 + 0.1_f64, custom_relative_epsilon) + ); + expect( + that % not equality_compare(1.0_f64, 1.0_f64 + 0.2_f64, custom_relative_epsilon) + ); + + expect( + that % equality_compare(2.0_f64, 2.0_f64 + 0.1_f64, custom_relative_epsilon) + ); + expect( + that % equality_compare(2.0_f64, 2.0_f64 + 0.2_f64, custom_relative_epsilon) + ); + expect( + that % not equality_compare(2.0_f64, 2.0_f64 + 0.3_f64, custom_relative_epsilon) + ); }; }; - "inequality_compare"_test = [] { - "equal_integers_are_equal"_test = [] { + "inequality_compare"_test = []() -> void { + "equal_integers_are_equal"_test = []() -> void { expect(that % not inequality_compare(1, 1)); }; - "inequal_integers_are_not_equal"_test = [] { + "inequal_integers_are_not_equal"_test = []() -> void { expect(that % inequality_compare(1, 2)); }; - "integer_equivalent_floats_are_equal"_test = [] { + "integer_equivalent_floats_are_equal"_test = []() -> void { expect(that % not inequality_compare(1, 1.0_f32)); expect(that % not inequality_compare(1, 1.0_f64)); expect(that % not inequality_compare(1, 1.0_fmax)); @@ -316,7 +400,7 @@ namespace hyperion::_test::platform::compare { expect(that % not inequality_compare(1'000_i32, 1'000.0_fmax)); }; - "noninteger_equivalent_floats_are_not_equal"_test = [] { + "noninteger_equivalent_floats_are_not_equal"_test = []() -> void { expect(that % inequality_compare(1, 2.0_f32)); expect(that % inequality_compare(1, 2.0_f64)); expect(that % inequality_compare(1, 2.0_fmax)); @@ -325,25 +409,25 @@ namespace hyperion::_test::platform::compare { expect(that % inequality_compare(1'000_i32, 1'001.0_fmax)); }; - "equivalent_floats_are_equal"_test = [] { + "equivalent_floats_are_equal"_test = []() -> void { expect(that % not inequality_compare(1.0_f32, 1.0_f32)); expect(that % not inequality_compare(1.0_f64, 1.0_f64)); expect(that % not inequality_compare(1.0_fmax, 1.0_fmax)); }; - "nonequivalent_floats_are_not_equal"_test = [] { + "nonequivalent_floats_are_not_equal"_test = []() -> void { expect(that % inequality_compare(1.0_f32, 2.0_f32)); expect(that % inequality_compare(1.0_f64, 2.0_f64)); expect(that % inequality_compare(1.0_fmax, 2.0_fmax)); }; - "floats_differing_by_only_1_epsilon_are_equal"_test = [] { + "floats_differing_by_only_1_epsilon_are_equal"_test = []() -> void { expect(that % not inequality_compare(1.0_f32, 1.0_f32 + f32_epsilon)); expect(that % not inequality_compare(1.0_f64, 1.0_f64 + f64_epsilon)); expect(that % not inequality_compare(1.0_fmax, 1.0_fmax + fmax_epsilon)); }; - "large_floats_with_equal_resolution_are_approximately_equal"_test = [] { + "large_floats_with_equal_resolution_are_approximately_equal"_test = []() -> void { // NOLINTNEXTLINE(*-magic-numbers) expect(that % not inequality_compare(1.0e10F, 10'000'000'001.0_f32)); // NOLINTNEXTLINE(*-magic-numbers) @@ -352,7 +436,7 @@ namespace hyperion::_test::platform::compare { expect(that % not inequality_compare(1.0e22L, 10'000'000'000'000'000'000'001.0L)); }; - "significantly_different_large_floats_are_not_approximately_equal"_test = [] { + "significantly_different_large_floats_are_not_approximately_equal"_test = []() -> void { // NOLINTNEXTLINE(*-magic-numbers) expect(that % inequality_compare(1.0e10F, 10'000'001'000.0_f32)); // NOLINTNEXTLINE(*-magic-numbers) @@ -361,8 +445,9 @@ namespace hyperion::_test::platform::compare { expect(that % inequality_compare(1.0e10L, 10'000'001'000.0_fmax)); }; - "comparisons_are_mathematically_consistent"_test = [] { - "values_calculated_from_addition_and_subtraction_compare_correctly"_test = [] { + "comparisons_are_mathematically_consistent"_test = []() -> void { + "values_calculated_from_addition_and_subtraction_compare_correctly"_test + = []() -> void { const auto one_tenth = 0.1_f64; const auto two_tenths = 0.2_f64; const auto three_tenths = 0.3_f64; @@ -372,80 +457,151 @@ namespace hyperion::_test::platform::compare { expect(that % not inequality_compare(three_tenths - calculated, 0.0_f64)); }; - "negated_values_compare_correctly"_test = [] { + "negated_values_compare_correctly"_test = []() -> void { expect(that % not inequality_compare(-0.0_f64, 0.0_f64)); expect(that % inequality_compare(-1.0_f64, 1.0_f64)); }; - "identity_operations_compare_correctly"_test = [] { + "identity_operations_compare_correctly"_test = []() -> void { const auto test_value = 1.23456_f64; - expect(that - % not inequality_compare(std::abs(test_value - 0.0_f64) - / (std::abs(test_value) + 0.0_f64), - 1.0_f64)); + expect( + that + % not inequality_compare( + std::abs(test_value - 0.0_f64) / (std::abs(test_value) + 0.0_f64), + 1.0_f64 + ) + ); }; - "limits_compare_correctly"_test = [] { - expect(that - % not inequality_compare(std::numeric_limits::max(), - std::numeric_limits::max())); - expect(that - % not inequality_compare(std::numeric_limits::max(), - std::numeric_limits::max())); - expect(that - % not inequality_compare(std::numeric_limits::max(), - std::numeric_limits::max())); - expect(that - % inequality_compare(std::numeric_limits::max(), - std::numeric_limits::max())); - expect(that - % inequality_compare(std::numeric_limits::max(), - std::numeric_limits::max())); - - expect(that - % not inequality_compare(std::numeric_limits::min(), - std::numeric_limits::min())); - expect(that - % not inequality_compare(std::numeric_limits::min(), - std::numeric_limits::min())); - expect(that - % not inequality_compare(std::numeric_limits::min(), - std::numeric_limits::min())); - expect(that - % not inequality_compare(std::numeric_limits::min(), - std::numeric_limits::min())); - expect(that - % not inequality_compare(std::numeric_limits::min(), - std::numeric_limits::min())); - expect(that - % not inequality_compare(std::numeric_limits::min(), - std::numeric_limits::min())); - - expect(that - % not inequality_compare(std::numeric_limits::denorm_min(), - std::numeric_limits::denorm_min())); - expect(that - % not inequality_compare(std::numeric_limits::denorm_min(), - std::numeric_limits::denorm_min())); - expect(that - % not inequality_compare(std::numeric_limits::denorm_min(), - std::numeric_limits::denorm_min())); - expect(that - % not inequality_compare(std::numeric_limits::denorm_min(), - std::numeric_limits::denorm_min())); - expect(that - % not inequality_compare(std::numeric_limits::denorm_min(), - std::numeric_limits::denorm_min())); - expect(that - % not inequality_compare(std::numeric_limits::denorm_min(), - std::numeric_limits::denorm_min())); + "limits_compare_correctly"_test = []() -> void { + expect( + that + % not inequality_compare( + std::numeric_limits::max(), + std::numeric_limits::max() + ) + ); + expect( + that + % not inequality_compare( + std::numeric_limits::max(), + std::numeric_limits::max() + ) + ); + expect( + that + % not inequality_compare( + std::numeric_limits::max(), + std::numeric_limits::max() + ) + ); + expect( + that + % inequality_compare( + std::numeric_limits::max(), + std::numeric_limits::max() + ) + ); + expect( + that + % inequality_compare( + std::numeric_limits::max(), + std::numeric_limits::max() + ) + ); + + expect( + that + % not inequality_compare( + std::numeric_limits::min(), + std::numeric_limits::min() + ) + ); + expect( + that + % not inequality_compare( + std::numeric_limits::min(), + std::numeric_limits::min() + ) + ); + expect( + that + % not inequality_compare( + std::numeric_limits::min(), + std::numeric_limits::min() + ) + ); + expect( + that + % not inequality_compare( + std::numeric_limits::min(), + std::numeric_limits::min() + ) + ); + expect( + that + % not inequality_compare( + std::numeric_limits::min(), + std::numeric_limits::min() + ) + ); + expect( + that + % not inequality_compare( + std::numeric_limits::min(), + std::numeric_limits::min() + ) + ); + + expect( + that + % not inequality_compare( + std::numeric_limits::denorm_min(), + std::numeric_limits::denorm_min() + ) + ); + expect( + that + % not inequality_compare( + std::numeric_limits::denorm_min(), + std::numeric_limits::denorm_min() + ) + ); + expect( + that + % not inequality_compare( + std::numeric_limits::denorm_min(), + std::numeric_limits::denorm_min() + ) + ); + expect( + that + % not inequality_compare( + std::numeric_limits::denorm_min(), + std::numeric_limits::denorm_min() + ) + ); + expect( + that + % not inequality_compare( + std::numeric_limits::denorm_min(), + std::numeric_limits::denorm_min() + ) + ); + expect( + that + % not inequality_compare( + std::numeric_limits::denorm_min(), + std::numeric_limits::denorm_min() + ) + ); expect(that % inequality_compare(std::numeric_limits::min(), 1.0)); expect(that % inequality_compare(std::numeric_limits::min(), 1.0)); expect(that % inequality_compare(std::numeric_limits::min(), 1.0)); }; - "math_results_compare_correctly"_test = [] { + "math_results_compare_correctly"_test = []() -> void { const auto sine1 = std::sin(0.0_f64); const auto sine2 = std::sin(f64_epsilon); expect(that % not inequality_compare(sine1, 0.0)); @@ -454,7 +610,7 @@ namespace hyperion::_test::platform::compare { }; }; - "non_arithmetic_types_compare_correctly"_test = [] { + "non_arithmetic_types_compare_correctly"_test = []() -> void { const auto val1 = non_arithmetic{0_i32}; const auto val2 = non_arithmetic{1_i32}; const auto val3 = non_arithmetic{0_i32}; @@ -464,82 +620,94 @@ namespace hyperion::_test::platform::compare { expect(that % not inequality_compare(val1, val3)); }; - "custom_absolute_epsilon"_test = [] { + "custom_absolute_epsilon"_test = []() -> void { expect(that % not inequality_compare(1.0_f64, 1.0_f64, custom_absolute_epsilon)); - expect(that - % not inequality_compare(1.0_f64, - 1.0_f64 + custom_absolute_epsilon.value(), - custom_absolute_epsilon)); - expect(that - % inequality_compare(1.0_f64, - 1.0_f64 + custom_absolute_epsilon.value() - + custom_absolute_epsilon.value(), - custom_absolute_epsilon)); - }; - - "custom_relative_epsilon"_test = [] { + expect( + that + % not inequality_compare( + 1.0_f64, + 1.0_f64 + custom_absolute_epsilon.value(), + custom_absolute_epsilon + ) + ); + expect( + that + % inequality_compare( + 1.0_f64, + 1.0_f64 + custom_absolute_epsilon.value() + custom_absolute_epsilon.value(), + custom_absolute_epsilon + ) + ); + }; + + "custom_relative_epsilon"_test = []() -> void { expect(that % not inequality_compare(1.0_f64, 1.0_f64, custom_relative_epsilon)); expect( that - % not inequality_compare(1.0_f64, 1.0_f64 + 0.1_f64, custom_relative_epsilon)); - expect(that - % inequality_compare(1.0_f64, 1.0_f64 + 0.2_f64, custom_relative_epsilon)); + % not inequality_compare(1.0_f64, 1.0_f64 + 0.1_f64, custom_relative_epsilon) + ); + expect( + that % inequality_compare(1.0_f64, 1.0_f64 + 0.2_f64, custom_relative_epsilon) + ); expect( that - % not inequality_compare(2.0_f64, 2.0_f64 + 0.1_f64, custom_relative_epsilon)); + % not inequality_compare(2.0_f64, 2.0_f64 + 0.1_f64, custom_relative_epsilon) + ); expect( that - % not inequality_compare(2.0_f64, 2.0_f64 + 0.2_f64, custom_relative_epsilon)); - expect(that - % inequality_compare(2.0_f64, 2.0_f64 + 0.3_f64, custom_relative_epsilon)); + % not inequality_compare(2.0_f64, 2.0_f64 + 0.2_f64, custom_relative_epsilon) + ); + expect( + that % inequality_compare(2.0_f64, 2.0_f64 + 0.3_f64, custom_relative_epsilon) + ); }; }; - "less_than"_test = [] { - "equal_integers_are_not_less_than"_test = [] { + "less_than"_test = []() -> void { + "equal_integers_are_not_less_than"_test = []() -> void { expect(that % not less_than_compare(1_i32, 1_i32)); }; - "less_than_integers_are_less_than"_test = [] { + "less_than_integers_are_less_than"_test = []() -> void { expect(that % less_than_compare(1_i32, 2_i32)); expect(that % less_than_compare(3_i32, 4_i32)); }; - "greater_than_integers_are_not_less_than"_test = [] { + "greater_than_integers_are_not_less_than"_test = []() -> void { expect(that % not less_than_compare(2_i32, 1_i32)); }; - "less_than_integers_are_less_than_very_near_floats"_test = [] { + "less_than_integers_are_less_than_very_near_floats"_test = []() -> void { expect(that % less_than_compare(1_i32, 1.01_f32)); expect(that % less_than_compare(1'000_i32, 1001.0_f32)); }; - "equal_floats_are_not_less_than"_test = [] { + "equal_floats_are_not_less_than"_test = []() -> void { expect(that % not less_than_compare(1.0_f32, 1.0_f32)); expect(that % not less_than_compare(1.0_f64, 1.0_f64)); expect(that % not less_than_compare(1.0_fmax, 1.0_fmax)); }; - "less_than_floats_are_less_than"_test = [] { + "less_than_floats_are_less_than"_test = []() -> void { expect(that % less_than_compare(1.0_f32, 2.0_f32)); expect(that % less_than_compare(1.0_f64, 2.0_f64)); expect(that % less_than_compare(1.0_fmax, 2.0_fmax)); }; - "floats_differing_by_only_1_epsilon_are_not_less_than"_test = [] { + "floats_differing_by_only_1_epsilon_are_not_less_than"_test = []() -> void { expect(that % not less_than_compare(1.0_f32, 1.0_f32 + f32_epsilon)); expect(that % not less_than_compare(1.0_f64, 1.0_f64 + f64_epsilon)); expect(that % not less_than_compare(1.0_fmax, 1.0_fmax + fmax_epsilon)); }; - "floats_differing_by_more_than_1_epsilon_are_not_less_than"_test = [] { + "floats_differing_by_more_than_1_epsilon_are_not_less_than"_test = []() -> void { expect(that % less_than_compare(1.0_f32, 1.0_f32 + f32_epsilon + f32_epsilon)); expect(that % less_than_compare(1.0_f64, 1.0_f64 + f64_epsilon + f64_epsilon)); expect(that % less_than_compare(1.0_fmax, 1.0_fmax + fmax_epsilon + fmax_epsilon)); }; - "floats_near_resolution_limits_compare_correctly"_test = [] { + "floats_near_resolution_limits_compare_correctly"_test = []() -> void { // NOLINTNEXTLINE(*-magic-numbers) expect(that % less_than_compare(1.0e10F, 10'000'001'000.0_f32)); // NOLINTNEXTLINE(*-magic-numbers) @@ -555,8 +723,9 @@ namespace hyperion::_test::platform::compare { expect(that % not less_than_compare(1.0e22L, 10'000'000'000'000'000'000'001.0L)); }; - "comparisons_are_mathematically_consistent"_test = [] { - "values_calculated_from_addition_and_subtraction_compare_correctly"_test = [] { + "comparisons_are_mathematically_consistent"_test = []() -> void { + "values_calculated_from_addition_and_subtraction_compare_correctly"_test + = []() -> void { const auto one_tenth = 0.1_f64; const auto two_tenths = 0.2_f64; const auto three_tenths = 0.3_f64; @@ -571,23 +740,26 @@ namespace hyperion::_test::platform::compare { expect(that % not less_than_compare(three_tenths - calculated, 0.0_f64)); }; - "negated_values_compare_correctly"_test = [] { + "negated_values_compare_correctly"_test = []() -> void { expect(that % not less_than_compare(-0.0_f64, 0.0_f64)); expect(that % less_than_compare(-1.0_f64, 1.0_f64)); expect(that % not less_than_compare(-1.0_f64, -1.0_f64)); expect(that % not less_than_compare(1.0_f64, -1.0_f64)); }; - "identity_operations_compare_correctly"_test = [] { + "identity_operations_compare_correctly"_test = []() -> void { const auto test_value = 1.23456_f64; - expect(that - % not less_than_compare(std::abs(test_value - 0.0_f64) - / (std::abs(test_value) + 0.0_f64), - 1.0_f64)); + expect( + that + % not less_than_compare( + std::abs(test_value - 0.0_f64) / (std::abs(test_value) + 0.0_f64), + 1.0_f64 + ) + ); }; }; - "non_arithmetic_types_compare_correctly"_test = [] { + "non_arithmetic_types_compare_correctly"_test = []() -> void { const auto val1 = non_arithmetic{0_i32}; const auto val2 = non_arithmetic{1_i32}; const auto val3 = non_arithmetic{0_i32}; @@ -597,105 +769,125 @@ namespace hyperion::_test::platform::compare { expect(that % not less_than_compare(val1, val3)); }; - "custom_absolute_epsilon"_test = [] { + "custom_absolute_epsilon"_test = []() -> void { expect(that % not less_than_compare(1.0_f64, 1.0_f64, custom_absolute_epsilon)); - expect(that - % not less_than_compare(1.0_f64, - 1.0_f64 + custom_absolute_epsilon.value(), - custom_absolute_epsilon)); - expect(that - % less_than_compare(1.0_f64, - 1.0_f64 + custom_absolute_epsilon.value() - + custom_absolute_epsilon.value(), - custom_absolute_epsilon)); - }; - - "custom_relative_epsilon"_test = [] { + expect( + that + % not less_than_compare( + 1.0_f64, + 1.0_f64 + custom_absolute_epsilon.value(), + custom_absolute_epsilon + ) + ); + expect( + that + % less_than_compare( + 1.0_f64, + 1.0_f64 + custom_absolute_epsilon.value() + custom_absolute_epsilon.value(), + custom_absolute_epsilon + ) + ); + }; + + "custom_relative_epsilon"_test = []() -> void { expect(that % not less_than_compare(1.0_f64, 1.0_f64, custom_relative_epsilon)); expect( that - % not less_than_compare(1.0_f64, 1.0_f64 + 0.1_f64, custom_relative_epsilon)); - expect(that - % less_than_compare(1.0_f64, 1.0_f64 + 0.2_f64, custom_relative_epsilon)); + % not less_than_compare(1.0_f64, 1.0_f64 + 0.1_f64, custom_relative_epsilon) + ); + expect( + that % less_than_compare(1.0_f64, 1.0_f64 + 0.2_f64, custom_relative_epsilon) + ); expect( that - % not less_than_compare(2.0_f64, 2.0_f64 + 0.1_f64, custom_relative_epsilon)); + % not less_than_compare(2.0_f64, 2.0_f64 + 0.1_f64, custom_relative_epsilon) + ); expect( that - % not less_than_compare(2.0_f64, 2.0_f64 + 0.2_f64, custom_relative_epsilon)); - expect(that - % less_than_compare(2.0_f64, 2.0_f64 + 0.3_f64, custom_relative_epsilon)); + % not less_than_compare(2.0_f64, 2.0_f64 + 0.2_f64, custom_relative_epsilon) + ); + expect( + that % less_than_compare(2.0_f64, 2.0_f64 + 0.3_f64, custom_relative_epsilon) + ); }; }; - "less_than_or_equal"_test = [] { - "equal_integers_are_less_than_or_equal"_test = [] { + "less_than_or_equal"_test = []() -> void { + "equal_integers_are_less_than_or_equal"_test = []() -> void { expect(that % less_than_or_equal_compare(1_i32, 1_i32)); }; - "less_than_integers_are_less_than_or_equal"_test = [] { + "less_than_integers_are_less_than_or_equal"_test = []() -> void { expect(that % less_than_or_equal_compare(1_i32, 2_i32)); expect(that % less_than_or_equal_compare(3_i32, 4_i32)); }; - "greater_than_integers_are_not_less_than_or_equal"_test = [] { + "greater_than_integers_are_not_less_than_or_equal"_test = []() -> void { expect(that % not less_than_or_equal_compare(2_i32, 1_i32)); }; - "less_than_integers_are_less_than_or_equal_very_near_floats"_test = [] { + "less_than_integers_are_less_than_or_equal_very_near_floats"_test = []() -> void { expect(that % less_than_or_equal_compare(1_i32, 1.01_f32)); expect(that % less_than_or_equal_compare(1'000_i32, 1001.0_f32)); }; - "equal_floats_are_less_than_or_equal"_test = [] { + "equal_floats_are_less_than_or_equal"_test = []() -> void { expect(that % less_than_or_equal_compare(1.0_f32, 1.0_f32)); expect(that % less_than_or_equal_compare(1.0_f64, 1.0_f64)); expect(that % less_than_or_equal_compare(1.0_fmax, 1.0_fmax)); }; - "less_than_floats_are_less_than_or_equal"_test = [] { + "less_than_floats_are_less_than_or_equal"_test = []() -> void { expect(that % less_than_or_equal_compare(1.0_f32, 2.0_f32)); expect(that % less_than_or_equal_compare(1.0_f64, 2.0_f64)); expect(that % less_than_or_equal_compare(1.0_fmax, 2.0_fmax)); }; - "floats_differing_by_only_1_epsilon_are_less_than_or_equal"_test = [] { + "floats_differing_by_only_1_epsilon_are_less_than_or_equal"_test = []() -> void { expect(that % less_than_or_equal_compare(1.0_f32, 1.0_f32 + f32_epsilon)); expect(that % less_than_or_equal_compare(1.0_f64, 1.0_f64 + f64_epsilon)); expect(that % less_than_or_equal_compare(1.0_fmax, 1.0_fmax + fmax_epsilon)); }; - "floats_differing_by_more_than_1_epsilon_are_less_than_or_equal"_test = [] { - expect(that - % less_than_or_equal_compare(1.0_f32, 1.0_f32 + f32_epsilon + f32_epsilon)); - expect(that - % less_than_or_equal_compare(1.0_f64, 1.0_f64 + f64_epsilon + f64_epsilon)); + "floats_differing_by_more_than_1_epsilon_are_less_than_or_equal"_test = []() -> void { + expect( + that % less_than_or_equal_compare(1.0_f32, 1.0_f32 + f32_epsilon + f32_epsilon) + ); + expect( + that % less_than_or_equal_compare(1.0_f64, 1.0_f64 + f64_epsilon + f64_epsilon) + ); expect( that - % less_than_or_equal_compare(1.0_fmax, 1.0_fmax + fmax_epsilon + fmax_epsilon)); + % less_than_or_equal_compare(1.0_fmax, 1.0_fmax + fmax_epsilon + fmax_epsilon) + ); }; - "floats_near_resolution_limits_compare_correctly"_test = [] { + "floats_near_resolution_limits_compare_correctly"_test = []() -> void { // NOLINTNEXTLINE(*-magic-numbers) expect(that % less_than_or_equal_compare(1.0e10F, 10'000'001'000.0_f32)); // NOLINTNEXTLINE(*-magic-numbers) expect(that % less_than_or_equal_compare(1.0e16, 10'000'000'000'001'000.0)); - expect(that - // NOLINTNEXTLINE(*-magic-numbers) - % less_than_or_equal_compare(1.0e22L, 10'000'000'000'000'000'001'000.0L)); + expect( + that + // NOLINTNEXTLINE(*-magic-numbers) + % less_than_or_equal_compare(1.0e22L, 10'000'000'000'000'000'001'000.0L) + ); // NOLINTNEXTLINE(*-magic-numbers) expect(that % less_than_or_equal_compare(1.0e10F, 10'000'000'001.0_f32)); // NOLINTNEXTLINE(*-magic-numbers) expect(that % less_than_or_equal_compare(1.0e16, 10'000'000'000'000'001.0)); - expect(that - // NOLINTNEXTLINE(*-magic-numbers) - % less_than_or_equal_compare(1.0e22L, 10'000'000'000'000'000'000'001.0L)); + expect( + that + // NOLINTNEXTLINE(*-magic-numbers) + % less_than_or_equal_compare(1.0e22L, 10'000'000'000'000'000'000'001.0L) + ); }; - "comparisons_are_mathematically_consistent"_test = [] { - "values_calculated_from_addition_and_subtraction_compare_correctly"_test = [] { + "comparisons_are_mathematically_consistent"_test = []() -> void { + "values_calculated_from_addition_and_subtraction_compare_correctly"_test + = []() -> void { const auto one_tenth = 0.1_f64; const auto two_tenths = 0.2_f64; const auto three_tenths = 0.3_f64; @@ -710,23 +902,26 @@ namespace hyperion::_test::platform::compare { expect(that % less_than_or_equal_compare(three_tenths - calculated, 0.0_f64)); }; - "negated_values_compare_correctly"_test = [] { + "negated_values_compare_correctly"_test = []() -> void { expect(that % less_than_or_equal_compare(-0.0_f64, 0.0_f64)); expect(that % less_than_or_equal_compare(-1.0_f64, 1.0_f64)); expect(that % less_than_or_equal_compare(-1.0_f64, -1.0_f64)); expect(that % not less_than_or_equal_compare(1.0_f64, -1.0_f64)); }; - "identity_operations_compare_correctly"_test = [] { + "identity_operations_compare_correctly"_test = []() -> void { const auto test_value = 1.23456_f64; - expect(that - % less_than_or_equal_compare(std::abs(test_value - 0.0_f64) - / (std::abs(test_value) + 0.0_f64), - 1.0_f64)); + expect( + that + % less_than_or_equal_compare( + std::abs(test_value - 0.0_f64) / (std::abs(test_value) + 0.0_f64), + 1.0_f64 + ) + ); }; }; - "non_arithmetic_types_compare_correctly"_test = [] { + "non_arithmetic_types_compare_correctly"_test = []() -> void { const auto val1 = non_arithmetic{0_i32}; const auto val2 = non_arithmetic{1_i32}; const auto val3 = non_arithmetic{0_i32}; @@ -736,105 +931,138 @@ namespace hyperion::_test::platform::compare { expect(that % less_than_or_equal_compare(val1, val3)); }; - "custom_absolute_epsilon"_test = [] { - expect(that - % less_than_or_equal_compare(1.0_f64, 1.0_f64, custom_absolute_epsilon)); - expect(that - % less_than_or_equal_compare(1.0_f64, - 1.0_f64 + custom_absolute_epsilon.value(), - custom_absolute_epsilon)); - expect(that - % less_than_or_equal_compare(1.0_f64, - 1.0_f64 + custom_absolute_epsilon.value() - + custom_absolute_epsilon.value(), - custom_absolute_epsilon)); - expect(that - % not less_than_or_equal_compare(1.1_f64, 1.0_f64, custom_absolute_epsilon)); - }; - - "custom_relative_epsilon"_test = [] { - expect(that - % less_than_or_equal_compare(1.0_f64, 1.0_f64, custom_relative_epsilon)); - expect(that - % less_than_or_equal_compare(1.0_f64, - 1.0_f64 + 0.1_f64, - custom_relative_epsilon)); - expect(that - % less_than_or_equal_compare(1.0_f64, - 1.0_f64 + 0.2_f64, - custom_relative_epsilon)); - expect(that - % not less_than_or_equal_compare(1.2_f64, 1.0_f64, custom_relative_epsilon)); - - expect(that - % less_than_or_equal_compare(2.0_f64, - 2.0_f64 + 0.1_f64, - custom_relative_epsilon)); - expect(that - % less_than_or_equal_compare(2.0_f64, - 2.0_f64 + 0.2_f64, - custom_relative_epsilon)); - expect(that - % less_than_or_equal_compare(2.0_f64, - 2.0_f64 + 0.3_f64, - custom_relative_epsilon)); - expect(that - % not less_than_or_equal_compare(2.3_f64, 2.0_f64, custom_relative_epsilon)); + "custom_absolute_epsilon"_test = []() -> void { + expect( + that % less_than_or_equal_compare(1.0_f64, 1.0_f64, custom_absolute_epsilon) + ); + expect( + that + % less_than_or_equal_compare( + 1.0_f64, + 1.0_f64 + custom_absolute_epsilon.value(), + custom_absolute_epsilon + ) + ); + expect( + that + % less_than_or_equal_compare( + 1.0_f64, + 1.0_f64 + custom_absolute_epsilon.value() + custom_absolute_epsilon.value(), + custom_absolute_epsilon + ) + ); + expect( + that % not less_than_or_equal_compare(1.1_f64, 1.0_f64, custom_absolute_epsilon) + ); + }; + + "custom_relative_epsilon"_test = []() -> void { + expect( + that % less_than_or_equal_compare(1.0_f64, 1.0_f64, custom_relative_epsilon) + ); + expect( + that + % less_than_or_equal_compare( + 1.0_f64, + 1.0_f64 + 0.1_f64, + custom_relative_epsilon + ) + ); + expect( + that + % less_than_or_equal_compare( + 1.0_f64, + 1.0_f64 + 0.2_f64, + custom_relative_epsilon + ) + ); + expect( + that % not less_than_or_equal_compare(1.2_f64, 1.0_f64, custom_relative_epsilon) + ); + + expect( + that + % less_than_or_equal_compare( + 2.0_f64, + 2.0_f64 + 0.1_f64, + custom_relative_epsilon + ) + ); + expect( + that + % less_than_or_equal_compare( + 2.0_f64, + 2.0_f64 + 0.2_f64, + custom_relative_epsilon + ) + ); + expect( + that + % less_than_or_equal_compare( + 2.0_f64, + 2.0_f64 + 0.3_f64, + custom_relative_epsilon + ) + ); + expect( + that % not less_than_or_equal_compare(2.3_f64, 2.0_f64, custom_relative_epsilon) + ); }; }; - "greater_than"_test = [] { - "equal_integers_are_not_greater_than"_test = [] { + "greater_than"_test = []() -> void { + "equal_integers_are_not_greater_than"_test = []() -> void { expect(that % not greater_than_compare(1_i32, 1_i32)); }; - "less_than_integers_are_not_greater_than"_test = [] { + "less_than_integers_are_not_greater_than"_test = []() -> void { expect(that % not greater_than_compare(1_i32, 2_i32)); expect(that % not greater_than_compare(3_i32, 4_i32)); }; - "greater_than_integers_are_greater_than"_test = [] { + "greater_than_integers_are_greater_than"_test = []() -> void { expect(that % greater_than_compare(2_i32, 1_i32)); expect(that % greater_than_compare(1_i32, 0_i32)); }; - "greater_than_integers_are_greater_than_very_near_floats"_test = [] { + "greater_than_integers_are_greater_than_very_near_floats"_test = []() -> void { expect(that % greater_than_compare(1_i32, 0.9999_f32)); expect(that % greater_than_compare(1'000_i32, 999.99_f32)); }; - "equal_floats_are_not_greater_than"_test = [] { + "equal_floats_are_not_greater_than"_test = []() -> void { expect(that % not greater_than_compare(1.0_f32, 1.0_f32)); expect(that % not greater_than_compare(1.0_f64, 1.0_f64)); expect(that % not greater_than_compare(1.0_fmax, 1.0_fmax)); }; - "less_than_floats_are_not_greater_than"_test = [] { + "less_than_floats_are_not_greater_than"_test = []() -> void { expect(that % not greater_than_compare(1.0_f32, 2.0_f32)); expect(that % not greater_than_compare(1.0_f64, 2.0_f64)); expect(that % not greater_than_compare(1.0_fmax, 2.0_fmax)); }; - "greater_than_floats_are_greater_than"_test = [] { + "greater_than_floats_are_greater_than"_test = []() -> void { expect(that % greater_than_compare(2.0_f32, 1.0_f32)); expect(that % greater_than_compare(2.0_f64, 1.0_f64)); expect(that % greater_than_compare(2.0_fmax, 1.0_fmax)); }; - "floats_differing_by_only_1_epsilon_are_not_greater_than"_test = [] { + "floats_differing_by_only_1_epsilon_are_not_greater_than"_test = []() -> void { expect(that % not greater_than_compare(1.0_f32 + f32_epsilon, 1.0_f32)); expect(that % not greater_than_compare(1.0_f64 + f64_epsilon, 1.0_f64)); expect(that % not greater_than_compare(1.0_fmax + fmax_epsilon, 1.0_fmax)); }; - "floats_differing_by_more_than_1_epsilon_are_greater_than"_test = [] { + "floats_differing_by_more_than_1_epsilon_are_greater_than"_test = []() -> void { expect(that % greater_than_compare(1.0_f32 + f32_epsilon + f32_epsilon, 1.0_f32)); expect(that % greater_than_compare(1.0_f64 + f64_epsilon + f64_epsilon, 1.0_f64)); - expect(that - % greater_than_compare(1.0_fmax + fmax_epsilon + fmax_epsilon, 1.0_fmax)); + expect( + that % greater_than_compare(1.0_fmax + fmax_epsilon + fmax_epsilon, 1.0_fmax) + ); }; - "floats_near_resolution_limits_compare_correctly"_test = [] { + "floats_near_resolution_limits_compare_correctly"_test = []() -> void { // NOLINTNEXTLINE(*-magic-numbers) expect(that % greater_than_compare(10'000'001'000.0_f32, 1.0e10F)); // NOLINTNEXTLINE(*-magic-numbers) @@ -850,8 +1078,9 @@ namespace hyperion::_test::platform::compare { expect(that % not greater_than_compare(1.0e22L, 10'000'000'000'000'000'000'001.0L)); }; - "comparisons_are_mathematically_consistent"_test = [] { - "values_calculated_from_addition_and_subtraction_compare_correctly"_test = [] { + "comparisons_are_mathematically_consistent"_test = []() -> void { + "values_calculated_from_addition_and_subtraction_compare_correctly"_test + = []() -> void { const auto one_tenth = 0.1_f64; const auto two_tenths = 0.2_f64; const auto three_tenths = 0.3_f64; @@ -866,23 +1095,26 @@ namespace hyperion::_test::platform::compare { expect(that % not greater_than_compare(three_tenths - calculated, 0.0_f64)); }; - "negated_values_compare_correctly"_test = [] { + "negated_values_compare_correctly"_test = []() -> void { expect(that % not greater_than_compare(-0.0_f64, 0.0_f64)); expect(that % greater_than_compare(1.0_f64, -1.0_f64)); expect(that % not greater_than_compare(-1.0_f64, -1.0_f64)); expect(that % not greater_than_compare(-1.0_f64, 1.0_f64)); }; - "identity_operations_compare_correctly"_test = [] { + "identity_operations_compare_correctly"_test = []() -> void { const auto test_value = 1.23456_f64; - expect(that - % not greater_than_compare(std::abs(test_value - 0.0_f64) - / (std::abs(test_value) + 0.0_f64), - 1.0_f64)); + expect( + that + % not greater_than_compare( + std::abs(test_value - 0.0_f64) / (std::abs(test_value) + 0.0_f64), + 1.0_f64 + ) + ); }; }; - "non_arithmetic_types_compare_correctly"_test = [] { + "non_arithmetic_types_compare_correctly"_test = []() -> void { const auto val1 = non_arithmetic{0_i32}; const auto val2 = non_arithmetic{1_i32}; const auto val3 = non_arithmetic{0_i32}; @@ -892,138 +1124,166 @@ namespace hyperion::_test::platform::compare { expect(that % not greater_than_compare(val1, val3)); }; - "custom_absolute_epsilon"_test = [] { + "custom_absolute_epsilon"_test = []() -> void { expect(that % not greater_than_compare(1.0_f64, 1.0_f64, custom_absolute_epsilon)); - expect(that - % not greater_than_compare(1.0_f64, - 1.0_f64 + custom_absolute_epsilon.value(), - custom_absolute_epsilon)); - expect(that - % not greater_than_compare(1.0_f64, - 1.0_f64 + custom_absolute_epsilon.value() - + custom_absolute_epsilon.value(), - custom_absolute_epsilon)); - expect(that - % greater_than_compare(1.0_f64 + custom_absolute_epsilon.value() - + custom_absolute_epsilon.value(), - 1.0_f64, - custom_absolute_epsilon)); - }; - - "custom_relative_epsilon"_test = [] { + expect( + that + % not greater_than_compare( + 1.0_f64, + 1.0_f64 + custom_absolute_epsilon.value(), + custom_absolute_epsilon + ) + ); + expect( + that + % not greater_than_compare( + 1.0_f64, + 1.0_f64 + custom_absolute_epsilon.value() + custom_absolute_epsilon.value(), + custom_absolute_epsilon + ) + ); + expect( + that + % greater_than_compare( + 1.0_f64 + custom_absolute_epsilon.value() + custom_absolute_epsilon.value(), + 1.0_f64, + custom_absolute_epsilon + ) + ); + }; + + "custom_relative_epsilon"_test = []() -> void { expect(that % not greater_than_compare(1.0_f64, 1.0_f64, custom_relative_epsilon)); - expect(that - % not greater_than_compare(1.0_f64, - 1.0_f64 + 0.1_f64, - custom_relative_epsilon)); - expect(that - % not greater_than_compare(1.0_f64, - 1.0_f64 + 0.2_f64, - custom_relative_epsilon)); - - expect(that - % not greater_than_compare(2.0_f64, - 2.0_f64 + 0.1_f64, - custom_relative_epsilon)); - expect(that - % not greater_than_compare(2.0_f64, - 2.0_f64 + 0.2_f64, - custom_relative_epsilon)); - expect(that - % not greater_than_compare(2.0_f64, - 2.0_f64 + 0.3_f64, - custom_relative_epsilon)); - expect(that - % greater_than_compare(2.0_f64 + 0.3_f64, 2.0_f64, custom_relative_epsilon)); + expect( + that + % not greater_than_compare(1.0_f64, 1.0_f64 + 0.1_f64, custom_relative_epsilon) + ); + expect( + that + % not greater_than_compare(1.0_f64, 1.0_f64 + 0.2_f64, custom_relative_epsilon) + ); + + expect( + that + % not greater_than_compare(2.0_f64, 2.0_f64 + 0.1_f64, custom_relative_epsilon) + ); + expect( + that + % not greater_than_compare(2.0_f64, 2.0_f64 + 0.2_f64, custom_relative_epsilon) + ); + expect( + that + % not greater_than_compare(2.0_f64, 2.0_f64 + 0.3_f64, custom_relative_epsilon) + ); + expect( + that % greater_than_compare(2.0_f64 + 0.3_f64, 2.0_f64, custom_relative_epsilon) + ); }; }; - "greater_than_or_equal"_test = [] { - "equal_integers_are_greater_than_or_equal"_test = [] { + "greater_than_or_equal"_test = []() -> void { + "equal_integers_are_greater_than_or_equal"_test = []() -> void { expect(that % greater_than_or_equal_compare(1_i32, 1_i32)); }; - "less_than_integers_are_not_greater_than_or_equal"_test = [] { + "less_than_integers_are_not_greater_than_or_equal"_test = []() -> void { expect(that % not greater_than_or_equal_compare(1_i32, 2_i32)); expect(that % not greater_than_or_equal_compare(3_i32, 4_i32)); }; - "greater_than_integers_are_greater_than_or_equal"_test = [] { + "greater_than_integers_are_greater_than_or_equal"_test = []() -> void { expect(that % greater_than_or_equal_compare(2_i32, 1_i32)); expect(that % greater_than_or_equal_compare(4_i32, 3_i32)); }; - "less_than_integers_are_not_greater_than_or_equal_very_near_floats"_test = [] { + "less_than_integers_are_not_greater_than_or_equal_very_near_floats"_test + = []() -> void { expect(that % not greater_than_or_equal_compare(1_i32, 1.01_f32)); expect(that % not greater_than_or_equal_compare(1'000_i32, 1001.0_f32)); }; - "equal_floats_are_greater_than_or_equal"_test = [] { + "equal_floats_are_greater_than_or_equal"_test = []() -> void { expect(that % greater_than_or_equal_compare(1.0_f32, 1.0_f32)); expect(that % greater_than_or_equal_compare(1.0_f64, 1.0_f64)); expect(that % greater_than_or_equal_compare(1.0_fmax, 1.0_fmax)); }; - "less_than_floats_are_not_greater_than_or_equal"_test = [] { + "less_than_floats_are_not_greater_than_or_equal"_test = []() -> void { expect(that % not greater_than_or_equal_compare(1.0_f32, 2.0_f32)); expect(that % not greater_than_or_equal_compare(1.0_f64, 2.0_f64)); expect(that % not greater_than_or_equal_compare(1.0_fmax, 2.0_fmax)); }; - "greater_than_floats_are_greater_than_or_equal"_test = [] { + "greater_than_floats_are_greater_than_or_equal"_test = []() -> void { expect(that % greater_than_or_equal_compare(2.0_f32, 1.0_f32)); expect(that % greater_than_or_equal_compare(2.0_f64, 1.0_f64)); expect(that % greater_than_or_equal_compare(2.0_fmax, 1.0_fmax)); }; - "floats_differing_by_only_1_epsilon_are_greater_than_or_equal"_test = [] { + "floats_differing_by_only_1_epsilon_are_greater_than_or_equal"_test = []() -> void { expect(that % greater_than_or_equal_compare(1.0_f32, 1.0_f32 + f32_epsilon)); expect(that % greater_than_or_equal_compare(1.0_f64, 1.0_f64 + f64_epsilon)); expect(that % greater_than_or_equal_compare(1.0_fmax, 1.0_fmax + fmax_epsilon)); }; - "floats_differing_by_more_than_1_epsilon_are_greater_than_or_equal"_test = [] { + "floats_differing_by_more_than_1_epsilon_are_greater_than_or_equal"_test + = []() -> void { + expect( + that + % greater_than_or_equal_compare(1.0_f32 + f32_epsilon + f32_epsilon, 1.0_f32) + ); expect( that - % greater_than_or_equal_compare(1.0_f32 + f32_epsilon + f32_epsilon, 1.0_f32)); + % greater_than_or_equal_compare(1.0_f64 + f64_epsilon + f64_epsilon, 1.0_f64) + ); expect( that - % greater_than_or_equal_compare(1.0_f64 + f64_epsilon + f64_epsilon, 1.0_f64)); - expect(that - % greater_than_or_equal_compare(1.0_fmax + fmax_epsilon + fmax_epsilon, - 1.0_fmax)); + % greater_than_or_equal_compare( + 1.0_fmax + fmax_epsilon + fmax_epsilon, + 1.0_fmax + ) + ); }; - "floats_near_resolution_limits_compare_correctly"_test = [] { + "floats_near_resolution_limits_compare_correctly"_test = []() -> void { // NOLINTNEXTLINE(*-magic-numbers) expect(that % not greater_than_or_equal_compare(1.0e10F, 10'000'001'000.0_f32)); // NOLINTNEXTLINE(*-magic-numbers) expect(that % not greater_than_or_equal_compare(1.0e16, 10'000'000'000'001'000.0)); - expect(that - // NOLINTNEXTLINE(*-magic-numbers) - % not greater_than_or_equal_compare(1.0e22L, - // NOLINTNEXTLINE(*-magic-numbers) - 10'000'000'000'000'010'000'000.0L)); + expect( + that + % not greater_than_or_equal_compare( + // NOLINTNEXTLINE(*-magic-numbers) + 1.0e22L, + // NOLINTNEXTLINE(*-magic-numbers) + 10'000'000'000'000'010'000'000.0L + ) + ); // NOLINTNEXTLINE(*-magic-numbers) expect(that % greater_than_or_equal_compare(1.0e10F, 10'000'000'001.0_f32)); // NOLINTNEXTLINE(*-magic-numbers) expect(that % greater_than_or_equal_compare(1.0e16, 10'000'000'000'000'001.0)); - expect(that - // NOLINTNEXTLINE(*-magic-numbers) - % greater_than_or_equal_compare(1.0e22L, 10'000'000'000'000'000'000'001.0L)); + expect( + that + // NOLINTNEXTLINE(*-magic-numbers) + % greater_than_or_equal_compare(1.0e22L, 10'000'000'000'000'000'000'001.0L) + ); // NOLINTNEXTLINE(*-magic-numbers) expect(that % greater_than_or_equal_compare(10'000'001'000.0_f32, 1.0e10F)); // NOLINTNEXTLINE(*-magic-numbers) expect(that % greater_than_or_equal_compare(10'000'000'000'001'000.0, 1.0e16)); - expect(that - // NOLINTNEXTLINE(*-magic-numbers) - % greater_than_or_equal_compare(10'000'000'000'000'000'001'000.0L, 1.0e22L)); + expect( + that + // NOLINTNEXTLINE(*-magic-numbers) + % greater_than_or_equal_compare(10'000'000'000'000'000'001'000.0L, 1.0e22L) + ); }; - "comparisons_are_mathematically_consistent"_test = [] { - "values_calculated_from_addition_and_subtraction_compare_correctly"_test = [] { + "comparisons_are_mathematically_consistent"_test = []() -> void { + "values_calculated_from_addition_and_subtraction_compare_correctly"_test + = []() -> void { const auto one_tenth = 0.1_f64; const auto two_tenths = 0.2_f64; const auto three_tenths = 0.3_f64; @@ -1035,27 +1295,31 @@ namespace hyperion::_test::platform::compare { expect(that % greater_than_or_equal_compare(three_tenths, one_tenth)); expect(that % greater_than_or_equal_compare(calculated, one_tenth)); expect(that % greater_than_or_equal_compare(calculated, three_tenths)); - expect(that - % greater_than_or_equal_compare(0.0_f64, three_tenths - calculated)); + expect( + that % greater_than_or_equal_compare(0.0_f64, three_tenths - calculated) + ); }; - "negated_values_compare_correctly"_test = [] { + "negated_values_compare_correctly"_test = []() -> void { expect(that % greater_than_or_equal_compare(-0.0_f64, 0.0_f64)); expect(that % greater_than_or_equal_compare(1.0_f64, -1.0_f64)); expect(that % greater_than_or_equal_compare(-1.0_f64, -1.0_f64)); expect(that % not greater_than_or_equal_compare(-1.0_f64, 1.0_f64)); }; - "identity_operations_compare_correctly"_test = [] { + "identity_operations_compare_correctly"_test = []() -> void { const auto test_value = 1.23456_f64; - expect(that - % greater_than_or_equal_compare(std::abs(test_value - 0.0_f64) - / (std::abs(test_value) + 0.0_f64), - 1.0_f64)); + expect( + that + % greater_than_or_equal_compare( + std::abs(test_value - 0.0_f64) / (std::abs(test_value) + 0.0_f64), + 1.0_f64 + ) + ); }; }; - "non_arithmetic_types_compare_correctly"_test = [] { + "non_arithmetic_types_compare_correctly"_test = []() -> void { const auto val1 = non_arithmetic{0_i32}; const auto val2 = non_arithmetic{1_i32}; const auto val3 = non_arithmetic{0_i32}; @@ -1065,109 +1329,187 @@ namespace hyperion::_test::platform::compare { expect(that % greater_than_or_equal_compare(val1, val3)); }; - "custom_absolute_epsilon"_test = [] { - expect(that - % greater_than_or_equal_compare(1.0_f64, 1.0_f64, custom_absolute_epsilon)); - expect(that - % greater_than_or_equal_compare(1.0_f64, - 1.0_f64 + custom_absolute_epsilon.value(), - custom_absolute_epsilon)); - expect(that - % not greater_than_or_equal_compare(1.0_f64, - 1.0_f64 + custom_absolute_epsilon.value() - + custom_absolute_epsilon.value(), - custom_absolute_epsilon)); - expect(that - % greater_than_or_equal_compare(1.0_f64 + custom_absolute_epsilon.value() - + custom_absolute_epsilon.value(), - 1.0_f64, - custom_absolute_epsilon)); - }; - - "custom_relative_epsilon"_test = [] { - expect(that - % greater_than_or_equal_compare(1.0_f64, 1.0_f64, custom_relative_epsilon)); - expect(that - % greater_than_or_equal_compare(1.0_f64, - 1.0_f64 + 0.1_f64, - custom_relative_epsilon)); - expect(that - % not greater_than_or_equal_compare(1.0_f64, - 1.0_f64 + 0.2_f64, - custom_relative_epsilon)); - - expect(that - % greater_than_or_equal_compare(2.0_f64, - 2.0_f64 + 0.1_f64, - custom_relative_epsilon)); - expect(that - % greater_than_or_equal_compare(2.0_f64, - 2.0_f64 + 0.2_f64, - custom_relative_epsilon)); - expect(that - % not greater_than_or_equal_compare(2.0_f64, - 2.0_f64 + 0.3_f64, - custom_relative_epsilon)); - expect(that - % greater_than_or_equal_compare(2.0_f64 + 0.3_f64, - 2.0_f64, - custom_relative_epsilon)); + "custom_absolute_epsilon"_test = []() -> void { + expect( + that % greater_than_or_equal_compare(1.0_f64, 1.0_f64, custom_absolute_epsilon) + ); + expect( + that + % greater_than_or_equal_compare( + 1.0_f64, + 1.0_f64 + custom_absolute_epsilon.value(), + custom_absolute_epsilon + ) + ); + expect( + that + % not greater_than_or_equal_compare( + 1.0_f64, + 1.0_f64 + custom_absolute_epsilon.value() + custom_absolute_epsilon.value(), + custom_absolute_epsilon + ) + ); + expect( + that + % greater_than_or_equal_compare( + 1.0_f64 + custom_absolute_epsilon.value() + custom_absolute_epsilon.value(), + 1.0_f64, + custom_absolute_epsilon + ) + ); + }; + + "custom_relative_epsilon"_test = []() -> void { + expect( + that % greater_than_or_equal_compare(1.0_f64, 1.0_f64, custom_relative_epsilon) + ); + expect( + that + % greater_than_or_equal_compare( + 1.0_f64, + 1.0_f64 + 0.1_f64, + custom_relative_epsilon + ) + ); + expect( + that + % not greater_than_or_equal_compare( + 1.0_f64, + 1.0_f64 + 0.2_f64, + custom_relative_epsilon + ) + ); + + expect( + that + % greater_than_or_equal_compare( + 2.0_f64, + 2.0_f64 + 0.1_f64, + custom_relative_epsilon + ) + ); + expect( + that + % greater_than_or_equal_compare( + 2.0_f64, + 2.0_f64 + 0.2_f64, + custom_relative_epsilon + ) + ); + expect( + that + % not greater_than_or_equal_compare( + 2.0_f64, + 2.0_f64 + 0.3_f64, + custom_relative_epsilon + ) + ); + expect( + that + % greater_than_or_equal_compare( + 2.0_f64 + 0.3_f64, + 2.0_f64, + custom_relative_epsilon + ) + ); }; }; }; struct not_comparable { }; - static_assert(EqualityComparable, - "hyperion::platform::compare::EqualityComparable test case 1 failing"); - static_assert(EqualityComparable, - "hyperion::platform::compare::EqualityComparable test case 2 failing"); - static_assert(!EqualityComparable, - "hyperion::platform::compare::EqualityComparable test case 3 failing"); - - static_assert(InequalityComparable, - "hyperion::platform::compare::InequalityComparable test case 1 failing"); - static_assert(InequalityComparable, - "hyperion::platform::compare::InequalityComparable test case 2 failing"); - static_assert(!InequalityComparable, - "hyperion::platform::compare::InequalityComparable test case 3 failing"); - - static_assert(LessThanComparable, - "hyperion::platform::compare::LessThanComparable test case 1 failing"); - static_assert(LessThanComparable, - "hyperion::platform::compare::LessThanComparable test case 2 failing"); - static_assert(!LessThanComparable, - "hyperion::platform::compare::LessThanComparable test case 3 failing"); - - static_assert(LessThanOrEqualComparable, - "hyperion::platform::compare::LessThanOrEqualComparable test case 1 failing"); - static_assert(LessThanOrEqualComparable, - "hyperion::platform::compare::LessThanOrEqualComparable test case 2 failing"); - static_assert(!LessThanOrEqualComparable, - "hyperion::platform::compare::LessThanOrEqualComparable test case 3 failing"); - - static_assert(GreaterThanComparable, - "hyperion::platform::compare::GreaterThanComparable test case 1 failing"); - static_assert(GreaterThanComparable, - "hyperion::platform::compare::GreaterThanComparable test case 2 failing"); - static_assert(!GreaterThanComparable, - "hyperion::platform::compare::GreaterThanComparable test case 3 failing"); - - static_assert(GreaterThanOrEqualComparable, - "hyperion::platform::compare::GreaterThanOrEqualComparable test case 1 failing"); - static_assert(GreaterThanOrEqualComparable, - "hyperion::platform::compare::GreaterThanOrEqualComparable test case 2 failing"); - static_assert(!GreaterThanOrEqualComparable, - "hyperion::platform::compare::GreaterThanOrEqualComparable test case 3 failing"); + static_assert( + EqualityComparable, + "hyperion::platform::compare::EqualityComparable test case 1 failing" + ); + static_assert( + EqualityComparable, + "hyperion::platform::compare::EqualityComparable test case 2 failing" + ); + static_assert( + !EqualityComparable, + "hyperion::platform::compare::EqualityComparable test case 3 failing" + ); + + static_assert( + InequalityComparable, + "hyperion::platform::compare::InequalityComparable test case 1 failing" + ); + static_assert( + InequalityComparable, + "hyperion::platform::compare::InequalityComparable test case 2 failing" + ); + static_assert( + !InequalityComparable, + "hyperion::platform::compare::InequalityComparable test case 3 failing" + ); + + static_assert( + LessThanComparable, + "hyperion::platform::compare::LessThanComparable test case 1 failing" + ); + static_assert( + LessThanComparable, + "hyperion::platform::compare::LessThanComparable test case 2 failing" + ); + static_assert( + !LessThanComparable, + "hyperion::platform::compare::LessThanComparable test case 3 failing" + ); + + static_assert( + LessThanOrEqualComparable, + "hyperion::platform::compare::LessThanOrEqualComparable test case 1 failing" + ); + static_assert( + LessThanOrEqualComparable, + "hyperion::platform::compare::LessThanOrEqualComparable test case 2 failing" + ); + static_assert( + !LessThanOrEqualComparable, + "hyperion::platform::compare::LessThanOrEqualComparable test case 3 failing" + ); + + static_assert( + GreaterThanComparable, + "hyperion::platform::compare::GreaterThanComparable test case 1 failing" + ); + static_assert( + GreaterThanComparable, + "hyperion::platform::compare::GreaterThanComparable test case 2 failing" + ); + static_assert( + !GreaterThanComparable, + "hyperion::platform::compare::GreaterThanComparable test case 3 failing" + ); + + static_assert( + GreaterThanOrEqualComparable, + "hyperion::platform::compare::GreaterThanOrEqualComparable test case 1 failing" + ); + static_assert( + GreaterThanOrEqualComparable, + "hyperion::platform::compare::GreaterThanOrEqualComparable test case 2 failing" + ); + static_assert( + !GreaterThanOrEqualComparable, + "hyperion::platform::compare::GreaterThanOrEqualComparable test case 3 failing" + ); #if HYPERION_PLATFORM_STD_LIB_HAS_COMPARE - static_assert(ThreeWayComparable, - "hyperion::platform::compare::ThreeWayComparable test case 1 failing"); - static_assert(ThreeWayComparable, - "hyperion::platform::compare::ThreeWayComparable test case 2 failing"); - static_assert(!ThreeWayComparable, - "hyperion::platform::compare::ThreeWayComparable test case 3 failing"); + static_assert( + ThreeWayComparable, + "hyperion::platform::compare::ThreeWayComparable test case 1 failing" + ); + static_assert( + ThreeWayComparable, + "hyperion::platform::compare::ThreeWayComparable test case 2 failing" + ); + static_assert( + !ThreeWayComparable, + "hyperion::platform::compare::ThreeWayComparable test case 3 failing" + ); #endif // HYPERION_PLATFORM_STD_LIB_HAS_COMPARE diff --git a/src/test_main.cpp b/src/test_main.cpp index 9214eba..84f7ee8 100644 --- a/src/test_main.cpp +++ b/src/test_main.cpp @@ -1,11 +1,11 @@ /// @file test_main.cpp /// @author Braxton Salyer /// @brief Unit tests main for hyperion::platform. -/// @version 0.1.1 -/// @date 2025-07-09 +/// @version 0.1.2 +/// @date 2025-11-25 /// /// MIT License -/// @copyright Copyright (c) 2024 Braxton Salyer +/// @copyright Copyright (c) 2025 Braxton Salyer /// /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal @@ -31,8 +31,8 @@ #include #if HYPERION_PLATFORM_COMPILER_IS_CLANG - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wmissing-variable-declarations" +_Pragma("GCC diagnostic push"); +_Pragma("GCC diagnostic ignored \"-Wmissing-variable-declarations\""); #endif // HYPERION_PLATFORM_COMPILER_IS_CLANG template<> @@ -41,7 +41,7 @@ auto boost::ut::cfg = boost::ut::runner>{}; #if HYPERION_PLATFORM_COMPILER_IS_CLANG - #pragma GCC diagnostic pop +_Pragma("GCC diagnostic pop"); #endif // HYPERION_PLATFORM_COMPILER_IS_CLANG #include "test/compare.h" @@ -51,5 +51,6 @@ using namespace hyperion; // NOLINT(google-build-using-namespace) // NOLINTNEXTLINE(bugprone-exception-escape) [[nodiscard]] auto main([[maybe_unused]] i32 argc, [[maybe_unused]] const char** argv) -> i32 { return static_cast( - boost::ut::cfg.run(boost::ut::run_cfg{.argc = argc, .argv = argv})); + boost::ut::cfg.run(boost::ut::run_cfg{.argc = argc, .argv = argv}) + ); } diff --git a/xmake.lua b/xmake.lua index 66b658c..3677d99 100644 --- a/xmake.lua +++ b/xmake.lua @@ -1,6 +1,6 @@ ---@diagnostic disable: undefined-global,undefined-field set_project("hyperion_platform") -set_version("0.5.4") +set_version("0.5.5") set_xmakever("3.0.0")