From ea9d5b0962978fe09d9b08f5729e4881a61726ff Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 16 Apr 2024 09:02:59 +0100 Subject: [PATCH] Changes for OSX + C++20 + STL compatibility --- include/etl/private/variant_variadic.h | 2 +- test/UnitTest++/Checks.h | 25 ++++++++++++++++++++----- test/test_variant_variadic.cpp | 2 +- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/include/etl/private/variant_variadic.h b/include/etl/private/variant_variadic.h index 97f8ce88d..d1543f701 100644 --- a/include/etl/private/variant_variadic.h +++ b/include/etl/private/variant_variadic.h @@ -2010,7 +2010,7 @@ namespace etl /// Only defined if using C++20 and STL. /// https://en.cppreference.com/w/cpp/utility/variant/operator_cmp //*************************************************************************** -#if ETL_USING_CPP20 && ETL_USING_STL +#if ETL_USING_CPP20 && ETL_USING_STL && !(defined(ETL_DEVELOPMENT_OS_APPLE) && defined(ETL_COMPILER_CLANG)) template ETL_CONSTEXPR14 std::common_comparison_category_t...> diff --git a/test/UnitTest++/Checks.h b/test/UnitTest++/Checks.h index 88f1a1c30..501ab7ff5 100644 --- a/test/UnitTest++/Checks.h +++ b/test/UnitTest++/Checks.h @@ -34,7 +34,7 @@ namespace UnitTest template <> inline std::string DisplayValue(const char& c) { - using type = std::char_traits::int_type; + typedef std::char_traits::int_type type; std::ostringstream oss; @@ -47,7 +47,7 @@ namespace UnitTest template <> inline std::string DisplayValue(const char8_t& c) { - using type = std::char_traits::int_type; + typedef std::char_traits::int_type type; std::ostringstream oss; @@ -60,7 +60,7 @@ namespace UnitTest template <> inline std::string DisplayValue(const wchar_t& c) { - using type = std::char_traits::int_type; + typedef std::char_traits::int_type type; std::ostringstream oss; @@ -73,7 +73,7 @@ namespace UnitTest template <> inline std::string DisplayValue(const char16_t& c) { - using type = std::char_traits::int_type; + typedef std::char_traits::int_type type; std::ostringstream oss; @@ -85,7 +85,7 @@ namespace UnitTest template <> inline std::string DisplayValue(const char32_t& c) { - using type = std::char_traits::int_type; + typedef std::char_traits::int_type type; std::ostringstream oss; @@ -171,6 +171,7 @@ namespace UnitTest return !value; } +#if __cplusplus >= 201103L template< typename Expected, typename Actual > void CheckEqual(TestResults& results, Expected&& expected, Actual&& actual, TestDetails const& details) { @@ -183,6 +184,20 @@ namespace UnitTest results.OnTestFailure(details, stream.GetText()); } } +#else + template< typename Expected, typename Actual > + void CheckEqual(TestResults& results, Expected const& expected, Actual const& actual, TestDetails const& details) + { + if (!(expected == actual)) + { + UnitTest::MemoryOutStream stream; + stream << "Expected " + << DisplayValue(expected) << " but was " << DisplayValue(actual); + + results.OnTestFailure(details, stream.GetText()); + } + } +#endif template< typename Expected, typename Actual > void CheckEqualHex(TestResults& results, Expected const& expected, Actual const& actual, TestDetails const& details) diff --git a/test/test_variant_variadic.cpp b/test/test_variant_variadic.cpp index 6a7f94696..a9a7331ee 100644 --- a/test/test_variant_variadic.cpp +++ b/test/test_variant_variadic.cpp @@ -2009,7 +2009,7 @@ namespace } #endif -#if ETL_USING_CPP20 && ETL_USING_STL +#if ETL_USING_CPP20 && ETL_USING_STL && !(defined(ETL_DEVELOPMENT_OS_APPLE) && defined(ETL_COMPILER_CLANG)) //************************************************************************* TEST(test_variant_spaceship_operator) {