From a0023aa9aa00631254017edfcc28822815fa321c Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 8 Jan 2022 12:25:18 +0000 Subject: [PATCH] Updated tests to support C++20 STL --- test/etl_profile.h | 7 ++++++- test/test_numeric.cpp | 7 +++++-- test/test_string_stream_u16.cpp | 2 +- test/test_string_stream_u32.cpp | 2 +- test/test_string_stream_wchar_t.cpp | 2 +- test/test_string_u16.cpp | 16 ++++++++++++++++ test/test_string_u16_external_buffer.cpp | 16 ++++++++++++++++ test/test_string_u32.cpp | 16 ++++++++++++++++ test/test_string_u32_external_buffer.cpp | 16 ++++++++++++++++ test/test_string_utilities_std_u16.cpp | 8 ++++++++ test/test_string_utilities_std_u32.cpp | 8 ++++++++ test/test_string_utilities_std_wchar_t.cpp | 8 ++++++++ test/test_string_utilities_u16.cpp | 8 ++++++++ test/test_string_utilities_u32.cpp | 8 ++++++++ test/test_string_utilities_wchar_t.cpp | 10 +++++++++- test/test_string_wchar_t.cpp | 17 ++++++++++++++++- test/test_string_wchar_t_external_buffer.cpp | 16 ++++++++++++++++ test/vs2019/etl.vcxproj | 2 +- 18 files changed, 160 insertions(+), 9 deletions(-) diff --git a/test/etl_profile.h b/test/etl_profile.h index 8cac498b..0f050628 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -73,7 +73,12 @@ SOFTWARE. #define ETL_POLYMORPHIC_VECTOR #define ETL_POLYMORPHIC_INDIRECT_VECTOR -#define ETL_CPP20_SUPPORTED 0 +#if defined(ETL_CPP20_ENABLED) + #define ETL_CPP20_SUPPORTED 1 +#else + #define ETL_CPP20_SUPPORTED 0 +#endif + //#define ETL_POLYMORPHIC_CONTAINERS diff --git a/test/test_numeric.cpp b/test/test_numeric.cpp index aa0760ab..86e0e9d5 100644 --- a/test/test_numeric.cpp +++ b/test/test_numeric.cpp @@ -37,6 +37,7 @@ SOFTWARE. #include #include #include +#include namespace { @@ -104,7 +105,8 @@ namespace //************************************************************************* TEST(test_midpoint_etl_random_access_iterator) { - etl::deque data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + std::array initial = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + etl::deque data(initial.begin(), initial.end()); etl::deque::iterator b = data.begin(); etl::deque::iterator e = data.end(); @@ -116,7 +118,8 @@ namespace //************************************************************************* TEST(test_midpoint_etl_bidirectional_iterator) { - etl::list data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + std::array initial = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + etl::list data(initial.begin(), initial.end()); etl::list::iterator b = data.begin(); etl::list::iterator e = data.end(); diff --git a/test/test_string_stream_u16.cpp b/test/test_string_stream_u16.cpp index cb548697..fbe60600 100644 --- a/test/test_string_stream_u16.cpp +++ b/test/test_string_stream_u16.cpp @@ -68,7 +68,7 @@ namespace etl { for (auto c : str) { - os << c; + os << uint16_t(c); } return os; diff --git a/test/test_string_stream_u32.cpp b/test/test_string_stream_u32.cpp index 58d174b7..451bb137 100644 --- a/test/test_string_stream_u32.cpp +++ b/test/test_string_stream_u32.cpp @@ -68,7 +68,7 @@ namespace etl { for (auto c : str) { - os << c; + os << uint32_t(c); } return os; diff --git a/test/test_string_stream_wchar_t.cpp b/test/test_string_stream_wchar_t.cpp index af69a80e..8ea2ce82 100644 --- a/test/test_string_stream_wchar_t.cpp +++ b/test/test_string_stream_wchar_t.cpp @@ -68,7 +68,7 @@ namespace etl { for (auto c : str) { - os << c; + os << uint16_t(c); } return os; diff --git a/test/test_string_u16.cpp b/test/test_string_u16.cpp index 34b96484..56a34464 100644 --- a/test/test_string_u16.cpp +++ b/test/test_string_u16.cpp @@ -46,6 +46,22 @@ namespace ((result1 > 0) && (result2 > 0)); } + //*********************************** + std::ostream& operator << (std::ostream& os, const etl::iu16string::value_type& c) + { + os << uint16_t(c); + + return os; + } + + //*********************************** + std::ostream& operator << (std::ostream& os, const etl::iu16string::value_type* c) + { + os << (void*)c; + + return os; + } + SUITE(test_string_char) { static const size_t SIZE = 11; diff --git a/test/test_string_u16_external_buffer.cpp b/test/test_string_u16_external_buffer.cpp index bbde373c..4d6e9b30 100644 --- a/test/test_string_u16_external_buffer.cpp +++ b/test/test_string_u16_external_buffer.cpp @@ -47,6 +47,22 @@ namespace ((result1 > 0) && (result2 > 0)); } + //*********************************** + std::ostream& operator << (std::ostream& os, const etl::iu16string::value_type& c) + { + os << uint16_t(c); + + return os; + } + + //*********************************** + std::ostream& operator << (std::ostream& os, const etl::iu16string::value_type* c) + { + os << (void*)c; + + return os; + } + SUITE(test_string_char) { static constexpr size_t SIZE = 11; diff --git a/test/test_string_u32.cpp b/test/test_string_u32.cpp index 3058afdb..ccbfac21 100644 --- a/test/test_string_u32.cpp +++ b/test/test_string_u32.cpp @@ -46,6 +46,22 @@ namespace ((result1 > 0) && (result2 > 0)); } + //*********************************** + std::ostream& operator << (std::ostream& os, const etl::iu32string::value_type& c) + { + os << uint32_t(c); + + return os; + } + + //*********************************** + std::ostream& operator << (std::ostream& os, const etl::iu32string::value_type* c) + { + os << (void*)c; + + return os; + } + SUITE(test_string_char) { static const size_t SIZE = 11; diff --git a/test/test_string_u32_external_buffer.cpp b/test/test_string_u32_external_buffer.cpp index d0592438..e7e8525e 100644 --- a/test/test_string_u32_external_buffer.cpp +++ b/test/test_string_u32_external_buffer.cpp @@ -47,6 +47,22 @@ namespace ((result1 > 0) && (result2 > 0)); } + //*********************************** + std::ostream& operator << (std::ostream& os, const etl::u32string_ext::value_type& c) + { + os << uint32_t(c); + + return os; + } + + //*********************************** + std::ostream& operator << (std::ostream& os, const etl::u32string_ext::value_type* c) + { + os << (void*)c; + + return os; + } + SUITE(test_string_char) { static constexpr size_t SIZE = 11; diff --git a/test/test_string_utilities_std_u16.cpp b/test/test_string_utilities_std_u16.cpp index 3c2d1d14..b57858f5 100644 --- a/test/test_string_utilities_std_u16.cpp +++ b/test/test_string_utilities_std_u16.cpp @@ -40,6 +40,14 @@ SOFTWARE. namespace { + //*********************************** + std::ostream& operator << (std::ostream& os, const std::wstring::value_type& c) + { + os << uint16_t(c); + + return os; + } + SUITE(test_string_utilities_std_u16) { using String = std::wstring; diff --git a/test/test_string_utilities_std_u32.cpp b/test/test_string_utilities_std_u32.cpp index b56ed472..1e0ee509 100644 --- a/test/test_string_utilities_std_u32.cpp +++ b/test/test_string_utilities_std_u32.cpp @@ -40,6 +40,14 @@ SOFTWARE. namespace { + //*********************************** + std::ostream& operator << (std::ostream& os, const std::u32string::value_type& c) + { + os << uint32_t(c); + + return os; + } + SUITE(test_string_utilities_std_u32) { using String = std::u32string; diff --git a/test/test_string_utilities_std_wchar_t.cpp b/test/test_string_utilities_std_wchar_t.cpp index 6ef1e6df..fcd17722 100644 --- a/test/test_string_utilities_std_wchar_t.cpp +++ b/test/test_string_utilities_std_wchar_t.cpp @@ -40,6 +40,14 @@ SOFTWARE. namespace { + //*********************************** + std::ostream& operator << (std::ostream& os, const std::wstring::value_type& c) + { + os << uint16_t(c); + + return os; + } + SUITE(test_string_utilities_std_wchar_t) { using String = std::wstring; diff --git a/test/test_string_utilities_u16.cpp b/test/test_string_utilities_u16.cpp index 9d26a3fa..1e3eecf2 100644 --- a/test/test_string_utilities_u16.cpp +++ b/test/test_string_utilities_u16.cpp @@ -38,6 +38,14 @@ SOFTWARE. namespace { + //*********************************** + std::ostream& operator << (std::ostream& os, const std::u16string::value_type& c) + { + os << uint16_t(c); + + return os; + } + SUITE(test_string_utilities_u16) { static const size_t SIZE = 50; diff --git a/test/test_string_utilities_u32.cpp b/test/test_string_utilities_u32.cpp index d71f543d..7e32498f 100644 --- a/test/test_string_utilities_u32.cpp +++ b/test/test_string_utilities_u32.cpp @@ -38,6 +38,14 @@ SOFTWARE. namespace { + //*********************************** + std::ostream& operator << (std::ostream& os, const etl::iu32string::value_type& c) + { + os << uint32_t(c); + + return os; + } + SUITE(test_string_utilities_u32) { static const size_t SIZE = 50; diff --git a/test/test_string_utilities_wchar_t.cpp b/test/test_string_utilities_wchar_t.cpp index c4a55833..39962da8 100644 --- a/test/test_string_utilities_wchar_t.cpp +++ b/test/test_string_utilities_wchar_t.cpp @@ -38,11 +38,19 @@ SOFTWARE. namespace { + //*********************************** + std::ostream& operator << (std::ostream& os, const std::wstring::value_type& c) + { + os << uint16_t(c); + + return os; + } + SUITE(test_string_utilities_wchar_t) { static const size_t SIZE = 50; - using String = etl::wstring; + using String = etl::wstring; using IString = etl::iwstring; using StringView = etl::wstring_view; using Char = etl::iwstring::value_type; diff --git a/test/test_string_wchar_t.cpp b/test/test_string_wchar_t.cpp index 77af504c..394173d5 100644 --- a/test/test_string_wchar_t.cpp +++ b/test/test_string_wchar_t.cpp @@ -46,6 +46,22 @@ namespace ((result1 > 0) && (result2 > 0)); } + //*********************************** + std::ostream& operator << (std::ostream& os, const etl::iwstring::value_type& c) + { + os << uint16_t(c); + + return os; + } + + //*********************************** + std::ostream& operator << (std::ostream& os, const etl::iwstring::value_type* c) + { + os << (void*)c; + + return os; + } + SUITE(test_string_wchar_t) { static const size_t SIZE = 11; @@ -581,7 +597,6 @@ namespace CHECK_EQUAL(&constText[0], constText.begin()); } - //************************************************************************* TEST_FIXTURE(SetupFixture, test_end) { diff --git a/test/test_string_wchar_t_external_buffer.cpp b/test/test_string_wchar_t_external_buffer.cpp index d8ebde05..2aa20394 100644 --- a/test/test_string_wchar_t_external_buffer.cpp +++ b/test/test_string_wchar_t_external_buffer.cpp @@ -47,6 +47,22 @@ namespace ((result1 > 0) && (result2 > 0)); } + //*********************************** + std::ostream& operator << (std::ostream& os, const etl::iwstring::value_type& c) + { + os << uint16_t(c); + + return os; + } + + //*********************************** + std::ostream& operator << (std::ostream& os, const etl::iwstring::value_type* c) + { + os << (void*)c; + + return os; + } + SUITE(test_string_char) { static constexpr size_t SIZE = 11; diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 666be5f3..e19e5ae9 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -810,7 +810,7 @@ Level3 Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_CPP20_ENABLED;%(PreprocessorDefinitions) ../../../unittest-cpp/;../../include;../../test