From e6a58db0409b46de7d3ea32b777543b59b65171b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 13 Jan 2020 16:31:28 +0200 Subject: [PATCH 1/9] Fix broken manifest (#187) --- library.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.json b/library.json index 689d3608..606d9945 100644 --- a/library.json +++ b/library.json @@ -3,7 +3,7 @@ "version": "16.0.0", "authors": { "name": "John Wellbelove", - "email": "" + "email": "john.wellbelove@etlcpp.com" }, "homepage": "https://www.etlcpp.com/", "license": "MIT", From af5a760d5d507d0df47907857401b32450db818d Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 14 Jan 2020 11:57:04 +0000 Subject: [PATCH 2/9] Merge remote-tracking branch 'origin/development' --- include/etl/basic_string.h | 94 +++++++++++++++++++++ include/etl/cstring.h | 4 + include/etl/error_handler.h | 28 +++---- include/etl/intrusive_forward_list.h | 2 +- include/etl/u16string.h | 4 + include/etl/u32string.h | 4 + include/etl/utility.h | 2 +- include/etl/version.h | 2 +- include/etl/wstring.h | 4 + library.json | 2 +- library.properties | 2 +- support/Release notes.txt | 5 ++ test/CMakeLists.txt | 8 -- test/test_error_handler.cpp | 32 +------ test/test_make_string.cpp | 7 ++ test/test_vector_non_trivial.cpp | 5 +- test/vs2017/etl.sln | 78 +++++++++-------- test/vs2017/etl.vcxproj | 121 ++++++++++++++++++++++++--- 18 files changed, 300 insertions(+), 104 deletions(-) diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index 0e5c56e8..bb0ae39a 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -125,6 +125,20 @@ namespace etl } }; + //*************************************************************************** + ///\ingroup string + /// String truncation exception. +//*************************************************************************** + class string_truncation : public etl::string_exception + { + public: + + string_truncation(string_type file_name_, numeric_type line_number_) + : string_exception(ETL_ERROR_TEXT("string:iterator", ETL_FILE"D"), file_name_, line_number_) + { + } + }; + //*************************************************************************** ///\ingroup string /// The base class for all templated string types. @@ -415,6 +429,10 @@ namespace etl if (new_size > CAPACITY) { is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif } new_size = etl::min(new_size, CAPACITY); @@ -540,6 +558,10 @@ namespace etl if (other.truncated()) { is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif } cleanup(); @@ -580,6 +602,10 @@ namespace etl is_truncated = (*other != 0); +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ASSERT(is_truncated == false, ETL_ERROR(string_truncation)) +#endif + p_buffer[current_size] = 0; } @@ -595,6 +621,10 @@ namespace etl is_truncated = (length_ > CAPACITY); +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ASSERT(is_truncated == false, ETL_ERROR(string_truncation)) +#endif + length_ = etl::min(length_, CAPACITY); etl::copy_n(other, length_, begin()); @@ -628,6 +658,10 @@ namespace etl p_buffer[current_size] = 0; is_truncated = (first != last); + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ASSERT(is_truncated == false, ETL_ERROR(string_truncation)) +#endif } //********************************************************************* @@ -642,6 +676,10 @@ namespace etl is_truncated = (n > CAPACITY); +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ASSERT(is_truncated == false, ETL_ERROR(string_truncation)) +#endif + n = etl::min(n, CAPACITY); etl::fill_n(begin(), n, value); @@ -672,6 +710,10 @@ namespace etl else { is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif } } @@ -698,6 +740,10 @@ namespace etl if (str.truncated()) { is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif } return *this; @@ -800,6 +846,10 @@ namespace etl } is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif } p_buffer[current_size] = 0; @@ -828,6 +878,10 @@ namespace etl if (start >= CAPACITY) { is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif return; } @@ -837,6 +891,10 @@ namespace etl if ((current_size + n) > CAPACITY) { is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif } current_size = CAPACITY; @@ -856,6 +914,10 @@ namespace etl { current_size = CAPACITY; is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif } else { @@ -891,6 +953,10 @@ namespace etl if (start >= CAPACITY) { is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif return; } @@ -900,6 +966,10 @@ namespace etl if (((current_size + n) > CAPACITY)) { is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif } current_size = CAPACITY; @@ -923,6 +993,10 @@ namespace etl { current_size = CAPACITY; is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif } else { @@ -954,6 +1028,10 @@ namespace etl if (str.truncated()) { is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif } return *this; @@ -981,6 +1059,10 @@ namespace etl if (str.truncated()) { is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif } return *this; @@ -1095,6 +1177,10 @@ namespace etl if ((pos + len > size())) { is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif } size_t endpos = etl::min(pos + len, size()); @@ -1373,6 +1459,10 @@ namespace etl if (str.truncated()) { is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif } return *this; @@ -1399,6 +1489,10 @@ namespace etl if (str.truncated()) { is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif } return *this; diff --git a/include/etl/cstring.h b/include/etl/cstring.h index 9dee9685..8036485c 100644 --- a/include/etl/cstring.h +++ b/include/etl/cstring.h @@ -108,6 +108,10 @@ namespace etl if (other.truncated()) { this->is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif } } diff --git a/include/etl/error_handler.h b/include/etl/error_handler.h index a0fc5e0f..6d7b9a61 100644 --- a/include/etl/error_handler.h +++ b/include/etl/error_handler.h @@ -121,32 +121,32 @@ namespace etl ///\ingroup error_handler //*************************************************************************** #if defined(ETL_NO_CHECKS) - #define ETL_ASSERT(b, e) // Does nothing. - #define ETL_ALWAYS_ASSERT(e) // Does nothing. + #define ETL_ASSERT(b, e) // Does nothing. + #define ETL_ALWAYS_ASSERT(e) // Does nothing. #elif defined(ETL_THROW_EXCEPTIONS) #if defined(ETL_LOG_ERRORS) - #define ETL_ASSERT(b, e) {if (!(b)) {etl::error_handler::error((e)); throw((e));}} // If the condition fails, calls the error handler then throws an exception. - #define ETL_ALWAYS_ASSERT(e) {etl::error_handler::error((e)); throw((e));} // Calls the error handler then throws an exception. + #define ETL_ASSERT(b, e) {if (!(b)) {etl::error_handler::error((e)); throw((e));}} // If the condition fails, calls the error handler then throws an exception. + #define ETL_ALWAYS_ASSERT(e) {etl::error_handler::error((e)); throw((e));} // Calls the error handler then throws an exception. #else - #define ETL_ASSERT(b, e) {if (!(b)) {throw((e));}} // If the condition fails, throws an exception. - #define ETL_ALWAYS_ASSERT(e) {throw((e));} // Throws an exception. + #define ETL_ASSERT(b, e) {if (!(b)) {throw((e));}} // If the condition fails, throws an exception. + #define ETL_ALWAYS_ASSERT(e) {throw((e));} // Throws an exception. #endif #else #if defined(ETL_LOG_ERRORS) #if defined(NDEBUG) - #define ETL_ASSERT(b, e) {if(!(b)) {etl::error_handler::error((e));}} // If the condition fails, calls the error handler - #define ETL_ALWAYS_ASSERT(e) {etl::error_handler::error((e));} // Calls the error handler + #define ETL_ASSERT(b, e) {if(!(b)) {etl::error_handler::error((e));}} // If the condition fails, calls the error handler + #define ETL_ALWAYS_ASSERT(e) {etl::error_handler::error((e));} // Calls the error handler #else - #define ETL_ASSERT(b, e) {if(!(b)) {etl::error_handler::error((e)); assert((b));}} // If the condition fails, calls the error handler then asserts. - #define ETL_ALWAYS_ASSERT(e) {etl::error_handler::error((e)); assert(true);} // Calls the error handler then asserts. + #define ETL_ASSERT(b, e) {if(!(b)) {etl::error_handler::error((e)); assert(false);}} // If the condition fails, calls the error handler then asserts. + #define ETL_ALWAYS_ASSERT(e) {etl::error_handler::error((e)); assert(false);} // Calls the error handler then asserts. #endif #else #if defined(NDEBUG) - #define ETL_ASSERT(b, e) // Does nothing. - #define ETL_ALWAYS_ASSERT(e) // Does nothing. + #define ETL_ASSERT(b, e) // Does nothing. + #define ETL_ALWAYS_ASSERT(e) // Does nothing. #else - #define ETL_ASSERT(b, e) assert((b)) // If the condition fails, asserts. - #define ETL_ALWAYS_ASSERT(e) assert(true) // Asserts. + #define ETL_ASSERT(b, e) assert((b)) // If the condition fails, asserts. + #define ETL_ALWAYS_ASSERT(e) assert(false) // Asserts. #endif #endif #endif diff --git a/include/etl/intrusive_forward_list.h b/include/etl/intrusive_forward_list.h index 48ed3972..33836cc4 100644 --- a/include/etl/intrusive_forward_list.h +++ b/include/etl/intrusive_forward_list.h @@ -935,7 +935,7 @@ namespace etl //************************************************************************* /// Splice an element from another list into this one. //************************************************************************* - void splice(iterator position, etl::intrusive_forward_list& other, iterator isource) + void splice_after(iterator position, etl::intrusive_forward_list& other, iterator isource) { link_type& before = *position.p_value; diff --git a/include/etl/u16string.h b/include/etl/u16string.h index 377d29e8..51d3b48a 100644 --- a/include/etl/u16string.h +++ b/include/etl/u16string.h @@ -108,6 +108,10 @@ namespace etl if (other.truncated()) { this->is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif } } diff --git a/include/etl/u32string.h b/include/etl/u32string.h index ee4ebabd..97d167b4 100644 --- a/include/etl/u32string.h +++ b/include/etl/u32string.h @@ -108,6 +108,10 @@ namespace etl if (other.truncated()) { this->is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif } } diff --git a/include/etl/utility.h b/include/etl/utility.h index 5f600f2f..b08ac571 100644 --- a/include/etl/utility.h +++ b/include/etl/utility.h @@ -163,7 +163,7 @@ namespace etl } #endif -#if defined(ETL_NO_STL) +#if defined(ETL_NO_STL) || !ETL_CPP14_SUPPORTED //*************************************************************************** /// exchange (const) //*************************************************************************** diff --git a/include/etl/version.h b/include/etl/version.h index 44270f57..c8ea0c5d 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -38,7 +38,7 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 16 -#define ETL_VERSION_MINOR 0 +#define ETL_VERSION_MINOR 1 #define ETL_VERSION_PATCH 0 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH) diff --git a/include/etl/wstring.h b/include/etl/wstring.h index 7447d962..1b45bc5d 100644 --- a/include/etl/wstring.h +++ b/include/etl/wstring.h @@ -109,6 +109,10 @@ namespace etl if (other.truncated()) { this->is_truncated = true; + +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); +#endif } } diff --git a/library.json b/library.json index 606d9945..ee63d96e 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "16.0.0", + "version": "16.1.0", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 13083571..936ca6dd 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=16.0.0 +version=16.1.0 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index 81833538..fccb353d 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,8 @@ +=============================================================================== +16.1.0 +Added compile time option to make string truncation an error. +Define ETL_STRING_TRUNCATION_IS_ERROR to enable. + =============================================================================== 16.0.0 Refactored the ETL's relationship with the STL diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0aaac6e9..f39460e6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,7 +3,6 @@ project(etl_unit_tests) add_definitions(-DETL_DEBUG) - if(NOT UnitTest++_FOUND) # Add unittest-cpp as an ExternalProject include(cmake/unit-test_external_project.cmake) @@ -117,11 +116,6 @@ set(TEST_SOURCE_FILES test_forward_list_shared_pool.cpp test_list_shared_pool.cpp test_multi_array.cpp - test_no_stl_algorithm.cpp - test_no_stl_functional.cpp - test_no_stl_iterator.cpp - test_no_stl_limits.cpp - test_no_stl_utility.cpp test_queue_memory_model_small.cpp test_queue_mpmc_mutex.cpp test_queue_mpmc_mutex_small.cpp @@ -143,8 +137,6 @@ set(TEST_SOURCE_FILES test_vector_pointer_external_buffer.cpp ) - - if (WIN32) # test_error_handler.cpp uses windows APIs that assume the microsoft project # is setup for unicode support. Note: This may have adverse effects on client diff --git a/test/test_error_handler.cpp b/test/test_error_handler.cpp index 17bff6a0..ec05fd48 100644 --- a/test/test_error_handler.cpp +++ b/test/test_error_handler.cpp @@ -27,11 +27,9 @@ SOFTWARE. ******************************************************************************/ #include "UnitTest++/UnitTest++.h" - #if defined(_WINDOWS) -#include -#endif -#include +#include #include +#include #include "etl/error_handler.h" #include "etl/exception.h" @@ -58,18 +56,7 @@ public: void receive_error(const etl::exception& e) { error_received = true; - std::ostringstream oss; - oss << "Error '" << e.what() << "' in " << e.file_name() << " at line " << e.line_number() << "\n"; - -#if defined(_WINDOWS) && defined(ETL_COMPILER_MICROSOFT) - std::string stext = oss.str(); - - WCHAR text[200]; - MultiByteToWideChar(0, 0, stext.c_str(), stext.size() + 1, text, 200); - LPCWSTR ltext = text; - - OutputDebugString(ltext); -#endif + CHECK(strcmp(e.what(), "test_exception") == 0); } //***************************************************************************** @@ -83,18 +70,7 @@ public: void receive_error(const etl::exception& e) { error_received = true; - std::ostringstream oss; - oss << "Error '" << e.what() << "' in " << e.file_name() << " at line " << e.line_number() << "\n"; - -#if defined(_WINDOWS) && defined(ETL_COMPILER_MICROSOFT) - std::string stext = oss.str(); - - WCHAR text[200]; - MultiByteToWideChar(0, 0, stext.c_str(), stext.size() + 1, text, 200); - LPCWSTR ltext = text; - - OutputDebugString(ltext); -#endif + CHECK(strcmp(e.what(), "test_exception") == 0); } }; diff --git a/test/test_make_string.cpp b/test/test_make_string.cpp index c7759325..5d6035e1 100644 --- a/test/test_make_string.cpp +++ b/test/test_make_string.cpp @@ -113,6 +113,12 @@ namespace constexpr size_t CAPACITY = 10; size_t length = strlen("Hello World"); +#if defined(ETL_STRING_TRUNCATION_IS_ERROR) + CHECK_THROW(auto ctext = etl::make_string_with_capacity("Hello World"), etl::string_truncation); + CHECK_THROW(auto wtext = etl::make_string_with_capacity(L"Hello World"), etl::string_truncation);; + CHECK_THROW(auto u16text = etl::make_string_with_capacity(u"Hello World"), etl::string_truncation);; + CHECK_THROW(auto u32text = etl::make_string_with_capacity(U"Hello World"), etl::string_truncation);; +#else auto ctext = etl::make_string_with_capacity("Hello World"); auto wtext = etl::make_string_with_capacity(L"Hello World"); auto u16text = etl::make_string_with_capacity(u"Hello World"); @@ -138,6 +144,7 @@ namespace CHECK(Equal(std::wstring(L"Hello Worl"), ctext)); CHECK(Equal(std::u16string(u"Hello Worl"), ctext)); CHECK(Equal(std::u32string(U"Hello Worl"), ctext)); +#endif } }; } diff --git a/test/test_vector_non_trivial.cpp b/test/test_vector_non_trivial.cpp index bab37793..f1c71fb4 100644 --- a/test/test_vector_non_trivial.cpp +++ b/test/test_vector_non_trivial.cpp @@ -756,7 +756,10 @@ namespace Data(std::string w, size_t x, double y, const char *z) : a(w), b(x), c(y), d(z){} bool operator == (const Data &other) const { - return (a == other.a) && (b == other.b) && (c == other.c) && (d == other.d); + return (a == other.a) && + (b == other.b) && + (c == other.c) && + (((d == nullptr) && (other.d == nullptr)) || (strcmp(d, other.d) == 0)); } }; diff --git a/test/vs2017/etl.sln b/test/vs2017/etl.sln index b6464410..c4438e18 100644 --- a/test/vs2017/etl.sln +++ b/test/vs2017/etl.sln @@ -7,52 +7,58 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "etl", "etl.vcxproj", "{C21D EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug 64|Win32 = Debug 64|Win32 - Debug 64|x64 = Debug 64|x64 - Debug LLVM No STL|Win32 = Debug LLVM No STL|Win32 - Debug LLVM No STL|x64 = Debug LLVM No STL|x64 + Debug LLVM - No STL|Win32 = Debug LLVM - No STL|Win32 + Debug LLVM - No STL|x64 = Debug LLVM - No STL|x64 Debug LLVM|Win32 = Debug LLVM|Win32 Debug LLVM|x64 = Debug LLVM|x64 - Debug No STL - Force No Advanced|Win32 = Debug No STL - Force No Advanced|Win32 - Debug No STL - Force No Advanced|x64 = Debug No STL - Force No Advanced|x64 - Debug No STL|Win32 = Debug No STL|Win32 - Debug No STL|x64 = Debug No STL|x64 - Debug No Unit Tests|Win32 = Debug No Unit Tests|Win32 - Debug No Unit Tests|x64 = Debug No Unit Tests|x64 - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 + Debug MSVC - No STL - Force No Advanced|Win32 = Debug MSVC - No STL - Force No Advanced|Win32 + Debug MSVC - No STL - Force No Advanced|x64 = Debug MSVC - No STL - Force No Advanced|x64 + Debug MSVC - No STL|Win32 = Debug MSVC - No STL|Win32 + Debug MSVC - No STL|x64 = Debug MSVC - No STL|x64 + Debug MSVC - No Unit Tests|Win32 = Debug MSVC - No Unit Tests|Win32 + Debug MSVC - No Unit Tests|x64 = Debug MSVC - No Unit Tests|x64 + Debug MSVC - String Truncation Is Error|Win32 = Debug MSVC - String Truncation Is Error|Win32 + Debug MSVC - String Truncation Is Error|x64 = Debug MSVC - String Truncation Is Error|x64 + Debug MSVC 64|Win32 = Debug MSVC 64|Win32 + Debug MSVC 64|x64 = Debug MSVC 64|x64 + Debug MSVC|Win32 = Debug MSVC|Win32 + Debug MSVC|x64 = Debug MSVC|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug 64|Win32.ActiveCfg = Debug No Unit Tests|Win32 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug 64|Win32.Build.0 = Debug No Unit Tests|Win32 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug 64|x64.ActiveCfg = Debug64|x64 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug 64|x64.Build.0 = Debug64|x64 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM No STL|Win32.ActiveCfg = DebugLLVMNoSTL|Win32 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM No STL|Win32.Build.0 = DebugLLVMNoSTL|Win32 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM No STL|x64.ActiveCfg = DebugLLVMNoSTL|x64 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM No STL|x64.Build.0 = DebugLLVMNoSTL|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL|Win32.ActiveCfg = DebugLLVMNoSTL|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL|Win32.Build.0 = DebugLLVMNoSTL|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL|x64.ActiveCfg = DebugLLVMNoSTL|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL|x64.Build.0 = DebugLLVMNoSTL|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM|Win32.ActiveCfg = Debug LLVM|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM|Win32.Build.0 = Debug LLVM|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM|x64.ActiveCfg = Debug LLVM|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM|x64.Build.0 = Debug LLVM|x64 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug No STL - Force No Advanced|Win32.ActiveCfg = DebugNoSTLForceNoAdvanced|Win32 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug No STL - Force No Advanced|Win32.Build.0 = DebugNoSTLForceNoAdvanced|Win32 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug No STL - Force No Advanced|x64.ActiveCfg = DebugNoSTLForceNoAdvanced|x64 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug No STL - Force No Advanced|x64.Build.0 = DebugNoSTLForceNoAdvanced|x64 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug No STL|Win32.ActiveCfg = DebugNoSTL|Win32 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug No STL|Win32.Build.0 = DebugNoSTL|Win32 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug No STL|x64.ActiveCfg = DebugNoSTL|x64 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug No STL|x64.Build.0 = DebugNoSTL|x64 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug No Unit Tests|Win32.ActiveCfg = Debug No Unit Tests|Win32 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug No Unit Tests|Win32.Build.0 = Debug No Unit Tests|Win32 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug No Unit Tests|x64.ActiveCfg = Debug No Unit Tests|x64 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug No Unit Tests|x64.Build.0 = Debug No Unit Tests|x64 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug|Win32.ActiveCfg = Debug|Win32 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug|Win32.Build.0 = Debug|Win32 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug|x64.ActiveCfg = Debug|x64 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug|x64.Build.0 = Debug|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Force No Advanced|Win32.ActiveCfg = DebugNoSTLForceNoAdvanced|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Force No Advanced|Win32.Build.0 = DebugNoSTLForceNoAdvanced|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Force No Advanced|x64.ActiveCfg = DebugNoSTLForceNoAdvanced|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Force No Advanced|x64.Build.0 = DebugNoSTLForceNoAdvanced|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL|Win32.ActiveCfg = DebugNoSTL|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL|Win32.Build.0 = DebugNoSTL|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL|x64.ActiveCfg = DebugNoSTL|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL|x64.Build.0 = DebugNoSTL|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No Unit Tests|Win32.ActiveCfg = Debug No Unit Tests|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No Unit Tests|Win32.Build.0 = Debug No Unit Tests|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No Unit Tests|x64.ActiveCfg = Debug No Unit Tests|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No Unit Tests|x64.Build.0 = Debug No Unit Tests|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - String Truncation Is Error|Win32.ActiveCfg = DebugStringTruncationIsError|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - String Truncation Is Error|Win32.Build.0 = DebugStringTruncationIsError|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - String Truncation Is Error|x64.ActiveCfg = DebugStringTruncationIsError|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - String Truncation Is Error|x64.Build.0 = DebugStringTruncationIsError|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC 64|Win32.ActiveCfg = Debug No Unit Tests|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC 64|Win32.Build.0 = Debug No Unit Tests|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC 64|x64.ActiveCfg = Debug64|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC 64|x64.Build.0 = Debug64|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC|Win32.ActiveCfg = Debug|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC|Win32.Build.0 = Debug|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC|x64.ActiveCfg = Debug|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC|x64.Build.0 = Debug|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Release|Win32.ActiveCfg = Release|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Release|Win32.Build.0 = Release|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Release|x64.ActiveCfg = Release|x64 diff --git a/test/vs2017/etl.vcxproj b/test/vs2017/etl.vcxproj index 3ac49ba6..88221eac 100644 --- a/test/vs2017/etl.vcxproj +++ b/test/vs2017/etl.vcxproj @@ -57,6 +57,14 @@ DebugNoSTL x64 + + DebugStringTruncationIsError + Win32 + + + DebugStringTruncationIsError + x64 + Debug Win32 @@ -88,6 +96,12 @@ v141 Unicode + + Application + true + v141 + Unicode + Application true @@ -124,6 +138,12 @@ v141 Unicode + + Application + true + v141 + Unicode + Application true @@ -198,6 +218,9 @@ + + + @@ -216,6 +239,9 @@ + + + @@ -255,6 +281,11 @@ true \$(IntDir) + + true + true + \$(IntDir) + true true @@ -284,6 +315,10 @@ true true + + true + true + true true @@ -350,6 +385,27 @@ $(OutDir)\etl.exe + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_STRING_TRUNCATION_IS_ERROR;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../test + + + false + stdcpp17 + + + Console + true + + + $(OutDir)\etl.exe + + @@ -357,7 +413,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING;ETL_NO_STL;%(PreprocessorDefinitions) - ../../../unittest-cpp/;../../include;../../include/etl/c;../../test + ./;../../../unittest-cpp/;../../include;../../test false @@ -423,7 +479,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_NO_STL;__clang__;%(PreprocessorDefinitions) - ../../../unittest-cpp/;../../include;../../include/etl/c;../../test + ../../../unittest-cpp/;../../include;../../test false @@ -447,7 +503,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ../../../unittest-cpp/UnitTest++/;../../include;../../include/etl/c;../../test + ../../../unittest-cpp/UnitTest++/;../../include;../../test false @@ -495,7 +551,28 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ../../unittest-cpp/UnitTest++/;../../include/etl;../../include/etl/c;../../test + ../../unittest-cpp/UnitTest++/;../../include/etl;../../test + + + false + stdcpp14 + + + Console + true + + + $(OutDir)\etl.exe + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../unittest-cpp/UnitTest++/;../../include/etl;../../test false @@ -516,7 +593,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ../../unittest-cpp/UnitTest++/;../../include/etl;../../include/etl/c;../../test + ../../unittest-cpp/UnitTest++/;../../include/etl;../../test false @@ -537,7 +614,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ../../unittest-cpp/UnitTest++/;../../include/etl;../../include/etl/c;../../test + ../../unittest-cpp/UnitTest++/;../../include/etl;../../test false @@ -558,7 +635,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ../../unittest-cpp/UnitTest++/;../../include/etl;../../include/etl/c;../../test + ../../unittest-cpp/UnitTest++/;../../include/etl;../../test false @@ -579,7 +656,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ../../unittest-cpp/UnitTest++/;../../include/etl;../../include/etl/c;../../test + ../../unittest-cpp/UnitTest++/;../../include/etl;../../test false @@ -600,7 +677,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ../../unittest-cpp/UnitTest++/;../../include/etl;../../include/etl/c;../../test + ../../unittest-cpp/UnitTest++/;../../include/etl;../../test false @@ -621,7 +698,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ../../../unittest-cpp/;../../include;../../include/etl/c;../../test + ../../../unittest-cpp/;../../include;../../test false @@ -642,7 +719,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ../../unittest-cpp/UnitTest++/;../../include/etl;../../include/etl/c;../../test + ../../unittest-cpp/UnitTest++/;../../include/etl;../../test false @@ -663,7 +740,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ../../../unittest-cpp/;../../include;../../include/etl/c;../../test + ../../../unittest-cpp/;../../include;../../test stdcpp17 @@ -1054,6 +1131,7 @@ false false false + false false false false @@ -1061,6 +1139,7 @@ false false false + false false false false @@ -1087,6 +1166,7 @@ false + false false false false @@ -1094,6 +1174,7 @@ false false false + false false false false @@ -1115,6 +1196,7 @@ false + false false false false @@ -1122,6 +1204,7 @@ false false false + false false false false @@ -1133,6 +1216,7 @@ false + false false false false @@ -1140,6 +1224,7 @@ false false false + false false false false @@ -1151,6 +1236,7 @@ false + false false false false @@ -1158,6 +1244,7 @@ false false false + false false false false @@ -1169,6 +1256,7 @@ false + false false false false @@ -1176,6 +1264,7 @@ false false false + false false false false @@ -1187,6 +1276,7 @@ false + false false false false @@ -1194,6 +1284,7 @@ false false false + false false false false @@ -1210,6 +1301,7 @@ false + false false false false @@ -1217,6 +1309,7 @@ false false false + false false false false @@ -1232,6 +1325,7 @@ true true false + false false false false @@ -1239,6 +1333,7 @@ false false false + false false false false @@ -1259,6 +1354,7 @@ false + false false false false @@ -1266,6 +1362,7 @@ false false false + false false false false From 8a99a2725c32fc5a710f60ee1a041e002b41fe5f Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 14 Jan 2020 12:46:17 +0000 Subject: [PATCH 3/9] Merge remote-tracking branch 'origin/development' # Conflicts: # include/etl/version.h # library.json # library.properties # support/Release notes.txt --- include/etl/algorithm.h | 37 +++++++++++++++++++++++++++++++++++++ include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- support/Release notes.txt | 4 ++++ test/test_algorithm.cpp | 30 ++++++++++++++++++++++++++++++ 6 files changed, 74 insertions(+), 3 deletions(-) diff --git a/include/etl/algorithm.h b/include/etl/algorithm.h index 39ea178f..1cd8e4f7 100644 --- a/include/etl/algorithm.h +++ b/include/etl/algorithm.h @@ -2938,6 +2938,43 @@ namespace etl etl::insertion_sort(first, last, etl::less::value_type>()); } + //*************************************************************************** + /// Sorts the elements using heap sort. + /// Uses user defined comparison. + ///\ingroup algorithm + //*************************************************************************** + template + void heap_sort(TIterator first, TIterator last, TCompare compare) + { + if (!etl::is_heap(first, last, compare)) + { + etl::make_heap(first, last, compare); + } + + while (first != last) + { + etl::pop_heap(first, last--, compare); + } + } + + //*************************************************************************** + /// Sorts the elements using heap sort. + ///\ingroup algorithm + //*************************************************************************** + template + void heap_sort(TIterator first, TIterator last) + { + if (!etl::is_heap(first, last)) + { + etl::make_heap(first, last); + } + + while (first != last) + { + etl::pop_heap(first, last--); + } + } + //*************************************************************************** /// Returns the maximum value. //*************************************************************************** diff --git a/include/etl/version.h b/include/etl/version.h index c8ea0c5d..78e56a81 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -38,7 +38,7 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 16 -#define ETL_VERSION_MINOR 1 +#define ETL_VERSION_MINOR 2 #define ETL_VERSION_PATCH 0 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index ee63d96e..c70a67fb 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "16.1.0", + "version": "16.2.0", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 936ca6dd..6f7b71d9 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=16.1.0 +version=16.2.0 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index fccb353d..bbaa2485 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +16.2.0 +Added etl::heap_sort to algorithms. + =============================================================================== 16.1.0 Added compile time option to make string truncation an error. diff --git a/test/test_algorithm.cpp b/test/test_algorithm.cpp index e5238719..d0b56114 100644 --- a/test/test_algorithm.cpp +++ b/test/test_algorithm.cpp @@ -1856,6 +1856,36 @@ namespace CHECK(is_same); } + //************************************************************************* + TEST(heap_sort_default) + { + std::vector initial_data = { NDC(1, 1), NDC(2, 1), NDC(3, 1), NDC(2, 2), NDC(3, 2), NDC(4, 1), NDC(2, 3), NDC(3, 3), NDC(5, 1) }; + + std::vector data1(initial_data); + std::vector data2(initial_data); + + std::sort(data1.begin(), data1.end()); + etl::heap_sort(data2.begin(), data2.end()); + + bool is_same = std::equal(data1.begin(), data1.end(), data2.begin()); + CHECK(is_same); + } + + //************************************************************************* + TEST(heap_sort_greater) + { + std::vector initial_data = { NDC(1, 1), NDC(2, 1), NDC(3, 1), NDC(2, 2), NDC(3, 2), NDC(4, 1), NDC(2, 3), NDC(3, 3), NDC(5, 1) }; + + std::vector data1(initial_data); + std::vector data2(initial_data); + + std::sort(data1.begin(), data1.end(), std::greater()); + etl::heap_sort(data2.begin(), data2.end(), std::greater()); + + bool is_same = std::equal(data1.begin(), data1.end(), data2.begin()); + CHECK(is_same); + } + //************************************************************************* TEST(multimax) { From 282655259fd427b025f2b7e544e82d5ec6a0fdf2 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 14 Jan 2020 17:54:56 +0000 Subject: [PATCH 4/9] Merge remote-tracking branch 'origin/development' # Conflicts: # include/etl/version.h # library.json # library.properties # support/Release notes.txt --- examples/QueuedMessageRouter/QueuedMessageRouter.cpp | 4 ++-- .../QueuedMessageRouter/vs2017/QueuedMessageRouter.vcxproj | 5 +++-- examples/QueuedMessageRouter/vs2017/etl_profile.h | 5 ++--- include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- support/Release notes.txt | 4 ++++ 7 files changed, 14 insertions(+), 10 deletions(-) diff --git a/examples/QueuedMessageRouter/QueuedMessageRouter.cpp b/examples/QueuedMessageRouter/QueuedMessageRouter.cpp index c66d389e..f635709e 100644 --- a/examples/QueuedMessageRouter/QueuedMessageRouter.cpp +++ b/examples/QueuedMessageRouter/QueuedMessageRouter.cpp @@ -1,6 +1,6 @@ -#include "queue.h" -#include "message_router.h" +#include "etl/queue.h" +#include "etl/message_router.h" #include #include diff --git a/examples/QueuedMessageRouter/vs2017/QueuedMessageRouter.vcxproj b/examples/QueuedMessageRouter/vs2017/QueuedMessageRouter.vcxproj index 98bf7e9e..b697a59e 100644 --- a/examples/QueuedMessageRouter/vs2017/QueuedMessageRouter.vcxproj +++ b/examples/QueuedMessageRouter/vs2017/QueuedMessageRouter.vcxproj @@ -23,7 +23,7 @@ {2BB47D48-5EFC-4C38-B2BE-002172F00E3B} Win32Proj QueuedMessageRouter - 10.0.15063.0 + 10.0.18362.0 @@ -102,8 +102,9 @@ Disabled _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ../../../src;../vs2017 + ../../../include;../vs2017 + stdcpp17 Console diff --git a/examples/QueuedMessageRouter/vs2017/etl_profile.h b/examples/QueuedMessageRouter/vs2017/etl_profile.h index a321fa85..c96719fd 100644 --- a/examples/QueuedMessageRouter/vs2017/etl_profile.h +++ b/examples/QueuedMessageRouter/vs2017/etl_profile.h @@ -37,12 +37,11 @@ SOFTWARE. #define ETL_ISTRING_REPAIR_ENABLE #define ETL_IVECTOR_REPAIR_ENABLE #define ETL_IDEQUE_REPAIR_ENABLE -#define ETL_IN_UNIT_TEST #ifdef _MSC_VER - #include "profiles/msvc_x86.h" + #include "etl/profiles/msvc_x86.h" #else - #include "profiles/gcc_windows_x86.h" + #include "etl/profiles/gcc_windows_x86.h" #endif #endif diff --git a/include/etl/version.h b/include/etl/version.h index 78e56a81..8edf7c07 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -39,7 +39,7 @@ SOFTWARE. #define ETL_VERSION_MAJOR 16 #define ETL_VERSION_MINOR 2 -#define ETL_VERSION_PATCH 0 +#define ETL_VERSION_PATCH 1 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index c70a67fb..35c1ffae 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "16.2.0", + "version": "16.2.1", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 6f7b71d9..bc9c071b 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=16.2.0 +version=16.2.1 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index bbaa2485..0d41df79 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +16.2.1 +Updated QueuedMessageHandler example + =============================================================================== 16.2.0 Added etl::heap_sort to algorithms. From a1a0391282a0a3f43df371a16dfc1af34145481d Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 15 Jan 2020 16:32:01 +0000 Subject: [PATCH 5/9] Merge remote-tracking branch 'origin/development' # Conflicts: # include/etl/version.h # library.json # library.properties # support/Release notes.txt --- include/etl/checksum.h | 53 ++++++++++++ include/etl/version.h | 4 +- library.json | 2 +- library.properties | 2 +- support/Release notes.txt | 4 + test/codeblocks/ETL.cbp | 1 + test/test_parity_checksum.cpp | 147 ++++++++++++++++++++++++++++++++ test/vs2017/etl.vcxproj | 1 + test/vs2017/etl.vcxproj.filters | 3 + 9 files changed, 213 insertions(+), 4 deletions(-) create mode 100644 test/test_parity_checksum.cpp diff --git a/include/etl/checksum.h b/include/etl/checksum.h index 38cf227d..db12acde 100644 --- a/include/etl/checksum.h +++ b/include/etl/checksum.h @@ -134,6 +134,30 @@ namespace etl } }; + //*************************************************************************** + /// Parity checksum policy. + //*************************************************************************** + template + struct checksum_policy_parity + { + typedef T value_type; + + inline T initial() const + { + return 0; + } + + inline T add(T sum, uint8_t value) const + { + return sum ^ etl::parity(value); + } + + inline T final(T sum) const + { + return sum; + } + }; + //************************************************************************* /// Standard Checksum. //************************************************************************* @@ -249,6 +273,35 @@ namespace etl this->add(begin, end); } }; + + //************************************************************************* + /// Parity Checksum. + //************************************************************************* + template + class parity_checksum : public etl::frame_check_sequence > + { + public: + + //************************************************************************* + /// Default constructor. + //************************************************************************* + parity_checksum() + { + this->reset(); + } + + //************************************************************************* + /// Constructor from range. + /// \param begin Start of the range. + /// \param end End of the range. + //************************************************************************* + template + parity_checksum(TIterator begin, const TIterator end) + { + this->reset(); + this->add(begin, end); + } + }; } #endif diff --git a/include/etl/version.h b/include/etl/version.h index 8edf7c07..51eac722 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -38,8 +38,8 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 16 -#define ETL_VERSION_MINOR 2 -#define ETL_VERSION_PATCH 1 +#define ETL_VERSION_MINOR 3 +#define ETL_VERSION_PATCH 0 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index 35c1ffae..f09a46ef 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "16.2.1", + "version": "16.3.0", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index bc9c071b..af92bfdc 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=16.2.1 +version=16.3.0 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index 0d41df79..b57a14ca 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +16.3.0 +Added parity checksum to checksum.h. + =============================================================================== 16.2.1 Updated QueuedMessageHandler example diff --git a/test/codeblocks/ETL.cbp b/test/codeblocks/ETL.cbp index e0014fc3..3a749d8e 100644 --- a/test/codeblocks/ETL.cbp +++ b/test/codeblocks/ETL.cbp @@ -512,6 +512,7 @@ + diff --git a/test/test_parity_checksum.cpp b/test/test_parity_checksum.cpp new file mode 100644 index 00000000..9f0cb495 --- /dev/null +++ b/test/test_parity_checksum.cpp @@ -0,0 +1,147 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +http://www.etlcpp.com + +Copyright(c) 2020 jwellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#include "UnitTest++/UnitTest++.h" + +#include +#include +#include +#include + +#include "etl/checksum.h" + +namespace +{ + template + int reference_checksum(TIterator begin, TIterator end) + { + T checksum = 0; + + while (begin != end) + { + checksum ^=etl::parity(*begin++); + } + + return checksum; + } + + SUITE(test_checksum) + { + //************************************************************************* + TEST(test_checksum_constructor) + { + std::string data("123456789"); + + uint8_t sum = etl::parity_checksum(data.begin(), data.end()); + uint8_t compare = reference_checksum(data.begin(), data.end()); + + CHECK_EQUAL(int(compare), int(sum)); + } + + //************************************************************************* + TEST(test_checksum_add_values8_add) + { + std::string data("123456789"); + + etl::parity_checksum checksum_calculator; + + for (size_t i = 0; i < data.size(); ++i) + { + checksum_calculator.add(data[i]); + } + + uint8_t sum = checksum_calculator; + uint8_t compare = reference_checksum(data.begin(), data.end()); + + CHECK_EQUAL(int(compare), int(sum)); + } + + //************************************************************************* + TEST(test_checksum_add_values8_operator_plus_equals) + { + std::string data("123456789"); + + etl::parity_checksum checksum_calculator; + + for (size_t i = 0; i < data.size(); ++i) + { + checksum_calculator.add(data[i]); + } + + uint8_t sum = checksum_calculator; + uint8_t compare = reference_checksum(data.begin(), data.end()); + + CHECK_EQUAL(int(compare), int(sum)); + } + + //************************************************************************* + TEST(test_checksum_add_range) + { + std::string data("123456789"); + + etl::parity_checksum checksum_calculator; + + checksum_calculator.add(data.begin(), data.end()); + + uint8_t sum = checksum_calculator.value(); + uint8_t compare = reference_checksum(data.begin(), data.end()); + + CHECK_EQUAL(int(compare), int(sum)); + } + + //************************************************************************* + TEST(test_checksum_add_range_sum32) + { + std::string data("1"); + + etl::parity_checksum checksum_calculator; + + checksum_calculator.add(data.begin(), data.end()); + + uint32_t sum = checksum_calculator.value(); + uint32_t compare = reference_checksum(data.begin(), data.end()); + + CHECK_EQUAL(compare, sum); + } + + //************************************************************************* + TEST(test_checksum_add_range_endian) + { + std::vector data1 = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }; + std::vector data2 = { 0x04030201, 0x08070605 }; + std::vector data3 = { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 }; + + uint64_t hash1 = etl::parity_checksum(data1.begin(), data1.end()); + uint64_t hash2 = etl::parity_checksum((uint8_t*)&data2[0], (uint8_t*)&data2[0] + (data2.size() * sizeof(uint32_t))); + uint64_t hash3 = etl::parity_checksum(data3.rbegin(), data3.rend()); + CHECK_EQUAL(hash1, hash2); + CHECK_EQUAL(hash1, hash3); + } + }; +} + diff --git a/test/vs2017/etl.vcxproj b/test/vs2017/etl.vcxproj index 88221eac..03643314 100644 --- a/test/vs2017/etl.vcxproj +++ b/test/vs2017/etl.vcxproj @@ -1377,6 +1377,7 @@ + diff --git a/test/vs2017/etl.vcxproj.filters b/test/vs2017/etl.vcxproj.filters index 9b6c35e4..d3911983 100644 --- a/test/vs2017/etl.vcxproj.filters +++ b/test/vs2017/etl.vcxproj.filters @@ -1271,6 +1271,9 @@ Source Files + + Source Files + From 119d68d3e5d9a4dffc60d2e41d567661b890be68 Mon Sep 17 00:00:00 2001 From: mchodzikiewicz <33954140+mchodzikiewicz@users.noreply.github.com> Date: Fri, 17 Jan 2020 15:35:28 +0100 Subject: [PATCH 6/9] Fix cmake Unittest++ include path (#188) --- test/cmake/unit-test_external_project.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cmake/unit-test_external_project.cmake b/test/cmake/unit-test_external_project.cmake index 119c64ee..b5e844c5 100644 --- a/test/cmake/unit-test_external_project.cmake +++ b/test/cmake/unit-test_external_project.cmake @@ -29,7 +29,7 @@ function (add_unittest_cpp) TEST_EXCLUDE_FROM_MAIN TRUE # Don't run UnitTest++'s tests by default ) - set(UTPP_INCLUDE_DIRS "${UTPP_INSATLL_DIR}/include/UnitTest++" PARENT_SCOPE) + set(UTPP_INCLUDE_DIRS "${UTPP_INSATLL_DIR}/include" PARENT_SCOPE) add_library(UnitTest++ STATIC IMPORTED) set_target_properties(UnitTest++ PROPERTIES IMPORTED_LOCATION "${UTPP_INSATLL_DIR}/lib/${UTPP_LIB_NAME}" ) # Require the ExternalProject target to complete before importing the library From 238244e1a1714601b6df6468608bed6f9544ce1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20M=C3=BCller?= Date: Fri, 24 Jan 2020 13:01:46 +0100 Subject: [PATCH 7/9] Fix warnings about implicitly-declared assignment operators (#189) --- include/etl/cstring.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/etl/cstring.h b/include/etl/cstring.h index 8036485c..a812403e 100644 --- a/include/etl/cstring.h +++ b/include/etl/cstring.h @@ -203,6 +203,20 @@ namespace etl return new_string; } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + string& operator = (const string& rhs) + { + if (&rhs != this) + { + this->assign(rhs); + } + + return *this; + } + + //************************************************************************* /// Assignment operator. //************************************************************************* From b80763e64430dde7a1655fe713f3e3b43b675afe Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 29 Jan 2020 17:38:02 +0000 Subject: [PATCH 8/9] Fixed incorrect ETL_ALWAYS_ASSERT in etl::callback_timer --- include/etl/callback_timer.h | 15 ++++++--------- include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- support/Release notes.txt | 4 ++++ 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/etl/callback_timer.h b/include/etl/callback_timer.h index 487f5789..07c084e6 100644 --- a/include/etl/callback_timer.h +++ b/include/etl/callback_timer.h @@ -93,6 +93,7 @@ namespace etl IFUNCTION, DELEGATE }; + //******************************************* callback_timer_data() : p_callback(nullptr), @@ -146,10 +147,10 @@ namespace etl //******************************************* /// ETL delegate callback //******************************************* - callback_timer_data(etl::timer::id::type id_, + callback_timer_data(etl::timer::id::type id_, etl::delegate& callback_, - uint32_t period_, - bool repeating_) + uint32_t period_, + bool repeating_) : p_callback(reinterpret_cast(&callback_)), period(period_), delta(etl::timer::state::INACTIVE), @@ -538,7 +539,7 @@ namespace etl for (int i = 0; i < MAX_TIMERS; ++i) { - new (&timer_array[i]) callback_timer_data(); + ::new (&timer_array[i]) callback_timer_data(); } registered_timers = 0; @@ -591,14 +592,10 @@ namespace etl #if ETL_CPP11_SUPPORTED else if(timer.cbk_type == callback_timer_data::DELEGATE) { - // Call the function wrapper callback. + // Call the delegate callback. (*reinterpret_cast*>(timer.p_callback))(); } #endif - else - { - ETL_ALWAYS_ASSERT("Callback timer has incorrect callback type stored"); - } } has_active = !active_list.empty(); diff --git a/include/etl/version.h b/include/etl/version.h index 51eac722..93b5e668 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -39,7 +39,7 @@ SOFTWARE. #define ETL_VERSION_MAJOR 16 #define ETL_VERSION_MINOR 3 -#define ETL_VERSION_PATCH 0 +#define ETL_VERSION_PATCH 1 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index f09a46ef..eae020a0 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "16.3.0", + "version": "16.3.1", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index af92bfdc..8dea8fd3 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=16.3.0 +version=16.3.1 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index b57a14ca..4cc6ae34 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +16.3.1 +Removed incorrect ETL_ALWAYS_ASSERT from etl::callback_timer + =============================================================================== 16.3.0 Added parity checksum to checksum.h. From c757ede53773ad3e94af8ff81d769de1660b6704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20M=C3=BCller?= Date: Fri, 31 Jan 2020 23:03:41 +0100 Subject: [PATCH 9/9] Add missing count calculation (#190) --- include/etl/memory.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/etl/memory.h b/include/etl/memory.h index 8d9c1aa1..39705ca1 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -308,6 +308,8 @@ namespace etl template TOutputIterator uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count) { + count += int32_t(etl::distance(i_begin, i_end)); + return std::uninitialized_copy(i_begin, i_end, o_begin); } #endif