From 3392a6cd88110db0a57cca00bd12a7bd3d85a376 Mon Sep 17 00:00:00 2001 From: David Hebbeker Date: Thu, 22 Feb 2024 20:11:38 +0100 Subject: [PATCH] add static assert with auto message (#740) * Resolve all C++ -O2 warnings Resolve all C++ -O2 warnings Resolve all C++ -O2 warnings * Updated release notes and version * Made unit test suite names unique * Added etl::bit_v for C++17 * add stringify macro (#741) * Add include/linux/stringify.h from Linux kernel 2.6.12-rc2 (cherry picked from commit https://github.com/torvalds/linux/commit/1da177e4c3f41524e886b7f1b8a0c1fc7321cac2) * Make __stringify support variable argument macros too For example: __stringify(__entry->irq, __entry->ret) will now convert it to: "REC->irq, REC->ret" It also still supports single arguments as the old macro did. Signed-off-by: Zhao Lei Acked-by: Frederic Weisbecker Cc: Steven Rostedt LKML-Reference: <49DC6751.30308@cn.fujitsu.com> Signed-off-by: Ingo Molnar (cherry picked from commit https://github.com/torvalds/linux/commit/8f7c2c37319a81ef4c2bfdec67b1ccd5744d97e4) * Add documentation. * Adjust names in order to satisfy naming convention. * Use __VA_ARGS__ instead a GNU extension as this works with more compilers. Works with the newest versions of ICCAVR, GCC, CLANG and MSCV. C++11 may be required. * Adjust to ETL folder structure. * Change include guard to the one usual in ETL. * Add definition guard for STRINGIFY. --------- Co-authored-by: Linus Torvalds Co-authored-by: Zhaolei * Updated stringify macro for variadic parameters * Edited comments * Added multi char type strcmp, strncmp, strcpy & strncpy * Added support for self transitions * Remove some unreachable code in bitset_new.h (#743) Warning[Pe111]: statement is unreachable * Re-enabled tests for etl::string_ext * Changes require for non-virtual messages * MutexMessageRouter example * Allow C++03 delegate in etl::callback_timer * #745 Assertion triggered in hash.h when compiling for MSP430 * Removed redundant #includes * Removed unused variable Minor format edit * Added time_to_next() status function * Added 'sentence case' versions of constants * Added C++03 compatible etl::move or etl::move_backward * Added c++03 zero parameter emplace member functions * Fix issue of release of an object on empty an pool * Remove used variable * Remove used variable * Change to require semicolons after debug count macros. Added error assert for vector reserve greater than capacity. * Added destructor to CMSIS_RTOS2 mutex * Updated version and release notes * Removed semicolon warnings * Updated vesrion and release notes * #753 [porting] IAR's overload resolution struggles with etl::span::span(etl::array&) #754 ambiguous etl::bit_stream_reader::bit_stream_reader() for some etl::span * #755 warning about constexpr in array.h * Re-enabled tests * const_reference at(size_t i) const is only constexpr from C++14 * Added conversion operators to std::span * MacOS clang span issue * MacOS clang span issue * MacOS clang span issue * MacOS clang span issue * MacOS clang span issue * Updated version and release notes * Possible fix for #756 * Fixed: move assignment not working for non-empty containers (#759) * Updated release notes * Make "private" includes relativ (#761) Avoid "include not found" when indirectly including etl-header Co-authored-by: Andreas Pelczer * Make "private" includes relativ (#761) Avoid "include not found" when indirectly including etl-header Co-authored-by: Andreas Pelczer * Remove BOM from random.h (#762) random.h is the only file with UTF8-BOM and IAR can not handle it. For compatibility reasons it should be removed. Co-authored-by: Andreas Pelczer * Enabled etl::overload for C++11 & C++14 * Added conversion operators to std::span MacOS clang span issue MacOS clang span issue MacOS clang span issue MacOS clang span issue MacOS clang span issue * Updated version and release notes * Possible fix for #756 * Fixed: move assignment not working for non-empty containers (#759) * Updated release notes * Make "private" includes relativ (#761) Avoid "include not found" when indirectly including etl-header Co-authored-by: Andreas Pelczer * Remove BOM from random.h (#762) random.h is the only file with UTF8-BOM and IAR can not handle it. For compatibility reasons it should be removed. Co-authored-by: Andreas Pelczer * Enabled etl::overload for C++11 & C++14 * Commets added * #766 etl::unique_ptr::reset() can call deleter with nullptr argument * Refactored storage for etl::optional * Updated release notes * Updated release notes * Test name updates * Fixed alignment functionality * Updated versions * Updated versions * Initial code * Final changes * Fix maybe-uninitialized warning * Fix maybe-uninitialized warning * Added etl::string::fill() * Added etl::string interface to etl::base64 * static_cast for string_view & array_view size() member functions * Return raw pointer for `etl::multi_span::operator->()`. (#773) - using `operator*()` in case getting the current element is changed one day - using `&` to get the address Simply returning `p_value` may break in case the internal type of `p_value` would change. This way it is more robust to changes. * Added -> operator test * #773 Return raw pointer for etl::multi_span::operator->() * static_cast for string_view & array_view size() member functions * Initial code * Final changes * Fix maybe-uninitialized warning * Added etl::string::fill() * Added etl::string interface to etl::base64 * Add missing semicolons (#776) * #776 Add missing semicolons * moved BUILD_TESTS check outside of root cmake check to allow building tests in submodules (#777) added check for GNUC >= 11 for -Wstringop-overread ignore pragma since it isn't introduced until gcc/g++-11 Co-authored-by: Josh * Try to fix library error for Github Actions for Clang C++20 * Try to fix library error for Github Actions for Clang C++20 * Added pul-request branches to CI * Removed temporary fix * Refactored swap * Added add_lvalue_reference for rvalue reference * Revert "Added add_lvalue_reference for rvalue reference" This reverts commit a09efffb8fadb0c25923fe5435b7b1f9bdd673f1. * Updated version and release notes * Updated version and release notes * Try to fix library error for Github Actions for Clang C++20 (cherry picked from commit f208eb4073c98b3c190b17a73db3b61aa35fae25) The line got lost in 95c7f44cc61d51406a70ccb9048724f9fbdd78f9. * Add helper macro which enables function-like macro overload with 1 or 2 arguments. Inspired by https://stackoverflow.com/a/11763277/ Warning: This requires support for variadic macros (`__VA_ARGS__`). These were officially added in C99 and C++11. * Add unit test for static_assert.h (cherry picked from commit 91e7f46effac2884de80a12ab0c7eda5ade5cabe) * Add static assert overload for only 1 argument. (cherry picked from commit ae8c19e8cba69ca209a13109a7225ce6281d945d) * Add test case for static_assert with only 1 argument. (cherry picked from commit 4d6e7a63094221feec22fe3addcccd903b2d81de) * Spelling. --------- Co-authored-by: John Wellbelove Co-authored-by: David Hebbeker Co-authored-by: Linus Torvalds Co-authored-by: Zhaolei Co-authored-by: John Wellbelove Co-authored-by: Soma Veszelovszki Co-authored-by: Andreas Co-authored-by: Andreas Pelczer Co-authored-by: H1MSK Co-authored-by: jmartens-42 Co-authored-by: Josh Co-authored-by: John Wellbelove --- .github/workflows/clang-syntax-checks.yml | 4 +- .github/workflows/clang.yml | 5 +- .github/workflows/gcc-syntax-checks.yml | 4 +- .github/workflows/gcc.yml | 4 +- .github/workflows/msvc.yml | 4 +- .gitignore | 4 + CMakeLists.txt | 11 +- arduino/library-arduino.json | 2 +- arduino/library-arduino.properties | 2 +- examples/MutexMessageRouter/CMakeLists.txt | 12 + .../MutexMessageRouter/MutexMessageRouter.cpp | 110 + .../MutexMessageRouter/MutexMessageRouter.sln | 31 + .../MutexMessageRouter.vcxproj | 140 + include/etl/algorithm.h | 72 +- include/etl/alignment.h | 17 +- include/etl/array.h | 4 - include/etl/array_view.h | 8 +- include/etl/base64.h | 523 + include/etl/basic_string.h | 22 +- include/etl/binary.h | 9 +- include/etl/bit_stream.h | 46 +- include/etl/callback_timer.h | 38 +- include/etl/callback_timer_atomic.h | 32 +- include/etl/callback_timer_interrupt.h | 47 +- include/etl/callback_timer_locked.h | 30 +- include/etl/char_traits.h | 91 +- include/etl/circular_buffer.h | 6 +- include/etl/covariance.h | 1 - include/etl/debug_count.h | 44 +- include/etl/deque.h | 96 +- include/etl/error_handler.h | 26 +- include/etl/file_error_numbers.h | 1 + include/etl/flat_map.h | 32 +- include/etl/flat_multimap.h | 26 +- include/etl/flat_multiset.h | 53 +- include/etl/flat_set.h | 64 +- include/etl/forward_list.h | 72 +- include/etl/fsm.h | 21 +- include/etl/generators/fsm_generator.h | 21 +- include/etl/generators/largest_generator.h | 8 +- .../etl/generators/message_packet_generator.h | 123 +- .../etl/generators/message_router_generator.h | 10 +- include/etl/generators/smallest_generator.h | 2 +- .../etl/generators/type_traits_generator.h | 2 +- include/etl/hash.h | 65 +- include/etl/indirect_vector.h | 30 +- include/etl/intrusive_forward_list.h | 12 +- include/etl/invert.h | 1 - include/etl/ipool.h | 45 +- include/etl/iterator.h | 8 +- include/etl/largest.h | 2 +- include/etl/limiter.h | 1 - include/etl/list.h | 98 +- include/etl/macros.h | 40 +- include/etl/map.h | 12 +- include/etl/mean.h | 2 +- include/etl/memory.h | 12 +- include/etl/message.h | 109 +- include/etl/message_packet.h | 677 +- include/etl/message_router.h | 38 +- include/etl/message_timer.h | 32 +- include/etl/message_timer_atomic.h | 40 +- include/etl/message_timer_interrupt.h | 31 +- include/etl/message_timer_locked.h | 30 +- include/etl/multi_span.h | 4 +- include/etl/multimap.h | 8 +- include/etl/multiset.h | 10 +- include/etl/mutex/mutex_cmsis_os2.h | 7 +- include/etl/optional.h | 124 +- include/etl/overload.h | 46 +- include/etl/parameter_pack.h | 2 +- include/etl/platform.h | 23 +- include/etl/priority_queue.h | 18 + include/etl/private/bitset_new.h | 4 - .../diagnostic_stringop_overread_push.h | 8 +- include/etl/private/ivectorpointer.h | 20 + include/etl/private/pvoidvector.h | 23 + include/etl/private/variant_legacy.h | 29 +- include/etl/private/variant_variadic.h | 50 +- include/etl/private/vector_base.h | 2 +- .../determine_compiler_language_support.h | 30 +- include/etl/quantize.h | 2 +- include/etl/queue.h | 22 +- include/etl/queue_lockable.h | 14 + include/etl/queue_mpmc_mutex.h | 33 + include/etl/queue_spsc_atomic.h | 22 + include/etl/queue_spsc_isr.h | 36 + include/etl/queue_spsc_locked.h | 35 + include/etl/random.h | 2 +- include/etl/rescale.h | 2 +- include/etl/set.h | 12 +- include/etl/span.h | 167 +- include/etl/stack.h | 22 +- include/etl/static_assert.h | 22 +- include/etl/string_view.h | 2 +- include/etl/stringify.h | 20 + include/etl/threshold.h | 2 +- include/etl/timer.h | 16 +- include/etl/to_arithmetic.h | 2 + include/etl/unordered_map.h | 18 +- include/etl/unordered_multimap.h | 14 +- include/etl/unordered_multiset.h | 14 +- include/etl/unordered_set.h | 14 +- include/etl/utility.h | 2 +- include/etl/variance.h | 2 +- include/etl/vector.h | 78 +- include/etl/version.h | 4 +- library.json | 2 +- library.properties | 2 +- scripts/update_version.bat | 1 + scripts/update_version.py | 154 + support/Release notes.txt | 52 +- test/CMakeLists.txt | 8 + test/etl_profile.h | 6 +- test/meson.build | 1 + test/run-tests.sh | 37 +- test/syntax_check/base64.h.t.cpp | 29 + test/syntax_check/c++03/CMakeLists.txt | 1 + test/syntax_check/c++11/CMakeLists.txt | 1 + test/syntax_check/c++14/CMakeLists.txt | 1 + test/syntax_check/c++17/CMakeLists.txt | 1 + test/syntax_check/c++20/CMakeLists.txt | 1 + test/test_algorithm.cpp | 13 +- test/test_alignment.cpp | 12 + test/test_base64.cpp | 685 + test/test_binary.cpp | 175 + test/test_bit_stream_reader_big_endian.cpp | 360 + test/test_bit_stream_reader_little_endian.cpp | 2351 +-- test/test_bit_stream_writer_big_endian.cpp | 1592 +-- test/test_bit_stream_writer_little_endian.cpp | 1766 +-- test/test_byte_stream.cpp | 1 + test/test_callback_timer.cpp | 132 +- test/test_callback_timer_atomic.cpp | 132 +- test/test_callback_timer_interrupt.cpp | 134 +- test/test_callback_timer_locked.cpp | 137 +- test/test_char_traits.cpp | 437 + test/test_deque.cpp | 140 +- test/test_etl_traits.cpp | 5 +- test/test_flat_multiset.cpp | 95 +- test/test_flat_set.cpp | 72 +- test/test_forward_list.cpp | 2 + test/test_fsm.cpp | 228 +- test/test_indirect_vector.cpp | 58 +- test/test_indirect_vector_external_buffer.cpp | 15 + test/test_list.cpp | 109 +- test/test_macros.cpp | 61 + test/test_map.cpp | 1 + test/test_message_packet.cpp | 6 + test/test_message_router.cpp | 19 +- test/test_message_timer.cpp | 126 +- test/test_message_timer_atomic.cpp | 126 +- test/test_message_timer_interrupt.cpp | 129 +- test/test_message_timer_locked.cpp | 131 +- test/test_multi_span.cpp | 34 + test/test_multi_vector.cpp | 2 +- test/test_multimap.cpp | 1 + test/test_multiset.cpp | 1 + test/test_optional.cpp | 42 + test/test_overload.cpp | 4 +- test/test_pool.cpp | 3 + test/test_pool_external_buffer.cpp | 3 + test/test_priority_queue.cpp | 19 +- test/test_queue.cpp | 32 +- test/test_queue_lockable.cpp | 4 +- test/test_queue_lockable_small.cpp | 9 +- test/test_queue_memory_model_small.cpp | 28 +- test/test_queue_mpmc_mutex.cpp | 7 +- test/test_queue_mpmc_mutex_small.cpp | 9 +- test/test_queue_spsc_atomic.cpp | 7 +- test/test_queue_spsc_atomic_small.cpp | 7 +- test/test_queue_spsc_isr.cpp | 23 +- test/test_queue_spsc_isr_small.cpp | 23 +- test/test_queue_spsc_locked.cpp | 23 +- test/test_queue_spsc_locked_small.cpp | 7 +- test/test_set.cpp | 1 + test/test_span_dynamic_extent.cpp | 22 + test/test_span_fixed_extent.cpp | 22 + test/test_stack.cpp | 34 +- test/test_static_assert.cpp | 21 + test/test_string_char.cpp | 16 + test/test_string_u16.cpp | 16 + test/test_string_u16_external_buffer.cpp | 9444 ++++++------- test/test_string_u32.cpp | 16 + test/test_string_u32_external_buffer.cpp | 18 + test/test_string_wchar_t.cpp | 16 + test/test_string_wchar_t_external_buffer.cpp | 18 + test/test_unordered_map.cpp | 1 + test/test_unordered_multimap.cpp | 1 + test/test_unordered_multiset.cpp | 1 + test/test_unordered_set.cpp | 1 + test/test_vector.cpp | 100 + test/test_vector_non_trivial.cpp | 1 - test/test_vector_pointer.cpp | 47 + test/test_vector_pointer_external_buffer.cpp | 2 +- test/vs2022/etl.sln | 12 + test/vs2022/etl.vcxproj | 11781 ++++------------ test/vs2022/etl.vcxproj.filters | 1163 +- version.txt | 2 +- 198 files changed, 17948 insertions(+), 18795 deletions(-) create mode 100644 examples/MutexMessageRouter/CMakeLists.txt create mode 100644 examples/MutexMessageRouter/MutexMessageRouter.cpp create mode 100644 examples/MutexMessageRouter/MutexMessageRouter.sln create mode 100644 examples/MutexMessageRouter/MutexMessageRouter.vcxproj create mode 100644 include/etl/base64.h create mode 100644 include/etl/stringify.h create mode 100644 scripts/update_version.bat create mode 100644 scripts/update_version.py create mode 100644 test/syntax_check/base64.h.t.cpp create mode 100644 test/test_base64.cpp create mode 100644 test/test_macros.cpp create mode 100644 test/test_static_assert.cpp diff --git a/.github/workflows/clang-syntax-checks.yml b/.github/workflows/clang-syntax-checks.yml index be626cb6f..a7cd58d47 100644 --- a/.github/workflows/clang-syntax-checks.yml +++ b/.github/workflows/clang-syntax-checks.yml @@ -1,9 +1,9 @@ name: clang syntax checks on: push: - branches: [ master, development ] + branches: [ master, development, pull-request/* ] pull_request: - branches: [ master ] + branches: [ master, pull-request/* ] jobs: build-clang-cpp03-linux-STL: diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index de243e407..c145beca6 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -1,11 +1,12 @@ name: clang on: push: - branches: [ master, development ] + branches: [ master, development, pull-request/* ] pull_request: - branches: [ master ] + branches: [ master, pull-request/* ] jobs: + build-clang-cpp11-linux-stl: name: Clang C++11 Linux - STL runs-on: ${{ matrix.os }} diff --git a/.github/workflows/gcc-syntax-checks.yml b/.github/workflows/gcc-syntax-checks.yml index 3e5aad947..ee6077967 100644 --- a/.github/workflows/gcc-syntax-checks.yml +++ b/.github/workflows/gcc-syntax-checks.yml @@ -1,9 +1,9 @@ name: gcc syntax checks on: push: - branches: [ master, development ] + branches: [ master, development, pull-request/* ] pull_request: - branches: [ master ] + branches: [ master, pull-request/* ] jobs: build-gcc-cpp03-linux-STL: diff --git a/.github/workflows/gcc.yml b/.github/workflows/gcc.yml index 9ee4b568a..c9423301c 100644 --- a/.github/workflows/gcc.yml +++ b/.github/workflows/gcc.yml @@ -1,9 +1,9 @@ name: gcc on: push: - branches: [ master, development ] + branches: [ master, development, pull-request/* ] pull_request: - branches: [ master ] + branches: [ master, pull-request/* ] jobs: build-gcc-cpp11-linux-stl: diff --git a/.github/workflows/msvc.yml b/.github/workflows/msvc.yml index cdeff8358..c63a35c2e 100644 --- a/.github/workflows/msvc.yml +++ b/.github/workflows/msvc.yml @@ -1,9 +1,9 @@ name: msvc on: push: - branches: [ master, development ] + branches: [ master, development, pull-request/* ] pull_request: - branches: [ master ] + branches: [ master, pull-request/* ] jobs: build-windows-msvc-stl: diff --git a/.gitignore b/.gitignore index b96d6aca2..1561cf007 100644 --- a/.gitignore +++ b/.gitignore @@ -382,3 +382,7 @@ test/vs2022/Release MSVC C++20 - No STL - Optimised -O2 test/vs2022/Release MSVC C++20 - Optimised O2 test/vs2022/Debug MSVC C++ 20 - No Tests test/vs2022/enc_temp_folder +test/vs2022/Debug MSVC C++20 - No virtual messages +examples/MutexMessageRouter/.vs +support/time remaining test.xlsx +test/vs2022/Debug MSVC C++20 - Force C++03 diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ce02e57d..9f81b8bbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,9 +73,10 @@ if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake) install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/etl DESTINATION include) - - if (BUILD_TESTS) - enable_testing() - add_subdirectory(test) - endif() + +endif() + +if (BUILD_TESTS) + enable_testing() + add_subdirectory(test) endif() diff --git a/arduino/library-arduino.json b/arduino/library-arduino.json index 24831b68d..822e28f84 100644 --- a/arduino/library-arduino.json +++ b/arduino/library-arduino.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library - Arduino", - "version": "20.37.3", + "version": "20.38.4", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/arduino/library-arduino.properties b/arduino/library-arduino.properties index a6468d730..41ce4dfd1 100644 --- a/arduino/library-arduino.properties +++ b/arduino/library-arduino.properties @@ -1,5 +1,5 @@ name=Embedded Template Library - Arduino -version=20.37.3 +version=20.38.4 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/examples/MutexMessageRouter/CMakeLists.txt b/examples/MutexMessageRouter/CMakeLists.txt new file mode 100644 index 000000000..3ed4b3359 --- /dev/null +++ b/examples/MutexMessageRouter/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.5.0) +project(etl_mutex_router LANGUAGES CXX) + +add_executable(etl_mutex_router MutexMessageRouter.cpp) + +target_compile_definitions(etl_mutex_router PRIVATE -DETL_DEBUG) + +target_include_directories(etl_mutex_router + PRIVATE + ${PROJECT_SOURCE_DIR}/../../include) + +set_property(TARGET etl_mutex_router PROPERTY CXX_STANDARD 17) diff --git a/examples/MutexMessageRouter/MutexMessageRouter.cpp b/examples/MutexMessageRouter/MutexMessageRouter.cpp new file mode 100644 index 000000000..1d6126730 --- /dev/null +++ b/examples/MutexMessageRouter/MutexMessageRouter.cpp @@ -0,0 +1,110 @@ + +#include +#include +#include +#include +#include + +#include "etl/mutex.h" +#include "etl/message.h" +#include "etl/message_router.h" + +//************************************* +struct Message1 : public etl::message<1> +{ +}; + +//************************************* +struct Message2 : public etl::message<2> +{ +}; + +//************************************* +class Router : public etl::message_router +{ +public: + + using base_t = etl::message_router; + + //***************** + // Overridden receive that protects access with mutexes + void receive(const etl::imessage& msg) override + { + access.lock(); + base_t::receive(msg); // Send it to the message_router's receive. + access.unlock(); + } + + //***************** + void on_receive(const Message1&) + { + result.append("Message1\n"); + } + + //***************** + void on_receive(const Message2&) + { + result.append("Message2\n"); + } + + //***************** + void on_receive_unknown(const etl::imessage&) + { + } + + std::string result; + +private: + + etl::mutex access; +}; + +//************************************* +etl::atomic start = false; +Router router; + +//************************************* +void thread1() +{ + using namespace std::chrono_literals; + + while (!start.load()); + + for (int i = 0; i < 10; ++i) + { + std::this_thread::sleep_for(1ms); + router.receive(Message1()); + } +} + +//************************************* +void thread2() +{ + using namespace std::chrono_literals; + + while (!start.load()); + + for (int i = 0; i < 10; ++i) + { + std::this_thread::sleep_for(1ms); + router.receive(Message2()); + } +} + +//************************************* +int main() +{ + std::thread t1(thread1); + std::thread t2(thread2); + + start.store(true); + + t1.join(); + t2.join(); + + std::cout << router.result << "\n"; + + return 0; +} + + diff --git a/examples/MutexMessageRouter/MutexMessageRouter.sln b/examples/MutexMessageRouter/MutexMessageRouter.sln new file mode 100644 index 000000000..f4e7b5d81 --- /dev/null +++ b/examples/MutexMessageRouter/MutexMessageRouter.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34009.444 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MutexMessageRouter", "MutexMessageRouter.vcxproj", "{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Debug|x64.ActiveCfg = Debug|x64 + {23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Debug|x64.Build.0 = Debug|x64 + {23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Debug|x86.ActiveCfg = Debug|Win32 + {23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Debug|x86.Build.0 = Debug|Win32 + {23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Release|x64.ActiveCfg = Release|x64 + {23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Release|x64.Build.0 = Release|x64 + {23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Release|x86.ActiveCfg = Release|Win32 + {23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8AA5CBFE-B15F-4262-97AE-C12F7266BD85} + EndGlobalSection +EndGlobal diff --git a/examples/MutexMessageRouter/MutexMessageRouter.vcxproj b/examples/MutexMessageRouter/MutexMessageRouter.vcxproj new file mode 100644 index 000000000..214a316c9 --- /dev/null +++ b/examples/MutexMessageRouter/MutexMessageRouter.vcxproj @@ -0,0 +1,140 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {23ad62d5-c3b6-48b0-bf0d-e349feb3f338} + MutexMessageRouter + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + ../../include; + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + ../../include;%(AdditionalIncludeDirectories) + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + \ No newline at end of file diff --git a/include/etl/algorithm.h b/include/etl/algorithm.h index a2b061820..cc989d153 100644 --- a/include/etl/algorithm.h +++ b/include/etl/algorithm.h @@ -88,6 +88,37 @@ namespace etl //***************************************************************************** namespace etl { + namespace private_algorithm + { + template + struct swap_impl; + + // Generic swap + template <> + struct swap_impl + { + template + static void do_swap(TIterator1 a, TIterator2 b) + { + typename etl::iterator_traits::value_type tmp = *a; + *a = *b; + *b = tmp; + } + }; + + // Specialised swap + template <> + struct swap_impl + { + template + static void do_swap(TIterator1 a, TIterator2 b) + { + using ETL_OR_STD::swap; // Allow ADL + swap(*a, *b); + } + }; + } + //*************************************************************************** // iter_swap //*************************************************************************** @@ -99,8 +130,20 @@ namespace etl #endif void iter_swap(TIterator1 a, TIterator2 b) { - using ETL_OR_STD::swap; // Allow ADL - swap(*a, *b); + typedef etl::iterator_traits traits1; + typedef etl::iterator_traits traits2; + + typedef typename traits1::value_type v1; + typedef typename traits2::value_type v2; + + typedef typename traits1::reference r1; + typedef typename traits2::reference r2; + + const bool use_swap = etl::is_same::value && + etl::is_reference::value && + etl::is_reference::value; + + private_algorithm::swap_impl::do_swap(a, b); } //*************************************************************************** @@ -229,8 +272,8 @@ namespace etl { return std::move(sb, se, db); } -#else - // non-pointer or not trivially copyable +#elif ETL_USING_CPP11 + // For C++11 template ETL_CONSTEXPR14 TIterator2 move(TIterator1 sb, TIterator1 se, TIterator2 db) { @@ -243,19 +286,25 @@ namespace etl return db; } +#else + // For C++03 + template + ETL_CONSTEXPR14 TIterator2 move(TIterator1 sb, TIterator1 se, TIterator2 db) + { + return copy(sb, se, db); + } #endif //*************************************************************************** // move_backward #if ETL_USING_STL && ETL_USING_CPP20 template - ETL_CONSTEXPR20 - TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de) + ETL_CONSTEXPR20 TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de) { return std::move_backward(sb, se, de); } -#else - // non-pointer or not trivially copyable +#elif ETL_USING_CPP11 + // For C++11 template ETL_CONSTEXPR14 TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de) { @@ -266,6 +315,13 @@ namespace etl return de; } +#else + // For C++03 + template + ETL_CONSTEXPR14 TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de) + { + return etl::copy_backward(sb, se, de); + } #endif //*************************************************************************** diff --git a/include/etl/alignment.h b/include/etl/alignment.h index 78f104057..ab2ad6fa8 100644 --- a/include/etl/alignment.h +++ b/include/etl/alignment.h @@ -204,13 +204,24 @@ namespace etl { public: -#if ETL_NOT_USING_64BIT_TYPES - typedef typename private_alignment::type_with_alignment_helper::type type; +#if ETL_USING_CPP11 + typedef struct { alignas(Alignment) char dummy; } type; #else - typedef typename private_alignment::type_with_alignment_helper::type type; + #if ETL_NOT_USING_64BIT_TYPES + typedef typename private_alignment::type_with_alignment_helper::type type; + #else + typedef typename private_alignment::type_with_alignment_helper::type type; + #endif #endif + + ETL_STATIC_ASSERT(etl::alignment_of::value == Alignment, "Unable to create the type with the specified alignment"); }; +#if ETL_USING_CPP11 + template + using type_with_alignment_t = typename type_with_alignment::type; +#endif + //*************************************************************************** /// Aligned storage /// Length should be determined in terms of sizeof() diff --git a/include/etl/array.h b/include/etl/array.h index 4bbb68713..52f0f654e 100644 --- a/include/etl/array.h +++ b/include/etl/array.h @@ -127,11 +127,7 @@ namespace etl ///\param i The index of the element to access. //************************************************************************* ETL_NODISCARD -#if defined(ETL_THROW_EXCEPTIONS) ETL_CONSTEXPR14 -#else - ETL_CONSTEXPR -#endif const_reference at(size_t i) const { ETL_ASSERT(i < SIZE, ETL_ERROR(array_out_of_range)); diff --git a/include/etl/array_view.h b/include/etl/array_view.h index 855680c86..f388f2877 100644 --- a/include/etl/array_view.h +++ b/include/etl/array_view.h @@ -421,7 +421,7 @@ namespace etl //************************************************************************* /// Returns true if the array size is zero. //************************************************************************* - bool empty() const + ETL_CONSTEXPR bool empty() const { return (mbegin == mend); } @@ -429,15 +429,15 @@ namespace etl //************************************************************************* /// Returns the size of the array. //************************************************************************* - size_t size() const + ETL_CONSTEXPR size_t size() const { - return (mend - mbegin); + return static_cast(mend - mbegin); } //************************************************************************* /// Returns the maximum possible size of the array. //************************************************************************* - size_t max_size() const + ETL_CONSTEXPR size_t max_size() const { return size(); } diff --git a/include/etl/base64.h b/include/etl/base64.h new file mode 100644 index 000000000..32217a964 --- /dev/null +++ b/include/etl/base64.h @@ -0,0 +1,523 @@ +//************************************************************************* +///Decode from Base64 from and to pointer/length +//*************************************************************************///\file + +/****************************************************************************** +The MIT License(MIT) +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com +Copyright(c) 2023 John Wellbelove +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. +******************************************************************************/ + +#ifndef ETL_BASE64_INCLUDED +#define ETL_BASE64_INCLUDED + +#include "etl/platform.h" +#include "etl/span.h" +#include "etl/static_assert.h" +#include "etl/error_handler.h" +#include "etl/exception.h" +#include "etl/type_traits.h" +#include "etl/binary.h" +#include "etl/algorithm.h" +#include "etl/integral_limits.h" +#include "etl/iterator.h" +#include "etl/string.h" + +#include + +#if ETL_USING_STL + #include +#endif + +namespace etl +{ + //*************************************************************************** + /// Exception base for base64 + //*************************************************************************** + class base64_exception : public etl::exception + { + public: + + base64_exception(string_type reason_, string_type file_name_, numeric_type line_number_) + : exception(reason_, file_name_, line_number_) + { + } + }; + + //*************************************************************************** + /// Memory misalignment exception. + //*************************************************************************** + class base64_overflow : public base64_exception + { + public: + + base64_overflow(string_type file_name_, numeric_type line_number_) + : base64_exception(ETL_ERROR_TEXT("base64:overflow", ETL_BASE64_FILE_ID"A"), file_name_, line_number_) + { + } + }; + + //************************************************************************* + /// Codec for Base64 + //************************************************************************* + class base64 + { + public: + + //************************************************************************* + /// Encode to Base64 from and to pointer/length + //************************************************************************* + template + ETL_CONSTEXPR14 + static + typename etl::enable_if::value && (etl::integral_limits::bits == 8U), size_t>::type + encode(const T* input, size_t input_length, char* output, size_t output_length) + { + if (input_length == 0U) + { + return 0; + } + + // Figure out if the output buffer is large enough. + size_t required_output_length = encode_size(input_length); + + ETL_ASSERT_OR_RETURN_VALUE(output_length >= required_output_length, ETL_ERROR(base64_overflow), 0U); + + const T* p_in = input; + const T* p_in_end = input + input_length; + + char* p_out = output; + char* p_out_end = output + required_output_length; + + int next_sextet = First_Sextet; + + // Step through the input buffer, creating the output sextets. + while (p_in != p_in_end) + { + T c = *p_in; + char index = 0; + + switch (next_sextet) + { + //************************** + case First_Sextet: + { + index = static_cast((*p_in & b11111100) >> 2); + next_sextet = Second_Sextet; + break; + } + + //************************** + case Second_Sextet: + { + index = static_cast((c & b00000011) << 4); + ++p_in; + + // Next byte valid? + if (p_in != p_in_end) + { + index = index | ((*p_in & b11110000) >> 4); + } + next_sextet = Third_Sextet; + break; + } + + //************************** + case Third_Sextet: + { + index = (c & b00001111) << 2; + ++p_in; + + // Next byte valid? + if (p_in != p_in_end) + { + index = index | static_cast((*p_in & b11000000) >> 6); + } + next_sextet = Fourth_Sextet; + break; + } + + //************************** + case Fourth_Sextet: + { + index = static_cast(c & b00111111); + ++p_in; + next_sextet = First_Sextet; + break; + } + + //************************** + default: + { + // Should never get here. + assert(false); + break; + } + } + + *p_out = get_sextet_from_index(index); + ++p_out; + } + + // Pad out the end of the output buffer. + while (p_out != p_out_end) + { + *p_out++ = padding(); + } + + return static_cast(etl::distance(output, p_out)); + } + + //************************************************************************* + /// Encode to Base64 from and to pointer/pointer + //************************************************************************* + template + ETL_CONSTEXPR14 + static + typename etl::enable_if::value && (etl::integral_limits::bits == 8U), size_t>::type + encode(const T* input_begin, const T* input_end, char* output_begin, char* output_end) + { + return encode(input_begin, static_cast(etl::distance(input_begin, input_end)), + output_begin, static_cast(etl::distance(output_begin, output_end))); + } + + //************************************************************************* + /// Encode to Base64 from and to span/span + //************************************************************************* + template + ETL_CONSTEXPR14 + static + typename etl::enable_if::value && (etl::integral_limits::bits == 8U), size_t>::type + encode(const etl::span& input_span, + const etl::span& output_span) + { + return encode(input_span.begin(), input_span.size(), + output_span.begin(), output_span.size()); + } + + //************************************************************************* + /// Encode to Base64 from pointer/length to etl::istring + //************************************************************************* + template + ETL_CONSTEXPR14 + static + typename etl::enable_if::value && (etl::integral_limits::bits == 8U), size_t>::type + encode(const T* input_begin, size_t input_length, + etl::istring& output) + { + output.resize(etl::base64::encode_size(input_length)); + + return encode(input_begin, input_length, + output.data(), output.size()); + } + + //************************************************************************* + /// Encode to Base64 from pointer/pointer to etl::istring + //************************************************************************* + template + ETL_CONSTEXPR14 + static + typename etl::enable_if::value && (etl::integral_limits::bits == 8U), size_t>::type + encode(const T* input_begin, const T* input_end, + etl::istring& output) + { + output.resize(etl::base64::encode_size(etl::distance(input_begin, input_end))); + + return encode(input_begin, static_cast(etl::distance(input_begin, input_end)), + output.data(), output.size()); + } + + //************************************************************************* + /// Encode to Base64 from span to etl::istring + //************************************************************************* + template + ETL_CONSTEXPR14 + static + typename etl::enable_if::value && (etl::integral_limits::bits == 8U), size_t>::type + encode(const etl::span& input_span, + etl::istring& output) + { + output.resize(etl::base64::encode_size(Length1)); + + return encode(input_span.begin(), input_span.size(), + output.data(), output.size()); + } + + //************************************************************************* + /// Calculates the buffer size required to encode to Base64 + //************************************************************************* + ETL_NODISCARD + ETL_CONSTEXPR14 + static + size_t encode_size(size_t input_length) + { + size_t required_output_length = (input_length * 8U) / 6U; + + if ((input_length % 3U) != 0U) + { + while ((required_output_length % 4U) != 0) + { + ++required_output_length; + } + } + + return required_output_length; + } + + //************************************************************************* + /// Decode from Base64 from and to pointer/length + //************************************************************************* + template + ETL_CONSTEXPR14 + static + typename etl::enable_if::value && (etl::integral_limits::bits == 8U), size_t>::type + decode(const char* input, size_t input_length, T* output, size_t output_length) + { + if (input_length == 0) + { + return 0; + } + + // Figure out if the output buffer is large enough. + size_t required_output_length = etl::base64::decode_size(input, input_length); + + ETL_ASSERT_OR_RETURN_VALUE(output_length >= required_output_length, ETL_ERROR(base64_overflow), 0U); + + const char* p_in = input; + const char* p_in_end = input + input_length; + + T* p_out = output; + + T c = 0; + int next_sextet = First_Sextet; + + // Step through the input buffer, creating the output binary. + while (p_in != p_in_end) + { + char sextet = *p_in++; // Get the sextet as a T. + + if (sextet == padding()) + { + break; + } + + char index = get_index_from_sextet(sextet); + + switch (next_sextet) + { + //************************** + case First_Sextet: + { + c = (index & b00111111) << 2; + next_sextet = Second_Sextet; + break; + } + + //************************** + case Second_Sextet: + { + c |= (index & b00110000) >> 4; + *p_out++ = static_cast(c); + c = (index & b00001111) << 4; + next_sextet = Third_Sextet; + break; + } + + //************************** + case Third_Sextet: + { + c |= (index & b00111100) >> 2; + *p_out++ = static_cast(c); + c = (index & b00000011) << 6; + next_sextet = Fourth_Sextet; + break; + } + + //************************** + case Fourth_Sextet: + { + c |= (index & b00111111); + *p_out++ = static_cast(c); + next_sextet = First_Sextet; + break; + } + + //************************** + default: + { + // Should never get here. + assert(false); + break; + } + } + } + + return static_cast(etl::distance(output, p_out)); + } + + //************************************************************************* + /// Decode from Base64 from and to pointer/pointer + //************************************************************************* + template + ETL_CONSTEXPR14 + static + typename etl::enable_if::value && (etl::integral_limits::bits == 8U), size_t>::type + decode(const char* input_begin, const char* input_end, T* output_begin, T* output_end) + { + return decode(input_begin, static_cast(etl::distance(input_begin, input_end)), + output_begin, static_cast(etl::distance(output_begin, output_end))); + } + + //************************************************************************* + /// Decode from Base64 from and to span/span + //************************************************************************* + template + ETL_CONSTEXPR14 + static + typename etl::enable_if::value && (etl::integral_limits::bits == 8U), size_t>::type + decode(const etl::span& input_span, + const etl::span& output_span) + { + return decode(input_span.begin(), input_span.size(), + output_span.begin(), output_span.size()); + } + + //************************************************************************* + /// Calculates the buffer size required to decode from Base64 + //************************************************************************* + ETL_NODISCARD + ETL_CONSTEXPR14 + static size_t decode_size(const char* input, size_t input_length) + { + if (input_length == 0U) + { + return 0U; + } + + // Figure out the minimum output buffer size. + size_t length = static_cast(etl::distance(input, etl::find(input, input + input_length, padding())) - 1); + size_t required_output_length = length - (length / 4U); + + return required_output_length; + } + + private: + + //************************************************************************* + /// Sextet index id. + enum + { + First_Sextet, + Second_Sextet, + Third_Sextet, + Fourth_Sextet + }; + + // Sextets + // 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + // 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + // 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + // 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + // 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + // 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + // 'w', 'x', 'y', 'z', '0', '1', '2', '3', + // '4', '5', '6', '7', '8', '9', '+', '/' + + //************************************************************************* + // Translates an index into a sextet + //************************************************************************* + ETL_CONSTEXPR14 static char get_sextet_from_index(char index) + { + if ((index >= 0) && (index < 26)) + { + return 'A' + index; + } + else if ((index >= 26) && (index < 52)) + { + index -= 26; + return 'a' + index; + } + else if ((index >= 52) && (index < 62)) + { + index -= 52; + return '0' + index; + } + else if (index == 62) + { + return '+'; + } + else if (index == 63) + { + return '/'; + } + else + { + // Should never get here. + assert(false); + return padding(); + } + } + + //************************************************************************* + // Translates a sextet into an index + //************************************************************************* + ETL_CONSTEXPR14 static char get_index_from_sextet(char sextet) + { + if ((sextet >= 'A') && (sextet <= 'Z')) + { + return sextet - 'A'; + } + else if ((sextet >= 'a') && (sextet <= 'z')) + { + return sextet - 'a' + 26; + } + else if ((sextet >= '0') && (sextet <= '9')) + { + return sextet - '0' + 52; + } + else if (sextet == '+') + { + return 62; + } + else if (sextet == '/') + { + return 63; + } + else + { + // Should never get here. + assert(false); + return 0; + } + } + + //************************************************************************* + /// Gets the padding character + //************************************************************************* + ETL_NODISCARD + ETL_CONSTEXPR14 + static char padding() + { + return '='; + } + }; +} + +#endif diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index b9d8a4a1c..8afdf18a4 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -173,7 +173,7 @@ namespace etl /// Gets the current size of the string. ///\return The current size of the string. //************************************************************************* - size_type size() const + ETL_CONSTEXPR size_type size() const { return current_size; } @@ -502,6 +502,16 @@ namespace etl p_buffer[new_size] = 0; } + //********************************************************************* + /// Fills the string with the specified character. + /// Does not change the string length. + ///\param value The character used to fill the string. + //********************************************************************* + void fill(T value) + { + etl::fill(begin(), end(), value); + } + //********************************************************************* /// Returns a reference to the value at index 'i' ///\param i The index. @@ -595,7 +605,7 @@ namespace etl /// Returns a const pointer to the beginning of the string data. ///\return A const pointer to the beginning of the string data. //********************************************************************* - const_pointer data() const + ETL_CONSTEXPR const_pointer data() const { return p_buffer; } @@ -703,7 +713,7 @@ namespace etl set_truncated(*other != 0); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ASSERT(flags.test() == false, ETL_ERROR(string_truncation)) + ETL_ASSERT(flags.test() == false, ETL_ERROR(string_truncation)); #endif #endif @@ -724,7 +734,7 @@ namespace etl set_truncated(length_ > CAPACITY); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ASSERT(flags.test() == false, ETL_ERROR(string_truncation)) + ETL_ASSERT(flags.test() == false, ETL_ERROR(string_truncation)); #endif #endif @@ -764,7 +774,7 @@ namespace etl set_truncated(first != last); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ASSERT(flags.test() == false, ETL_ERROR(string_truncation)) + ETL_ASSERT(flags.test() == false, ETL_ERROR(string_truncation)); #endif #endif } @@ -783,7 +793,7 @@ namespace etl set_truncated(n > CAPACITY); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ASSERT(flags.test() == false, ETL_ERROR(string_truncation)) + ETL_ASSERT(flags.test() == false, ETL_ERROR(string_truncation)); #endif #endif diff --git a/include/etl/binary.h b/include/etl/binary.h index e94782984..1efd5f15c 100644 --- a/include/etl/binary.h +++ b/include/etl/binary.h @@ -390,16 +390,21 @@ namespace etl template struct bit { - typedef typename etl::smallest_uint_for_bits::type value_type; + typedef typename etl::smallest_uint_for_bits::type value_type; static ETL_CONSTANT value_type value = value_type(1) << POSITION; }; template ETL_CONSTANT typename bit::value_type bit::value; +#if ETL_USING_CPP11 + template + using bit_t = typename etl::bit::value_type; +#endif + #if ETL_USING_CPP17 template - inline constexpr typename bit::value_type bit_v = bit::value; + inline constexpr bit_t bit_v = etl::bit::value; #endif //*************************************************************************** diff --git a/include/etl/bit_stream.h b/include/etl/bit_stream.h index 21d95d364..9734a9b0d 100644 --- a/include/etl/bit_stream.h +++ b/include/etl/bit_stream.h @@ -535,7 +535,8 @@ namespace etl //*************************************************************************** /// Construct from span. //*************************************************************************** - bit_stream_writer(etl::span span_, etl::endian stream_endianness_, callback_type callback_ = callback_type()) + template + bit_stream_writer(const etl::span& span_, etl::endian stream_endianness_, callback_type callback_ = callback_type()) : pdata(span_.begin()) , length_chars(span_.size_bytes()) , stream_endianness(stream_endianness_) @@ -547,7 +548,8 @@ namespace etl //*************************************************************************** /// Construct from span. //*************************************************************************** - bit_stream_writer(etl::span span_, etl::endian stream_endianness_, callback_type callback_ = callback_type()) + template + bit_stream_writer(const etl::span& span_, etl::endian stream_endianness_, callback_type callback_ = callback_type()) : pdata(reinterpret_cast(span_.begin())) , length_chars(span_.size_bytes()) , stream_endianness(stream_endianness_) @@ -1031,7 +1033,8 @@ namespace etl //*************************************************************************** /// Construct from span. //*************************************************************************** - bit_stream_reader(etl::span span_, etl::endian stream_endianness_) + template + bit_stream_reader(const etl::span& span_, etl::endian stream_endianness_) : pdata(span_.begin()) , length_chars(span_.size_bytes()) , stream_endianness(stream_endianness_) @@ -1042,8 +1045,33 @@ namespace etl //*************************************************************************** /// Construct from span. //*************************************************************************** - bit_stream_reader(etl::span span_, etl::endian stream_endianness_) - : pdata(reinterpret_cast(span_.begin())) + template + bit_stream_reader(const etl::span& span_, etl::endian stream_endianness_) + : pdata(reinterpret_cast(span_.begin())) + , length_chars(span_.size_bytes()) + , stream_endianness(stream_endianness_) + { + restart(); + } + + //*************************************************************************** + /// Construct from span. + //*************************************************************************** + template + bit_stream_reader(const etl::span& span_, etl::endian stream_endianness_) + : pdata(span_.begin()) + , length_chars(span_.size_bytes()) + , stream_endianness(stream_endianness_) + { + restart(); + } + + //*************************************************************************** + /// Construct from span. + //*************************************************************************** + template + bit_stream_reader(const etl::span& span_, etl::endian stream_endianness_) + : pdata(reinterpret_cast(span_.begin())) , length_chars(span_.size_bytes()) , stream_endianness(stream_endianness_) { @@ -1054,8 +1082,8 @@ namespace etl /// Construct from range. //*************************************************************************** bit_stream_reader(void* begin_, void* end_, etl::endian stream_endianness_) - : pdata(reinterpret_cast(begin_)) - , length_chars(etl::distance(reinterpret_cast(begin_), reinterpret_cast(end_))) + : pdata(reinterpret_cast(begin_)) + , length_chars(etl::distance(reinterpret_cast(begin_), reinterpret_cast(end_))) , stream_endianness(stream_endianness_) { restart(); @@ -1065,7 +1093,7 @@ namespace etl /// Construct from begin and length. //*************************************************************************** bit_stream_reader(void* begin_, size_t length_, etl::endian stream_endianness_) - : pdata(reinterpret_cast(begin_)) + : pdata(reinterpret_cast(begin_)) , length_chars(length_) , stream_endianness(stream_endianness_) { @@ -1318,7 +1346,7 @@ namespace etl bits_available -= nbits; } - char* pdata; ///< The start of the bitstream buffer. + const char* pdata; ///< The start of the bitstream buffer. size_t length_chars; ///< The length, in char, of the bitstream buffer. const etl::endian stream_endianness; ///< The endianness of the stream data. unsigned char bits_available_in_char; ///< The number of available bits in the current char. diff --git a/include/etl/callback_timer.h b/include/etl/callback_timer.h index 7f16bffea..e4b5596d7 100644 --- a/include/etl/callback_timer.h +++ b/include/etl/callback_timer.h @@ -94,7 +94,7 @@ namespace etl callback_timer_data() : p_callback(ETL_NULLPTR), period(0), - delta(etl::timer::state::INACTIVE), + delta(etl::timer::state::Inactive), id(etl::timer::id::NO_TIMER), previous(etl::timer::id::NO_TIMER), next(etl::timer::id::NO_TIMER), @@ -112,7 +112,7 @@ namespace etl bool repeating_) : p_callback(reinterpret_cast(p_callback_)), period(period_), - delta(etl::timer::state::INACTIVE), + delta(etl::timer::state::Inactive), id(id_), previous(etl::timer::id::NO_TIMER), next(etl::timer::id::NO_TIMER), @@ -130,7 +130,7 @@ namespace etl bool repeating_) : p_callback(reinterpret_cast(&callback_)), period(period_), - delta(etl::timer::state::INACTIVE), + delta(etl::timer::state::Inactive), id(id_), previous(etl::timer::id::NO_TIMER), next(etl::timer::id::NO_TIMER), @@ -139,7 +139,6 @@ namespace etl { } -#if ETL_USING_CPP11 //******************************************* /// ETL delegate callback //******************************************* @@ -149,7 +148,7 @@ namespace etl bool repeating_) : p_callback(reinterpret_cast(&callback_)), period(period_), - delta(etl::timer::state::INACTIVE), + delta(etl::timer::state::Inactive), id(id_), previous(etl::timer::id::NO_TIMER), next(etl::timer::id::NO_TIMER), @@ -157,14 +156,13 @@ namespace etl cbk_type(DELEGATE) { } -#endif //******************************************* /// Returns true if the timer is active. //******************************************* bool is_active() const { - return delta != etl::timer::state::INACTIVE; + return delta != etl::timer::state::Inactive; } //******************************************* @@ -172,7 +170,7 @@ namespace etl //******************************************* void set_inactive() { - delta = etl::timer::state::INACTIVE; + delta = etl::timer::state::Inactive; } void* p_callback; @@ -315,7 +313,7 @@ namespace etl timer.previous = etl::timer::id::NO_TIMER; timer.next = etl::timer::id::NO_TIMER; - timer.delta = etl::timer::state::INACTIVE; + timer.delta = etl::timer::state::Inactive; } //******************************* @@ -324,6 +322,12 @@ namespace etl return ptimers[head]; } + //******************************* + const etl::callback_timer_data& front() const + { + return ptimers[head]; + } + //******************************* etl::timer::id::type begin() { @@ -587,13 +591,11 @@ namespace etl // Call the function wrapper callback. (*reinterpret_cast*>(timer.p_callback))(); } -#if ETL_USING_CPP11 else if(timer.cbk_type == callback_timer_data::DELEGATE) { // Call the delegate callback. (*reinterpret_cast(timer.p_callback))(); } -#endif } has_active = !active_list.empty(); @@ -629,7 +631,7 @@ namespace etl if (timer.id != etl::timer::id::NO_TIMER) { // Has a valid period. - if (timer.period != etl::timer::state::INACTIVE) + if (timer.period != etl::timer::state::Inactive) { ETL_DISABLE_TIMER_UPDATES; if (timer.is_active()) @@ -706,6 +708,16 @@ namespace etl return false; } + //******************************************* + /// Get the time to the next timer event. + //******************************************* + uint32_t time_to_next() const + { + uint32_t delta = active_list.front().delta; + + return delta; + } + protected: //******************************************* @@ -744,7 +756,7 @@ namespace etl #endif #endif - etl::timer_semaphore_t process_semaphore; + mutable etl::timer_semaphore_t process_semaphore; #endif uint_least8_t registered_timers; diff --git a/include/etl/callback_timer_atomic.h b/include/etl/callback_timer_atomic.h index 860901dd1..0d12fc297 100644 --- a/include/etl/callback_timer_atomic.h +++ b/include/etl/callback_timer_atomic.h @@ -220,7 +220,7 @@ namespace etl if (timer.id != etl::timer::id::NO_TIMER) { // Has a valid period. - if (timer.period != etl::timer::state::INACTIVE) + if (timer.period != etl::timer::state::Inactive) { ++process_semaphore; if (timer.is_active()) @@ -297,6 +297,18 @@ namespace etl return false; } + //******************************************* + /// Get the time to the next timer event. + //******************************************* + uint32_t time_to_next() const + { + ++process_semaphore; + uint32_t delta = active_list.front().delta; + --process_semaphore; + + return delta; + } + protected: //************************************************************************* @@ -307,7 +319,7 @@ namespace etl timer_data() : callback() , period(0U) - , delta(etl::timer::state::INACTIVE) + , delta(etl::timer::state::Inactive) , id(etl::timer::id::NO_TIMER) , previous(etl::timer::id::NO_TIMER) , next(etl::timer::id::NO_TIMER) @@ -324,7 +336,7 @@ namespace etl bool repeating_) : callback(callback_) , period(period_) - , delta(etl::timer::state::INACTIVE) + , delta(etl::timer::state::Inactive) , id(id_) , previous(etl::timer::id::NO_TIMER) , next(etl::timer::id::NO_TIMER) @@ -337,7 +349,7 @@ namespace etl //******************************************* bool is_active() const { - return delta != etl::timer::state::INACTIVE; + return delta != etl::timer::state::Inactive; } //******************************************* @@ -345,7 +357,7 @@ namespace etl //******************************************* void set_inactive() { - delta = etl::timer::state::INACTIVE; + delta = etl::timer::state::Inactive; } callback_type callback; @@ -500,7 +512,7 @@ namespace etl timer.previous = etl::timer::id::NO_TIMER; timer.next = etl::timer::id::NO_TIMER; - timer.delta = etl::timer::state::INACTIVE; + timer.delta = etl::timer::state::Inactive; } //******************************* @@ -509,6 +521,12 @@ namespace etl return ptimers[head]; } + //******************************* + const timer_data& front() const + { + return ptimers[head]; + } + //******************************* etl::timer::id::type begin() { @@ -563,7 +581,7 @@ namespace etl timer_list active_list; bool enabled; - TSemaphore process_semaphore; + mutable TSemaphore process_semaphore; uint_least8_t number_of_registered_timers; public: diff --git a/include/etl/callback_timer_interrupt.h b/include/etl/callback_timer_interrupt.h index 11658707b..bc3fda5d7 100644 --- a/include/etl/callback_timer_interrupt.h +++ b/include/etl/callback_timer_interrupt.h @@ -221,7 +221,7 @@ namespace etl if (timer.id != etl::timer::id::NO_TIMER) { // Has a valid period. - if (timer.period != etl::timer::state::INACTIVE) + if (timer.period != etl::timer::state::Inactive) { TInterruptGuard guard; (void)guard; // Silence 'unused variable warnings. @@ -300,6 +300,19 @@ namespace etl return false; } + //******************************************* + /// Get the time to the next timer event. + //******************************************* + uint32_t time_to_next() const + { + TInterruptGuard guard; + (void)guard; // Silence 'unused variable warnings. + + uint32_t delta = active_list.front().delta; + + return delta; + } + protected: //************************************************************************* @@ -310,7 +323,7 @@ namespace etl timer_data() : callback() , period(0U) - , delta(etl::timer::state::INACTIVE) + , delta(etl::timer::state::Inactive) , id(etl::timer::id::NO_TIMER) , previous(etl::timer::id::NO_TIMER) , next(etl::timer::id::NO_TIMER) @@ -327,7 +340,7 @@ namespace etl bool repeating_) : callback(callback_) , period(period_) - , delta(etl::timer::state::INACTIVE) + , delta(etl::timer::state::Inactive) , id(id_) , previous(etl::timer::id::NO_TIMER) , next(etl::timer::id::NO_TIMER) @@ -340,7 +353,7 @@ namespace etl //******************************************* bool is_active() const { - return delta != etl::timer::state::INACTIVE; + return delta != etl::timer::state::Inactive; } //******************************************* @@ -348,7 +361,7 @@ namespace etl //******************************************* void set_inactive() { - delta = etl::timer::state::INACTIVE; + delta = etl::timer::state::Inactive; } callback_type callback; @@ -370,11 +383,11 @@ namespace etl /// Constructor. //******************************************* icallback_timer_interrupt(timer_data* const timer_array_, const uint_least8_t MAX_TIMERS_) - : timer_array(timer_array_), - active_list(timer_array_), - enabled(false), - number_of_registered_timers(0U), - MAX_TIMERS(MAX_TIMERS_) + : timer_array(timer_array_) + , active_list(timer_array_) + , enabled(false) + , number_of_registered_timers(0U) + , MAX_TIMERS(MAX_TIMERS_) { } @@ -501,8 +514,8 @@ namespace etl } timer.previous = etl::timer::id::NO_TIMER; - timer.next = etl::timer::id::NO_TIMER; - timer.delta = etl::timer::state::INACTIVE; + timer.next = etl::timer::id::NO_TIMER; + timer.delta = etl::timer::state::Inactive; } //******************************* @@ -511,6 +524,12 @@ namespace etl return ptimers[head]; } + //******************************* + const timer_data& front() const + { + return ptimers[head]; + } + //******************************* etl::timer::id::type begin() { @@ -544,8 +563,8 @@ namespace etl timer.next = etl::timer::id::NO_TIMER; } - head = etl::timer::id::NO_TIMER; - tail = etl::timer::id::NO_TIMER; + head = etl::timer::id::NO_TIMER; + tail = etl::timer::id::NO_TIMER; current = etl::timer::id::NO_TIMER; } diff --git a/include/etl/callback_timer_locked.h b/include/etl/callback_timer_locked.h index ab4dfa0ef..bfd6952c4 100644 --- a/include/etl/callback_timer_locked.h +++ b/include/etl/callback_timer_locked.h @@ -222,7 +222,7 @@ namespace etl if (timer.id != etl::timer::id::NO_TIMER) { // Has a valid period. - if (timer.period != etl::timer::state::INACTIVE) + if (timer.period != etl::timer::state::Inactive) { lock(); if (timer.is_active()) @@ -309,6 +309,18 @@ namespace etl unlock = unlock_; } + //******************************************* + /// Get the time to the next timer event. + //******************************************* + uint32_t time_to_next() const + { + lock(); + uint32_t delta = active_list.front().delta; + unlock(); + + return delta; + } + protected: //************************************************************************* @@ -319,7 +331,7 @@ namespace etl timer_data() : callback() , period(0U) - , delta(etl::timer::state::INACTIVE) + , delta(etl::timer::state::Inactive) , id(etl::timer::id::NO_TIMER) , previous(etl::timer::id::NO_TIMER) , next(etl::timer::id::NO_TIMER) @@ -336,7 +348,7 @@ namespace etl bool repeating_) : callback(callback_) , period(period_) - , delta(etl::timer::state::INACTIVE) + , delta(etl::timer::state::Inactive) , id(id_) , previous(etl::timer::id::NO_TIMER) , next(etl::timer::id::NO_TIMER) @@ -349,7 +361,7 @@ namespace etl //******************************************* bool is_active() const { - return delta != etl::timer::state::INACTIVE; + return delta != etl::timer::state::Inactive; } //******************************************* @@ -357,7 +369,7 @@ namespace etl //******************************************* void set_inactive() { - delta = etl::timer::state::INACTIVE; + delta = etl::timer::state::Inactive; } callback_type callback; @@ -511,7 +523,7 @@ namespace etl timer.previous = etl::timer::id::NO_TIMER; timer.next = etl::timer::id::NO_TIMER; - timer.delta = etl::timer::state::INACTIVE; + timer.delta = etl::timer::state::Inactive; } //******************************* @@ -520,6 +532,12 @@ namespace etl return ptimers[head]; } + //******************************* + const timer_data& front() const + { + return ptimers[head]; + } + //******************************* etl::timer::id::type begin() { diff --git a/include/etl/char_traits.h b/include/etl/char_traits.h index 19b985b8f..96e4cfe14 100644 --- a/include/etl/char_traits.h +++ b/include/etl/char_traits.h @@ -264,7 +264,7 @@ namespace etl /// Alternative strlen for all character types. //*************************************************************************** template - ETL_CONSTEXPR size_t strlen(const T* t) + ETL_CONSTEXPR14 size_t strlen(const T* t) { return etl::char_traits::length(t); } @@ -273,10 +273,97 @@ namespace etl /// Alternative strlen for all character types, with maximum length. //*************************************************************************** template - size_t strlen(const T* t, size_t max_length) + ETL_CONSTEXPR14 size_t strlen(const T* t, size_t max_length) { return etl::char_traits::length(t, max_length); } + + //*************************************************************************** + /// Alternative strcmp for all character types. + //*************************************************************************** + template + ETL_CONSTEXPR14 int strcmp(const T* t1, const T* t2) + { + while ((*t1 != 0) || (*t2 != 0)) + { + if (*t1 > *t2) + { + return 1; + } + + if (*t1 < *t2) + { + return -1; + } + + ++t1; + ++t2; + } + + return 0; + } + + //*************************************************************************** + /// Alternative strncmp for all character types. + //*************************************************************************** + template + ETL_CONSTEXPR14 int strncmp(const T* t1, const T* t2, size_t n) + { + while (((*t1 != 0) || (*t2 != 0)) && (n != 0)) + { + if (*t1 < *t2) + { + return -1; + } + else if (*t1 > *t2) + { + return 1; + } + + ++t1; + ++t2; + --n; + } + + return 0; + } + + //*************************************************************************** + /// Alternative strcpy for all character types. + //*************************************************************************** + template + ETL_CONSTEXPR14 T* strcpy(T* dst, const T* src) + { + T* result = dst; + + while (*src != 0) + { + *dst++ = *src++; + } + + *dst = 0; + + return result; + } + + //*************************************************************************** + /// Alternative strncpy for all character types. + //*************************************************************************** + template + ETL_CONSTEXPR14 T* strncpy(T* dst, const T* src, size_t n) + { + T* result = dst; + + while ((*src != 0) && (n != 0)) + { + *dst++ = *src++; + --n; + } + + *dst = 0; + + return result; + } } #endif diff --git a/include/etl/circular_buffer.h b/include/etl/circular_buffer.h index aa7eff18f..a099ca4a8 100644 --- a/include/etl/circular_buffer.h +++ b/include/etl/circular_buffer.h @@ -170,7 +170,7 @@ namespace etl size_type buffer_size; size_type in; ///< Index to the next write. size_type out; ///< Index to the next read. - ETL_DECLARE_DEBUG_COUNT ///< Internal debugging. + ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging. }; //*************************************************************************** @@ -933,7 +933,7 @@ namespace etl ETL_ASSERT(!empty(), ETL_ERROR(circular_buffer_empty)); pbuffer[out].~T(); increment_out(); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* @@ -956,7 +956,7 @@ namespace etl { in = 0U; out = 0U; - ETL_RESET_DEBUG_COUNT + ETL_RESET_DEBUG_COUNT; } else { diff --git a/include/etl/covariance.h b/include/etl/covariance.h index 8ecd80274..9769b79e1 100644 --- a/include/etl/covariance.h +++ b/include/etl/covariance.h @@ -35,7 +35,6 @@ SOFTWARE. #include "functional.h" #include "type_traits.h" -#include #include namespace etl diff --git a/include/etl/debug_count.h b/include/etl/debug_count.h index 2eeba5364..ebbfb13ef 100644 --- a/include/etl/debug_count.h +++ b/include/etl/debug_count.h @@ -42,15 +42,15 @@ SOFTWARE. #if defined(ETL_DEBUG_COUNT) - #define ETL_DECLARE_DEBUG_COUNT etl::debug_count etl_debug_count; + #define ETL_DECLARE_DEBUG_COUNT etl::debug_count etl_debug_count #define ETL_SET_DEBUG_COUNT(n) etl_debug_count.set(n) #define ETL_GET_DEBUG_COUNT etl_debug_count.get() - #define ETL_INCREMENT_DEBUG_COUNT ++etl_debug_count; - #define ETL_DECREMENT_DEBUG_COUNT --etl_debug_count; - #define ETL_ADD_DEBUG_COUNT(n) etl_debug_count += (n); - #define ETL_SUBTRACT_DEBUG_COUNT(n) etl_debug_count -= (n); - #define ETL_RESET_DEBUG_COUNT etl_debug_count.clear(); - #define ETL_OBJECT_RESET_DEBUG_COUNT(object) object.etl_debug_count.clear(); + #define ETL_INCREMENT_DEBUG_COUNT ++etl_debug_count + #define ETL_DECREMENT_DEBUG_COUNT --etl_debug_count + #define ETL_ADD_DEBUG_COUNT(n) etl_debug_count += (n) + #define ETL_SUBTRACT_DEBUG_COUNT(n) etl_debug_count -= (n) + #define ETL_RESET_DEBUG_COUNT etl_debug_count.clear() + #define ETL_OBJECT_RESET_DEBUG_COUNT(object) object.etl_debug_count.clear() #define ETL_OBJECT_GET_DEBUG_COUNT(object) object.etl_debug_count.get() namespace etl @@ -62,8 +62,6 @@ namespace etl /// Does nothing in a non-debug build. ///\ingroup reference //*************************************************************************** - - class debug_count { public: @@ -154,23 +152,29 @@ namespace etl }; } // namespace etl - inline void swap(etl::debug_count& lhs, etl::debug_count& rhs) { lhs.swap(rhs); } #else - #define ETL_DECLARE_DEBUG_COUNT - #define ETL_SET_DEBUG_COUNT(n) - #define ETL_GET_DEBUG_COUNT - #define ETL_INCREMENT_DEBUG_COUNT - #define ETL_DECREMENT_DEBUG_COUNT - #define ETL_ADD_DEBUG_COUNT(n) - #define ETL_SUBTRACT_DEBUG_COUNT(n) - #define ETL_RESET_DEBUG_COUNT - #define ETL_OBJECT_RESET_DEBUG_COUNT(object) - #define ETL_OBJECT_GET_DEBUG_COUNT(object) + #define ETL_DECLARE_DEBUG_COUNT etl::debug_count etl_debug_count + #define ETL_SET_DEBUG_COUNT(n) ETL_DO_NOTHING + #define ETL_GET_DEBUG_COUNT ETL_DO_NOTHING + #define ETL_INCREMENT_DEBUG_COUNT ETL_DO_NOTHING + #define ETL_DECREMENT_DEBUG_COUNT ETL_DO_NOTHING + #define ETL_ADD_DEBUG_COUNT(n) ETL_DO_NOTHING + #define ETL_SUBTRACT_DEBUG_COUNT(n) ETL_DO_NOTHING + #define ETL_RESET_DEBUG_COUNT ETL_DO_NOTHING + #define ETL_OBJECT_RESET_DEBUG_COUNT(object) ETL_DO_NOTHING + #define ETL_OBJECT_GET_DEBUG_COUNT(object) ETL_DO_NOTHING + +namespace etl +{ + class debug_count + { + }; +} #endif // ETL_DEBUG_COUNT #endif diff --git a/include/etl/deque.h b/include/etl/deque.h index 3406ae008..88984bdaf 100644 --- a/include/etl/deque.h +++ b/include/etl/deque.h @@ -214,7 +214,7 @@ namespace etl size_type current_size; ///< The current number of elements in the deque. const size_type CAPACITY; ///< The maximum number of elements in the deque. const size_type BUFFER_SIZE; ///< The number of elements in the buffer. - ETL_DECLARE_DEBUG_COUNT ///< Internal debugging. + ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging. }; //*************************************************************************** @@ -1074,7 +1074,7 @@ namespace etl --_begin; p = etl::addressof(*_begin); ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; position = _begin; } else if (insert_position == end()) @@ -1082,7 +1082,7 @@ namespace etl p = etl::addressof(*_end); ++_end; ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; position = _end - 1; } else @@ -1141,7 +1141,7 @@ namespace etl --_begin; p = etl::addressof(*_begin); ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; position = _begin; } else if (insert_position == end()) @@ -1149,7 +1149,7 @@ namespace etl p = etl::addressof(*_end); ++_end; ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; position = _end - 1; } else @@ -1206,7 +1206,7 @@ namespace etl --_begin; p = etl::addressof(*_begin); ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; position = _begin; } else if (insert_position == end()) @@ -1214,7 +1214,7 @@ namespace etl p = etl::addressof(*_end); ++_end; ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; position = _end - 1; } else @@ -1271,7 +1271,7 @@ namespace etl --_begin; p = etl::addressof(*_begin); ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; position = _begin; } else if (insert_position == end()) @@ -1279,7 +1279,7 @@ namespace etl p = etl::addressof(*_end); ++_end; ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; position = _end - 1; } else @@ -1336,7 +1336,7 @@ namespace etl --_begin; p = etl::addressof(*_begin); ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; position = _begin; } else if (insert_position == end()) @@ -1344,7 +1344,7 @@ namespace etl p = etl::addressof(*_end); ++_end; ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; position = _end - 1; } else @@ -1751,12 +1751,29 @@ namespace etl ::new (&(*_end)) T(etl::forward(args)...); ++_end; ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return back(); } #else + //************************************************************************* + /// Emplaces an item to the back of the deque. + /// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full. + //************************************************************************* + reference emplace_back() + { +#if defined(ETL_CHECK_PUSH_POP) + ETL_ASSERT(!full(), ETL_ERROR(deque_full)); +#endif + + ::new (&(*_end)) T(); + ++_end; + ++current_size; + ETL_INCREMENT_DEBUG_COUNT; + return back(); + } + //************************************************************************* /// Emplaces an item to the back of the deque. /// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full. @@ -1771,7 +1788,7 @@ namespace etl ::new (&(*_end)) T(value1); ++_end; ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return back(); } @@ -1789,7 +1806,7 @@ namespace etl ::new (&(*_end)) T(value1, value2); ++_end; ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return back(); } @@ -1807,7 +1824,7 @@ namespace etl ::new (&(*_end)) T(value1, value2, value3); ++_end; ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return back(); } @@ -1825,7 +1842,7 @@ namespace etl ::new (&(*_end)) T(value1, value2, value3, value4); ++_end; ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return back(); } #endif @@ -1884,12 +1901,29 @@ namespace etl --_begin; ::new (&(*_begin)) T(etl::forward(args)...); ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return front(); } #else + //************************************************************************* + /// Emplaces an item to the front of the deque. + /// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full. + //************************************************************************* + reference emplace_front() + { +#if defined(ETL_CHECK_PUSH_POP) + ETL_ASSERT(!full(), ETL_ERROR(deque_full)); +#endif + + --_begin; + ::new (&(*_begin)) T(); + ++current_size; + ETL_INCREMENT_DEBUG_COUNT; + return front(); + } + //************************************************************************* /// Emplaces an item to the front of the deque. /// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full. @@ -1904,7 +1938,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(value1); ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return front(); } @@ -1922,7 +1956,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(value1, value2); ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return front(); } @@ -1940,7 +1974,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(value1, value2, value3); ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return front(); } @@ -1958,7 +1992,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(value1, value2, value3, value4); ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return front(); } #endif @@ -2098,7 +2132,7 @@ namespace etl if ETL_IF_CONSTEXPR(etl::is_trivially_destructible::value) { current_size = 0; - ETL_RESET_DEBUG_COUNT + ETL_RESET_DEBUG_COUNT; } else { @@ -2137,7 +2171,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(); ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; } //********************************************************************* @@ -2161,7 +2195,7 @@ namespace etl ++item; ++from; ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; } while (--n != 0); } @@ -2173,7 +2207,7 @@ namespace etl ::new (&(*_end)) T(); ++_end; ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; } //********************************************************************* @@ -2184,7 +2218,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(value); ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; } //********************************************************************* @@ -2195,7 +2229,7 @@ namespace etl ::new (&(*_end)) T(value); ++_end; ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; } #if ETL_USING_CPP11 @@ -2207,7 +2241,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(etl::move(value)); ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; } //********************************************************************* @@ -2218,7 +2252,7 @@ namespace etl ::new (&(*_end)) T(etl::move(value)); ++_end; ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; } #endif @@ -2229,7 +2263,7 @@ namespace etl { (*_begin).~T(); --current_size; - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; ++_begin; } @@ -2241,7 +2275,7 @@ namespace etl --_end; (*_end).~T(); --current_size; - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* diff --git a/include/etl/error_handler.h b/include/etl/error_handler.h index 138970578..b08a0d4bc 100644 --- a/include/etl/error_handler.h +++ b/include/etl/error_handler.h @@ -268,22 +268,22 @@ namespace etl ///\ingroup error_handler //*************************************************************************** #if defined(ETL_NO_CHECKS) - #define ETL_ASSERT(b, e) // Does nothing. - #define ETL_ASSERT_OR_RETURN(b, e) // Does nothing. - #define ETL_ASSERT_OR_RETURN_VALUE(b, e, v) // Does nothing. + #define ETL_ASSERT(b, e) ETL_DO_NOTHING // Does nothing. + #define ETL_ASSERT_OR_RETURN(b, e) ETL_DO_NOTHING // Does nothing. + #define ETL_ASSERT_OR_RETURN_VALUE(b, e, v) ETL_DO_NOTHING // Does nothing. - #define ETL_ASSERT_FAIL(e) // Does nothing. - #define ETL_ASSERT_FAIL_AND_RETURN(e) // Does nothing. - #define ETL_ASSERT_FAIL_AND_RETURN_VALUE(e, v) // Does nothing. + #define ETL_ASSERT_FAIL(e) ETL_DO_NOTHING // Does nothing. + #define ETL_ASSERT_FAIL_AND_RETURN(e) ETL_DO_NOTHING // Does nothing. + #define ETL_ASSERT_FAIL_AND_RETURN_VALUE(e, v) ETL_DO_NOTHING // Does nothing. #elif ETL_USING_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_ASSERT_OR_RETURN(b, e) {if (!(b)) {etl::error_handler::error((e)); throw((e)); return;}} // If the condition fails, calls the error handler then throws an exception. - #define ETL_ASSERT_OR_RETURN_VALUE(b, e, v) {if (!(b)) {etl::error_handler::error((e)); throw((e)); return(v);}} // If the condition fails, calls the error handler then throws an exception. + #define ETL_ASSERT_OR_RETURN(b, e) {if (!(b)) {etl::error_handler::error((e)); throw((e)); return;}} // If the condition fails, calls the error handler then throws an exception. + #define ETL_ASSERT_OR_RETURN_VALUE(b, e, v) {if (!(b)) {etl::error_handler::error((e)); throw((e)); return(v);}} // If the condition fails, calls the error handler then throws an exception. #define ETL_ASSERT_FAIL(e) {etl::error_handler::error((e)); throw((e));} // Calls the error handler then throws an exception. #define ETL_ASSERT_FAIL_AND_RETURN(e) {etl::error_handler::error((e)); throw((e)); return;} // Calls the error handler then throws an exception. - #define ETL_ASSERT_FAIL_AND_RETURN_VALUE(e, v) {etl::error_handler::error((e)); throw((e)); return(v);} // Calls the error handler then throws an exception. + #define ETL_ASSERT_FAIL_AND_RETURN_VALUE(e, v) {etl::error_handler::error((e)); throw((e)); return(v);} // 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_ASSERT_OR_RETURN(b, e) {if (!(b)) {throw((e));}} // If the condition fails, throws an exception. @@ -297,8 +297,8 @@ namespace etl #else #if defined(ETL_LOG_ERRORS) #define ETL_ASSERT(b, e) {if(!(b)) {etl::error_handler::error((e));}} // If the condition fails, calls the error handler - #define ETL_ASSERT_OR_RETURN(b, e) {if(!(b)) {etl::error_handler::error((e)); return;}} // If the condition fails, calls the error handler and return - #define ETL_ASSERT_OR_RETURN_VALUE(b, e, v) {if(!(b)) {etl::error_handler::error((e)); return (v);}} // If the condition fails, calls the error handler and return a value + #define ETL_ASSERT_OR_RETURN(b, e) {if(!(b)) {etl::error_handler::error((e)); return;}} // If the condition fails, calls the error handler and return + #define ETL_ASSERT_OR_RETURN_VALUE(b, e, v) {if(!(b)) {etl::error_handler::error((e)); return (v);}} // If the condition fails, calls the error handler and return a value #define ETL_ASSERT_FAIL(e) {etl::error_handler::error((e));} // Calls the error handler #define ETL_ASSERT_FAIL_AND_RETURN(e) {etl::error_handler::error((e)); return;} // Calls the error handler and return @@ -306,8 +306,8 @@ namespace etl #else #if ETL_IS_DEBUG_BUILD #define ETL_ASSERT(b, e) assert((b)) // If the condition fails, asserts. - #define ETL_ASSERT_OR_RETURN(b, e) {if (!(b)) {assert(false); return;}} // If the condition fails, asserts and return. - #define ETL_ASSERT_OR_RETURN_VALUE(b, e, v) {if (!(b)) {assert(false); return(v);}} // If the condition fails, asserts and return a value. + #define ETL_ASSERT_OR_RETURN(b, e) {if (!(b)) {assert(false); return;}} // If the condition fails, asserts and return. + #define ETL_ASSERT_OR_RETURN_VALUE(b, e, v) {if (!(b)) {assert(false); return(v);}} // If the condition fails, asserts and return a value. #define ETL_ASSERT_FAIL(e) assert(false) // Asserts. #define ETL_ASSERT_FAIL_AND_RETURN(e) {assert(false); return;} // Asserts. diff --git a/include/etl/file_error_numbers.h b/include/etl/file_error_numbers.h index 1bc5bc5fb..a866ce417 100644 --- a/include/etl/file_error_numbers.h +++ b/include/etl/file_error_numbers.h @@ -102,5 +102,6 @@ SOFTWARE. #define ETL_TO_ARITHMETIC_FILE_ID "69" #define ETL_EXPECTED_FILE_ID "70" #define ETL_ALIGNMENT_FILE_ID "71" +#define ETL_BASE64_FILE_ID "72" #endif diff --git a/include/etl/flat_map.h b/include/etl/flat_map.h index 0cae36c42..e7fc5e647 100644 --- a/include/etl/flat_map.h +++ b/include/etl/flat_map.h @@ -444,7 +444,7 @@ namespace etl // Doesn't already exist? if ((i_element == end()) || compare(key, i_element->first)) { - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); } else @@ -478,7 +478,7 @@ namespace etl // Doesn't already exist? if ((i_element == end()) || compare(key, i_element->first)) { - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); } else @@ -510,7 +510,7 @@ namespace etl // Doesn't already exist? if ((i_element == end()) || compare(key, i_element->first)) { - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); } else @@ -542,7 +542,7 @@ namespace etl // Doesn't already exist? if ((i_element == end()) || compare(key, i_element->first)) { - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); } else @@ -574,7 +574,7 @@ namespace etl // Doesn't already exist? if ((i_element == end()) || compare(key, i_element->first)) { - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); } else @@ -606,7 +606,7 @@ namespace etl i_element->~value_type(); storage.release(etl::addressof(*i_element)); refmap_t::erase(i_element); - ETL_DECREMENT_DEBUG_COUNT; + ETL_DECREMENT_DEBUG_COUNT;; return 1; } } @@ -627,7 +627,7 @@ namespace etl i_element->~value_type(); storage.release(etl::addressof(*i_element)); refmap_t::erase(i_element); - ETL_DECREMENT_DEBUG_COUNT; + ETL_DECREMENT_DEBUG_COUNT;; return 1; } } @@ -641,7 +641,7 @@ namespace etl { i_element->~value_type(); storage.release(etl::addressof(*i_element)); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; return refmap_t::erase(i_element); } @@ -653,7 +653,7 @@ namespace etl { i_element->~value_type(); storage.release(etl::addressof(*i_element)); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; return refmap_t::erase(i_element); } @@ -673,7 +673,7 @@ namespace etl itr->~value_type(); storage.release(etl::addressof(*itr)); ++itr; - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } return refmap_t::erase(first, last); @@ -700,7 +700,7 @@ namespace etl } } - ETL_RESET_DEBUG_COUNT + ETL_RESET_DEBUG_COUNT; refmap_t::clear(); } @@ -1019,7 +1019,7 @@ namespace etl TKeyCompare compare; /// Internal debugging. - ETL_DECLARE_DEBUG_COUNT + ETL_DECLARE_DEBUG_COUNT; #if ETL_USING_CPP11 //************************************************************************* @@ -1030,7 +1030,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(etl::forward(value)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } #else @@ -1041,7 +1041,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(value_type(value)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } #endif @@ -1055,7 +1055,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new ((void*)etl::addressof(pvalue->first)) key_type(etl::move(key)); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } @@ -1069,7 +1069,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } diff --git a/include/etl/flat_multimap.h b/include/etl/flat_multimap.h index a3c6f7486..48631585c 100644 --- a/include/etl/flat_multimap.h +++ b/include/etl/flat_multimap.h @@ -267,7 +267,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(value); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); return result; @@ -289,7 +289,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(etl::move(value)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); return result; @@ -357,7 +357,7 @@ namespace etl ::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(mapped); iterator i_element = upper_bound(key); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } @@ -376,7 +376,7 @@ namespace etl ::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(etl::forward(args)...); iterator i_element = upper_bound(key); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } @@ -395,7 +395,7 @@ namespace etl ::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1); iterator i_element = upper_bound(key); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } @@ -413,7 +413,7 @@ namespace etl ::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1, value2); iterator i_element = upper_bound(key); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } @@ -431,7 +431,7 @@ namespace etl ::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1, value2, value3); iterator i_element = upper_bound(key); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } @@ -449,7 +449,7 @@ namespace etl ::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1, value2, value3, value4); iterator i_element = upper_bound(key); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } @@ -505,7 +505,7 @@ namespace etl { i_element->~value_type(); storage.release(etl::addressof(*i_element)); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; return refmap_t::erase(i_element); } @@ -517,7 +517,7 @@ namespace etl { i_element->~value_type(); storage.release(etl::addressof(*i_element)); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; return refmap_t::erase(i_element); } @@ -537,7 +537,7 @@ namespace etl itr->~value_type(); storage.release(etl::addressof(*itr)); ++itr; - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } return refmap_t::erase(first, last); @@ -564,7 +564,7 @@ namespace etl } } - ETL_RESET_DEBUG_COUNT + ETL_RESET_DEBUG_COUNT; refmap_t::clear(); } @@ -881,7 +881,7 @@ namespace etl storage_t& storage; /// Internal debugging. - ETL_DECLARE_DEBUG_COUNT + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/flat_multiset.h b/include/etl/flat_multiset.h index 2f35babef..2ab5172b7 100644 --- a/include/etl/flat_multiset.h +++ b/include/etl/flat_multiset.h @@ -237,7 +237,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(value); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); return result; @@ -259,7 +259,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(etl::move(value)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); return result; @@ -319,7 +319,7 @@ namespace etl //************************************************************************* /// Emplaces a value to the set. //************************************************************************* -#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT +#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_FLAT_MULTISET_FORCE_CPP03_IMPLEMENTATION) template ETL_OR_STD::pair emplace(Args && ... args) { @@ -331,10 +331,27 @@ namespace etl iterator i_element = upper_bound(*pvalue); - ETL_INCREMENT_DEBUG_COUNT - return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); + ETL_INCREMENT_DEBUG_COUNT; + return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); } #else + //************************************************************************* + /// Emplaces a value to the set. + //************************************************************************* + ETL_OR_STD::pair emplace() + { + ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full)); + + // Create it. + value_type* pvalue = storage.allocate(); + ::new (pvalue) value_type(); + + iterator i_element = upper_bound(*pvalue); + + ETL_INCREMENT_DEBUG_COUNT; + return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); + } + //************************************************************************* /// Emplaces a value to the set. //************************************************************************* @@ -349,8 +366,8 @@ namespace etl iterator i_element = upper_bound(*pvalue); - ETL_INCREMENT_DEBUG_COUNT - return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); + ETL_INCREMENT_DEBUG_COUNT; + return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); } //************************************************************************* @@ -367,8 +384,8 @@ namespace etl iterator i_element = upper_bound(*pvalue); - ETL_INCREMENT_DEBUG_COUNT - return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); + ETL_INCREMENT_DEBUG_COUNT; + return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); } //************************************************************************* @@ -385,8 +402,8 @@ namespace etl iterator i_element = upper_bound(*pvalue); - ETL_INCREMENT_DEBUG_COUNT - return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); + ETL_INCREMENT_DEBUG_COUNT; + return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); } //************************************************************************* @@ -403,8 +420,8 @@ namespace etl iterator i_element = upper_bound(*pvalue); - ETL_INCREMENT_DEBUG_COUNT - return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); + ETL_INCREMENT_DEBUG_COUNT; + return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); } #endif @@ -457,7 +474,7 @@ namespace etl { etl::destroy_at(etl::addressof(*i_element)); storage.release(etl::addressof(*i_element)); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; return refset_t::erase(i_element); } @@ -469,7 +486,7 @@ namespace etl { etl::destroy_at(etl::addressof(*i_element)); storage.release(etl::addressof(*i_element)); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; return refset_t::erase(i_element); } @@ -489,7 +506,7 @@ namespace etl etl::destroy_at(etl::addressof(*itr)); storage.release(etl::addressof(*itr)); ++itr; - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } return refset_t::erase(first, last); @@ -516,7 +533,7 @@ namespace etl } } - ETL_RESET_DEBUG_COUNT + ETL_RESET_DEBUG_COUNT; refset_t::clear(); } @@ -835,7 +852,7 @@ namespace etl TKeyCompare compare; /// Internal debugging. - ETL_DECLARE_DEBUG_COUNT + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/flat_set.h b/include/etl/flat_set.h index a0d839e26..c24724c7a 100644 --- a/include/etl/flat_set.h +++ b/include/etl/flat_set.h @@ -240,7 +240,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(value); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); } @@ -266,7 +266,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(etl::move(value)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); } @@ -326,7 +326,7 @@ namespace etl //************************************************************************* /// Emplaces a value to the set. //************************************************************************* -#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT +#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_FLAT_SET_FORCE_CPP03_IMPLEMENTATION) template ETL_OR_STD::pair emplace(Args && ... args) { @@ -343,7 +343,7 @@ namespace etl // Doesn't already exist? if ((i_element == end()) || compare(*pvalue, *i_element)) { - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); } else @@ -357,6 +357,38 @@ namespace etl return result; } #else + //************************************************************************* + /// Emplaces a value to the set. + //************************************************************************* + ETL_OR_STD::pair emplace() + { + ETL_ASSERT(!full(), ETL_ERROR(flat_set_full)); + + ETL_OR_STD::pair result; + + // Create it. + value_type* pvalue = storage.allocate(); + ::new (pvalue) value_type(); + + iterator i_element = lower_bound(*pvalue); + + // Doesn't already exist? + if ((i_element == end()) || compare(*pvalue, *i_element)) + { + ETL_INCREMENT_DEBUG_COUNT; + result = refset_t::insert_at(i_element, *pvalue); + } + else + { + // Destroy it. + pvalue->~value_type(); + storage.release(pvalue); + result = ETL_OR_STD::pair(end(), false); + } + + return result; + } + //************************************************************************* /// Emplaces a value to the set. //************************************************************************* @@ -376,7 +408,7 @@ namespace etl // Doesn't already exist? if ((i_element == end()) || compare(*pvalue, *i_element)) { - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); } else @@ -409,7 +441,7 @@ namespace etl // Doesn't already exist? if ((i_element == end()) || compare(*pvalue, *i_element)) { - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); } else @@ -442,7 +474,7 @@ namespace etl // Doesn't already exist? if ((i_element == end()) || compare(*pvalue, *i_element)) { - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); } else @@ -475,7 +507,7 @@ namespace etl // Doesn't already exist? if ((i_element == end()) || compare(*pvalue, *i_element)) { - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); } else @@ -508,7 +540,7 @@ namespace etl etl::destroy_at(etl::addressof(*i_element)); storage.release(etl::addressof(*i_element)); refset_t::erase(i_element); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; return 1; } } @@ -529,7 +561,7 @@ namespace etl etl::destroy_at(etl::addressof(*i_element)); storage.release(etl::addressof(*i_element)); refset_t::erase(i_element); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; return 1; } } @@ -543,7 +575,7 @@ namespace etl { etl::destroy_at(etl::addressof(*i_element)); storage.release(etl::addressof(*i_element)); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; return refset_t::erase(i_element); } @@ -555,7 +587,7 @@ namespace etl { etl::destroy_at(etl::addressof(*i_element)); storage.release(etl::addressof(*i_element)); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; return refset_t::erase(i_element); } @@ -575,7 +607,7 @@ namespace etl etl::destroy_at(etl::addressof(*itr)); storage.release(etl::addressof(*itr)); ++itr; - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } return refset_t::erase(first, last); @@ -599,11 +631,11 @@ namespace etl etl::destroy_at(etl::addressof(*itr)); storage.release(etl::addressof(*itr)); ++itr; - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } } - ETL_RESET_DEBUG_COUNT + ETL_RESET_DEBUG_COUNT; refset_t::clear(); } @@ -922,7 +954,7 @@ namespace etl TKeyCompare compare; /// Internal debugging. - ETL_DECLARE_DEBUG_COUNT + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index c149ada35..25b174845 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -352,7 +352,7 @@ namespace etl etl::ipool* p_node_pool; ///< The pool of data nodes used in the list. size_type MAX_SIZE; ///< The maximum size of the forward_list. bool pool_is_shared; ///< If true then the pool is shared between lists. - ETL_DECLARE_DEBUG_COUNT ///< Internal debugging. + ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging. }; //*************************************************************************** @@ -717,7 +717,7 @@ namespace etl } #endif -#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT +#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_FORWARD_LIST_FORCE_CPP03_IMPLEMENTATION) //************************************************************************* /// Emplaces a value to the front of the list.. //************************************************************************* @@ -729,11 +729,26 @@ namespace etl #endif data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(etl::forward(args)...); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(start_node, *p_data_node); return front(); } #else + //************************************************************************* + /// Emplaces a value to the front of the list.. + //************************************************************************* + reference emplace_front() + { +#if defined(ETL_CHECK_PUSH_POP) + ETL_ASSERT(!full(), ETL_ERROR(forward_list_full)); +#endif + data_node_t* p_data_node = allocate_data_node(); + ::new (&(p_data_node->value)) T(); + ETL_INCREMENT_DEBUG_COUNT; + insert_node_after(start_node, *p_data_node); + return front(); + } + //************************************************************************* /// Emplaces a value to the front of the list.. //************************************************************************* @@ -745,7 +760,7 @@ namespace etl #endif data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(start_node, *p_data_node); return front(); } @@ -761,7 +776,7 @@ namespace etl #endif data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1, value2); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(start_node, *p_data_node); return front(); } @@ -777,7 +792,7 @@ namespace etl #endif data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1, value2, value3); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(start_node, *p_data_node); return front(); } @@ -793,7 +808,7 @@ namespace etl #endif data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1, value2, value3, value4); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(start_node, *p_data_node); return front(); } @@ -879,7 +894,7 @@ namespace etl return iterator(&data_node); } -#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT +#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_FORWARD_LIST_FORCE_CPP03_IMPLEMENTATION) //************************************************************************* /// Emplaces a value to the forward_list after the specified position. //************************************************************************* @@ -890,12 +905,27 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(etl::forward(args)...); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(*to_iterator(position).p_node, *p_data_node); return iterator(p_data_node); } #else + //************************************************************************* + /// Emplaces a value to the forward_list after the specified position. + //************************************************************************* + iterator emplace_after(const_iterator position) + { + ETL_ASSERT(!full(), ETL_ERROR(forward_list_full)); + + data_node_t* p_data_node = allocate_data_node(); + ::new (&(p_data_node->value)) T(); + ETL_INCREMENT_DEBUG_COUNT; + insert_node_after(*to_iterator(position).p_node, *p_data_node); + + return iterator(p_data_node); + } + //************************************************************************* /// Emplaces a value to the forward_list after the specified position. //************************************************************************* @@ -906,8 +936,8 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1); - ETL_INCREMENT_DEBUG_COUNT - insert_node_after(*position.p_node, *p_data_node); + ETL_INCREMENT_DEBUG_COUNT; + insert_node_after(*to_iterator(position).p_node, *p_data_node); return iterator(p_data_node); } @@ -922,8 +952,8 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1, value2); - ETL_INCREMENT_DEBUG_COUNT - insert_node_after(*position.p_node, *p_data_node); + ETL_INCREMENT_DEBUG_COUNT; + insert_node_after(*to_iterator(position).p_node, *p_data_node); return iterator(p_data_node); } @@ -938,8 +968,8 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1, value2, value3); - ETL_INCREMENT_DEBUG_COUNT - insert_node_after(*position.p_node, *p_data_node); + ETL_INCREMENT_DEBUG_COUNT; + insert_node_after(*to_iterator(position).p_node, *p_data_node); return iterator(p_data_node); } @@ -954,8 +984,8 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1, value2, value3, value4); - ETL_INCREMENT_DEBUG_COUNT - insert_node_after(*position.p_node, *p_data_node); + ETL_INCREMENT_DEBUG_COUNT; + insert_node_after(*to_iterator(position).p_node, *p_data_node); return iterator(p_data_node); } @@ -1432,7 +1462,7 @@ namespace etl { ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(forward_list_no_pool)); p_node_pool->release_all(); - ETL_RESET_DEBUG_COUNT + ETL_RESET_DEBUG_COUNT; } else { @@ -1459,7 +1489,7 @@ namespace etl { data_node_t* p_node = allocate_data_node(); ::new (&(p_node->value)) T(value); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return *p_node; } @@ -1472,7 +1502,7 @@ namespace etl { data_node_t* p_node = allocate_data_node(); ::new (&(p_node->value)) T(etl::move(value)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return *p_node; } @@ -1595,7 +1625,7 @@ namespace etl { node.value.~T(); p_node_pool->release(&node); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } // Disable copy construction. diff --git a/include/etl/fsm.h b/include/etl/fsm.h index 19b3bb55d..19584a911 100644 --- a/include/etl/fsm.h +++ b/include/etl/fsm.h @@ -182,6 +182,9 @@ namespace etl // Pass this when this event also needs to be passed to the parent. static ETL_CONSTANT fsm_state_id_t Pass_To_Parent = No_State_Change - 1U; + + // Pass this when this event should trigger a self transition. + static ETL_CONSTANT fsm_state_id_t Self_Transition = No_State_Change - 2U; }; template @@ -189,6 +192,9 @@ namespace etl template ETL_CONSTANT fsm_state_id_t ifsm_state_helper::Pass_To_Parent; + + template + ETL_CONSTANT fsm_state_id_t ifsm_state_helper::Self_Transition; } //*************************************************************************** @@ -204,6 +210,7 @@ namespace etl using private_fsm::ifsm_state_helper<>::No_State_Change; using private_fsm::ifsm_state_helper<>::Pass_To_Parent; + using private_fsm::ifsm_state_helper<>::Self_Transition; #if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION) // For C++17 and above template @@ -418,6 +425,11 @@ namespace etl } } while (p_next_state != p_state); // Have we changed state again? } + else if (is_self_transition(next_state_id)) + { + p_state->on_exit_state(); + p_state->on_enter_state(); + } } using imessage_router::accepts; @@ -504,7 +516,14 @@ namespace etl bool have_changed_state(etl::fsm_state_id_t next_state_id) const { return (next_state_id != p_state->get_state_id()) && - (next_state_id != ifsm_state::No_State_Change); + (next_state_id != ifsm_state::No_State_Change) && + (next_state_id != ifsm_state::Self_Transition); + } + + //******************************************** + bool is_self_transition(etl::fsm_state_id_t next_state_id) const + { + return (next_state_id == ifsm_state::Self_Transition); } etl::ifsm_state* p_state; ///< A pointer to the current state. diff --git a/include/etl/generators/fsm_generator.h b/include/etl/generators/fsm_generator.h index 6b5d6e99d..a59d1fa1f 100644 --- a/include/etl/generators/fsm_generator.h +++ b/include/etl/generators/fsm_generator.h @@ -201,6 +201,9 @@ namespace etl // Pass this when this event also needs to be passed to the parent. static ETL_CONSTANT fsm_state_id_t Pass_To_Parent = No_State_Change - 1U; + + // Pass this when this event should trigger a self transition. + static ETL_CONSTANT fsm_state_id_t Self_Transition = No_State_Change - 2U; }; template @@ -208,6 +211,9 @@ namespace etl template ETL_CONSTANT fsm_state_id_t ifsm_state_helper::Pass_To_Parent; + + template + ETL_CONSTANT fsm_state_id_t ifsm_state_helper::Self_Transition; } //*************************************************************************** @@ -223,6 +229,7 @@ namespace etl using private_fsm::ifsm_state_helper<>::No_State_Change; using private_fsm::ifsm_state_helper<>::Pass_To_Parent; + using private_fsm::ifsm_state_helper<>::Self_Transition; #if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION) // For C++17 and above template @@ -444,6 +451,11 @@ namespace etl } } while (p_next_state != p_state); // Have we changed state again? } + else if (is_self_transition(next_state_id)) + { + p_state->on_exit_state(); + p_state->on_enter_state(); + } } using imessage_router::accepts; @@ -530,7 +542,14 @@ namespace etl bool have_changed_state(etl::fsm_state_id_t next_state_id) const { return (next_state_id != p_state->get_state_id()) && - (next_state_id != ifsm_state::No_State_Change); + (next_state_id != ifsm_state::No_State_Change) && + (next_state_id != ifsm_state::Self_Transition); + } + + //******************************************** + bool is_self_transition(etl::fsm_state_id_t next_state_id) const + { + return (next_state_id == ifsm_state::Self_Transition); } etl::ifsm_state* p_state; ///< A pointer to the current state. diff --git a/include/etl/generators/largest_generator.h b/include/etl/generators/largest_generator.h index 40307bf23..a8cb40837 100644 --- a/include/etl/generators/largest_generator.h +++ b/include/etl/generators/largest_generator.h @@ -140,7 +140,7 @@ namespace etl cog.outl("/// Supports up to %s types." % NTypes) cog.outl("/// Defines 'value_type' which is the type of the largest parameter.") cog.outl("/// Defines 'size' which is the size of the largest parameter.") - cog.outl("///\ingroup largest") + cog.outl("///\\ingroup largest") cog.outl("//***************************************************************************") cog.out("template value which is the largest alignment of all the parameters.") - cog.outl("///\ingroup largest") + cog.outl("///\\ingroup largest") cog.outl("//***************************************************************************") cog.out("template struct larger_int_type @@ -407,7 +407,7 @@ namespace etl cog.outl("/// Template to determine the largest type, size and alignment.") cog.outl("/// Supports up to %s types." % NTypes) cog.outl("/// Defines value which is the largest type, size and alignment of all the parameters.") - cog.outl("///\ingroup largest") + cog.outl("///\\ingroup largest") cog.outl("//***************************************************************************") cog.out("template explicit message_packet(T&& msg) : valid(true) @@ -138,7 +142,7 @@ namespace etl ETL_STATIC_ASSERT(IsInMessageList, "Message not in packet type list"); } } -#include "etl/private/diagnostic_pop.h" +#include "private/diagnostic_pop.h" //********************************************** void copy(const message_packet& other) @@ -163,7 +167,7 @@ namespace etl } //********************************************** -#include "etl/private/diagnostic_uninitialized_push.h" +#include "private/diagnostic_uninitialized_push.h" message_packet& operator =(const message_packet& rhs) { delete_current_message(); @@ -175,10 +179,10 @@ namespace etl return *this; } -#include "etl/private/diagnostic_pop.h" +#include "private/diagnostic_pop.h" //********************************************** -#include "etl/private/diagnostic_uninitialized_push.h" +#include "private/diagnostic_uninitialized_push.h" message_packet& operator =(message_packet&& rhs) { delete_current_message(); @@ -190,7 +194,7 @@ namespace etl return *this; } -#include "etl/private/diagnostic_pop.h" +#include "private/diagnostic_pop.h" //******************************************** ~message_packet() @@ -267,7 +271,7 @@ namespace etl } //******************************************** -#include "etl/private/diagnostic_uninitialized_push.h" +#include "private/diagnostic_uninitialized_push.h" void delete_current_message() { if (valid) @@ -277,7 +281,7 @@ namespace etl pmsg->~imessage(); } } -#include "etl/private/diagnostic_pop.h" +#include "private/diagnostic_pop.h" //******************************************** void add_new_message(const etl::imessage& msg) @@ -291,7 +295,7 @@ namespace etl (add_new_message_type(etl::move(msg)) || ...); } -#include "etl/private/diagnostic_uninitialized_push.h" +#include "private/diagnostic_uninitialized_push.h" //******************************************** /// Only enabled for types that are in the typelist. //******************************************** @@ -302,9 +306,9 @@ namespace etl void* p = data; new (p) etl::remove_reference_t((etl::forward(msg))); } -#include "etl/private/diagnostic_pop.h" +#include "private/diagnostic_pop.h" -#include "etl/private/diagnostic_uninitialized_push.h" +#include "private/diagnostic_uninitialized_push.h" //******************************************** template bool add_new_message_type(const etl::imessage& msg) @@ -320,7 +324,7 @@ namespace etl return false; } } -#include "etl/private/diagnostic_pop.h" +#include "private/diagnostic_pop.h" //******************************************** template @@ -394,9 +398,9 @@ namespace etl cog.out(" etl::is_one_of::type,") for i in range(1, n): cog.out("T%d, " % i) - cog.outl("T%s>::value);" % n) + cog.outl("T%s>::value);" % n) cog.outl("") - cog.outl(" ETL_STATIC_ASSERT(Enabled, \"Message not in packet type list\");") + cog.outl(" ETL_STATIC_ASSERT(Enabled, \"Message not in packet type list\");") ################################################ def generate_static_assert_cpp11(n): @@ -432,15 +436,15 @@ namespace etl cog.outl("public:") cog.outl("") cog.outl(" //********************************************") - cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl("#include \"private/diagnostic_uninitialized_push.h\"") cog.outl(" message_packet()") cog.outl(" : valid(false)") cog.outl(" {") cog.outl(" }") - cog.outl("#include \"etl/private/diagnostic_pop.h\"") + cog.outl("#include \"private/diagnostic_pop.h\"") cog.outl("") cog.outl(" //********************************************") - cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl("#include \"private/diagnostic_uninitialized_push.h\"") cog.outl(" explicit message_packet(const etl::imessage& msg)") cog.outl(" {") cog.outl(" if (accepts(msg))") @@ -455,11 +459,11 @@ namespace etl cog.outl("") cog.outl(" ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception));") cog.outl(" }") - cog.outl("#include \"etl/private/diagnostic_pop.h\"") + cog.outl("#include \"private/diagnostic_pop.h\"") cog.outl("") cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)") cog.outl(" //********************************************") - cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl("#include \"private/diagnostic_uninitialized_push.h\"") cog.outl(" explicit message_packet(etl::imessage&& msg)") cog.outl(" {") cog.outl(" if (accepts(msg))") @@ -474,12 +478,12 @@ namespace etl cog.outl("") cog.outl(" ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception));") cog.outl(" }") - cog.outl("#include \"etl/private/diagnostic_pop.h\"") + cog.outl("#include \"private/diagnostic_pop.h\"") cog.outl("#endif") cog.outl("") cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS)") cog.outl(" //********************************************") - cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl("#include \"private/diagnostic_uninitialized_push.h\"") cog.out(" template ::type, etl::message_packet<") for n in range(1, int(Handlers)): cog.out("T%s, " % n) @@ -494,10 +498,10 @@ namespace etl cog.outl(" {") generate_static_assert_cpp11(int(Handlers)) cog.outl(" }") - cog.outl("#include \"etl/private/diagnostic_pop.h\"") + cog.outl("#include \"private/diagnostic_pop.h\"") cog.outl("#else") cog.outl(" //********************************************") - cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl("#include \"private/diagnostic_uninitialized_push.h\"") cog.outl(" template ") cog.out(" explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if::type, etl::message_packet<") for n in range(1, int(Handlers)): @@ -512,11 +516,11 @@ namespace etl cog.outl(" {") generate_static_assert_cpp03(int(Handlers)) cog.outl(" }") - cog.outl("#include \"etl/private/diagnostic_pop.h\"") + cog.outl("#include \"private/diagnostic_pop.h\"") cog.outl("#endif") cog.outl("") cog.outl(" //**********************************************") - cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl("#include \"private/diagnostic_uninitialized_push.h\"") cog.outl(" message_packet(const message_packet& other)") cog.outl(" : valid(other.is_valid())") cog.outl(" {") @@ -525,11 +529,11 @@ namespace etl cog.outl(" add_new_message(other.get());") cog.outl(" }") cog.outl(" }") - cog.outl("#include \"etl/private/diagnostic_pop.h\"") + cog.outl("#include \"private/diagnostic_pop.h\"") cog.outl("") cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)") cog.outl(" //**********************************************") - cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl("#include \"private/diagnostic_uninitialized_push.h\"") cog.outl(" message_packet(message_packet&& other)") cog.outl(" : valid(other.is_valid())") cog.outl(" {") @@ -538,11 +542,11 @@ namespace etl cog.outl(" add_new_message(etl::move(other.get()));") cog.outl(" }") cog.outl(" }") - cog.outl("#include \"etl/private/diagnostic_pop.h\"") + cog.outl("#include \"private/diagnostic_pop.h\"") cog.outl("#endif") cog.outl("") cog.outl(" //**********************************************") - cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl("#include \"private/diagnostic_uninitialized_push.h\"") cog.outl(" message_packet& operator =(const message_packet& rhs)") cog.outl(" {") cog.outl(" delete_current_message();") @@ -554,11 +558,11 @@ namespace etl cog.outl("") cog.outl(" return *this;") cog.outl(" }") - cog.outl("#include \"etl/private/diagnostic_pop.h\"") + cog.outl("#include \"private/diagnostic_pop.h\"") cog.outl("") cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)") cog.outl(" //**********************************************") - cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl("#include \"private/diagnostic_uninitialized_push.h\"") cog.outl(" message_packet& operator =(message_packet&& rhs)") cog.outl(" {") cog.outl(" delete_current_message();") @@ -570,7 +574,7 @@ namespace etl cog.outl("") cog.outl(" return *this;") cog.outl(" }") - cog.outl("#include \"etl/private/diagnostic_pop.h\"") + cog.outl("#include \"private/diagnostic_pop.h\"") cog.outl("#endif") cog.outl("") cog.outl(" //********************************************") @@ -624,7 +628,7 @@ namespace etl cog.outl(" {") generate_accepts_return_compile_time_TMessage(int(Handlers)) cog.outl(" }") - cog.outl("") + cog.outl("") cog.outl(" enum") cog.outl(" {") cog.out(" SIZE = etl::largest<") @@ -640,7 +644,7 @@ namespace etl cog.outl("private:") cog.outl("") cog.outl(" //********************************************") - cog.outl(" #include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"") cog.outl(" void delete_current_message()") cog.outl(" {") cog.outl(" if (valid)") @@ -650,7 +654,7 @@ namespace etl cog.outl(" pmsg->~imessage();") cog.outl(" }") cog.outl(" }") - cog.outl(" #include \"etl/private/diagnostic_pop.h\"") + cog.outl(" #include \"private/diagnostic_pop.h\"") cog.outl("") cog.outl(" //********************************************") cog.outl(" void add_new_message(const etl::imessage& msg)") @@ -720,15 +724,15 @@ namespace etl cog.outl("public:") cog.outl("") cog.outl(" //********************************************") - cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl("#include \"private/diagnostic_uninitialized_push.h\"") cog.outl(" message_packet()") cog.outl(" : valid(false)") cog.outl(" {") cog.outl(" }") - cog.outl("#include \"etl/private/diagnostic_pop.h\"") + cog.outl("#include \"private/diagnostic_pop.h\"") cog.outl("") cog.outl(" //********************************************") - cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl("#include \"private/diagnostic_uninitialized_push.h\"") cog.outl(" explicit message_packet(const etl::imessage& msg)") cog.outl(" {") cog.outl(" if (accepts(msg))") @@ -743,11 +747,11 @@ namespace etl cog.outl("") cog.outl(" ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception));") cog.outl(" }") - cog.outl("#include \"etl/private/diagnostic_pop.h\"") + cog.outl("#include \"private/diagnostic_pop.h\"") cog.outl("") cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)") cog.outl(" //********************************************") - cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl("#include \"private/diagnostic_uninitialized_push.h\"") cog.outl(" explicit message_packet(etl::imessage&& msg)") cog.outl(" {") cog.outl(" if (accepts(msg))") @@ -762,12 +766,12 @@ namespace etl cog.outl("") cog.outl(" ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception));") cog.outl(" }") - cog.outl("#include \"etl/private/diagnostic_pop.h\"") + cog.outl("#include \"private/diagnostic_pop.h\"") cog.outl("#endif") cog.outl("") cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS)") cog.outl(" //********************************************") - cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl("#include \"private/diagnostic_uninitialized_push.h\"") cog.out(" template ::type, etl::message_packet<") for t in range(1, n): cog.out("T%s, " % t) @@ -782,10 +786,10 @@ namespace etl cog.outl(" {") generate_static_assert_cpp11(n) cog.outl(" }") - cog.outl("#include \"etl/private/diagnostic_pop.h\"") + cog.outl("#include \"private/diagnostic_pop.h\"") cog.outl("#else") cog.outl(" //********************************************") - cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl("#include \"private/diagnostic_uninitialized_push.h\"") cog.outl(" template ") cog.out(" explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if::type, etl::message_packet<") for t in range(1, n): @@ -800,11 +804,11 @@ namespace etl cog.outl(" {") generate_static_assert_cpp03(n) cog.outl(" }") - cog.outl("#include \"etl/private/diagnostic_pop.h\"") + cog.outl("#include \"private/diagnostic_pop.h\"") cog.outl("#endif") cog.outl("") cog.outl(" //**********************************************") - cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl("#include \"private/diagnostic_uninitialized_push.h\"") cog.outl(" message_packet(const message_packet& other)") cog.outl(" : valid(other.is_valid())") cog.outl(" {") @@ -813,11 +817,11 @@ namespace etl cog.outl(" add_new_message(other.get());") cog.outl(" }") cog.outl(" }") - cog.outl("#include \"etl/private/diagnostic_pop.h\"") + cog.outl("#include \"private/diagnostic_pop.h\"") cog.outl("") cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)") cog.outl(" //**********************************************") - cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl("#include \"private/diagnostic_uninitialized_push.h\"") cog.outl(" message_packet(message_packet&& other)") cog.outl(" : valid(other.is_valid())") cog.outl(" {") @@ -826,11 +830,11 @@ namespace etl cog.outl(" add_new_message(etl::move(other.get()));") cog.outl(" }") cog.outl(" }") - cog.outl("#include \"etl/private/diagnostic_pop.h\"") + cog.outl("#include \"private/diagnostic_pop.h\"") cog.outl("#endif") cog.outl("") cog.outl(" //**********************************************") - cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl("#include \"private/diagnostic_uninitialized_push.h\"") cog.outl(" message_packet& operator =(const message_packet& rhs)") cog.outl(" {") cog.outl(" delete_current_message();") @@ -842,11 +846,11 @@ namespace etl cog.outl("") cog.outl(" return *this;") cog.outl(" }") - cog.outl("#include \"etl/private/diagnostic_pop.h\"") + cog.outl("#include \"private/diagnostic_pop.h\"") cog.outl("") cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)") cog.outl(" //**********************************************") - cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl("#include \"private/diagnostic_uninitialized_push.h\"") cog.outl(" message_packet& operator =(message_packet&& rhs)") cog.outl(" {") cog.outl(" delete_current_message();") @@ -858,7 +862,7 @@ namespace etl cog.outl("") cog.outl(" return *this;") cog.outl(" }") - cog.outl("#include \"etl/private/diagnostic_pop.h\"") + cog.outl("#include \"private/diagnostic_pop.h\"") cog.outl("#endif") cog.outl("") cog.outl(" //********************************************") @@ -928,7 +932,7 @@ namespace etl cog.outl("private:") cog.outl("") cog.outl(" //********************************************") - cog.outl(" #include \"etl/private/diagnostic_uninitialized_push.h\"") + cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"") cog.outl(" void delete_current_message()") cog.outl(" {") cog.outl(" if (valid)") @@ -938,7 +942,7 @@ namespace etl cog.outl(" pmsg->~imessage();") cog.outl(" }") cog.outl(" }") - cog.outl(" #include \"etl/private/diagnostic_pop.h\"") + cog.outl(" #include \"private/diagnostic_pop.h\"") cog.outl("") cog.outl(" //********************************************") cog.outl(" void add_new_message(const etl::imessage& msg)") @@ -977,5 +981,8 @@ namespace etl /*[[[end]]]*/ #endif } +#else + #error "etl::message_packet is not compatible with non-virtual etl::imessage" +#endif #endif diff --git a/include/etl/generators/message_router_generator.h b/include/etl/generators/message_router_generator.h index 50c7f5a98..32903acfb 100644 --- a/include/etl/generators/message_router_generator.h +++ b/include/etl/generators/message_router_generator.h @@ -66,7 +66,9 @@ cog.outl("//******************************************************************** #include "platform.h" #include "message.h" #include "shared_message.h" -#include "message_packet.h" +#if ETL_HAS_VIRTUAL_MESSAGES + #include "message_packet.h" +#endif #include "message_types.h" #include "alignment.h" #include "error_handler.h" @@ -402,7 +404,9 @@ namespace etl { public: +#if ETL_HAS_VIRTUAL_MESSAGES typedef etl::message_packet message_packet; +#endif //********************************************** message_router() @@ -560,10 +564,12 @@ namespace etl cog.outl("{") cog.outl("public:") cog.outl("") + cog.outl("#if ETL_HAS_VIRTUAL_MESSAGES") cog.out(" typedef etl::message_packet<") for n in range(1, int(Handlers)): cog.out("T%s, " % n) cog.outl(" T%s> message_packet;" % int(Handlers)) + cog.outl("#endif") cog.outl("") cog.outl(" //**********************************************") cog.outl(" message_router(etl::message_router_id_t id_)") @@ -728,10 +734,12 @@ namespace etl cog.outl("{") cog.outl("public:") cog.outl("") + cog.outl("#if ETL_HAS_VIRTUAL_MESSAGES") cog.out(" typedef etl::message_packet<") for t in range(1, n): cog.out("T%s, " % t) cog.outl(" T%s> message_packet;" % n) + cog.outl("#endif") cog.outl("") cog.outl(" //**********************************************") cog.outl(" message_router(etl::message_router_id_t id_)") diff --git a/include/etl/generators/smallest_generator.h b/include/etl/generators/smallest_generator.h index 2e1908c7e..064420db1 100644 --- a/include/etl/generators/smallest_generator.h +++ b/include/etl/generators/smallest_generator.h @@ -140,7 +140,7 @@ namespace etl cog.outl("/// Supports up to %s types." % NTypes) cog.outl("/// Defines 'value_type' which is the type of the smallest parameter.") cog.outl("/// Defines 'size' which is the size of the smallest parameter.") - cog.outl("///\ingroup smallest") + cog.outl("///\\ingroup smallest") cog.outl("//***************************************************************************") cog.out("template true_type; import cog cog.outl("//***************************************************************************") cog.outl("/// Template to determine if a type is one of a specified list.") - cog.outl("///\ingroup types") + cog.outl("///\\ingroup types") cog.outl("template struct hash { - ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(wchar_t), "size_t smaller than type"); - size_t operator ()(wchar_t v) const { - return static_cast(v); + // If it's the same size as a size_t. + if ETL_IF_CONSTEXPR(sizeof(size_t) >= sizeof(v)) + { + return static_cast(v); + } + else + { + uint8_t* p = reinterpret_cast(&v); + return private_hash::generic_hash(p, p + sizeof(v)); + } } }; @@ -204,11 +211,18 @@ namespace etl template<> struct hash { - ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(short), "size_t smaller than type"); - size_t operator ()(short v) const { - return static_cast(v); + // If it's the same size as a size_t. + if ETL_IF_CONSTEXPR(sizeof(size_t) >= sizeof(v)) + { + return static_cast(v); + } + else + { + uint8_t* p = reinterpret_cast(&v); + return private_hash::generic_hash(p, p + sizeof(v)); + } } }; @@ -219,11 +233,18 @@ namespace etl template<> struct hash { - ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(unsigned short), "size_t smaller than type"); - size_t operator ()(unsigned short v) const { - return static_cast(v); + // If it's the same size as a size_t. + if ETL_IF_CONSTEXPR(sizeof(size_t) >= sizeof(v)) + { + return static_cast(v); + } + else + { + uint8_t* p = reinterpret_cast(&v); + return private_hash::generic_hash(p, p + sizeof(v)); + } } }; @@ -234,11 +255,18 @@ namespace etl template<> struct hash { - ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(int), "size_t smaller than type"); - size_t operator ()(int v) const { - return static_cast(v); + // If it's the same size as a size_t. + if ETL_IF_CONSTEXPR(sizeof(size_t) >= sizeof(v)) + { + return static_cast(v); + } + else + { + uint8_t* p = reinterpret_cast(&v); + return private_hash::generic_hash(p, p + sizeof(v)); + } } }; @@ -249,11 +277,18 @@ namespace etl template<> struct hash { - ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(unsigned int), "size_t smaller than type"); - size_t operator ()(unsigned int v) const { - return static_cast(v); + // If it's the same size as a size_t. + if ETL_IF_CONSTEXPR(sizeof(size_t) >= sizeof(v)) + { + return static_cast(v); + } + else + { + uint8_t* p = reinterpret_cast(&v); + return private_hash::generic_hash(p, p + sizeof(v)); + } } }; diff --git a/include/etl/indirect_vector.h b/include/etl/indirect_vector.h index 7158a4a07..e52274e00 100644 --- a/include/etl/indirect_vector.h +++ b/include/etl/indirect_vector.h @@ -598,11 +598,13 @@ namespace etl } //********************************************************************* - /// Does nothing. /// For compatibility with the STL vector API. + /// Does not increase the capacity, as this is fixed. + /// Asserts an etl::vector_out_of_bounds error if the request is for more than the capacity. //********************************************************************* - void reserve(size_t) + void reserve(size_t n) { + ETL_ASSERT(n <= capacity(), ETL_ERROR(vector_out_of_bounds)); } //********************************************************************* @@ -789,6 +791,18 @@ namespace etl return back(); } #else + //********************************************************************* + /// Constructs a value at the end of the indirect_vector. + /// If asserts or exceptions are enabled, emits vector_full if the indirect_vector is already full. + ///\param value The value to add. + //********************************************************************* + reference emplace_back() + { + T* p = storage.create(T()); + lookup.push_back(p); + return back(); + } + //********************************************************************* /// Constructs a value at the end of the indirect_vector. /// If asserts or exceptions are enabled, emits vector_full if the indirect_vector is already full. @@ -891,7 +905,7 @@ namespace etl //************************************************************************* /// Emplaces a value to the vector at the specified position. //************************************************************************* -#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT +#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_VECTOR_FORCE_CPP03_IMPLEMENTATION) template iterator emplace(iterator position, Args && ... args) { @@ -903,6 +917,16 @@ namespace etl return position; } #else + iterator emplace(iterator position) + { + ETL_ASSERT(!full(), ETL_ERROR(vector_full)); + + T* p = storage.create(T()); + position = iterator(lookup.insert(position.lookup_itr, p)); + + return position; + } + template iterator emplace(iterator position, const T1& value1) { diff --git a/include/etl/intrusive_forward_list.h b/include/etl/intrusive_forward_list.h index 020c77a3e..665d42e22 100644 --- a/include/etl/intrusive_forward_list.h +++ b/include/etl/intrusive_forward_list.h @@ -177,20 +177,16 @@ namespace etl link_type* p_last = &start; - int count = 0; - // Add all of the elements. while (first != last) { - ++count; - - link_type& value = *first++; + link_type& value = *first++; ETL_ASSERT_OR_RETURN(!value.is_linked(), ETL_ERROR(intrusive_forward_list_value_is_already_linked)); - value.etl_next = p_last->etl_next; + value.etl_next = p_last->etl_next; p_last->etl_next = &value; - p_last = &value; + p_last = &value; ++current_size; } } @@ -232,7 +228,7 @@ namespace etl while (next != &terminator) { - next = next->etl_next; // Point to next link. + next = next->etl_next; // Point to next link. current->etl_next = previous; // Reverse the current link. previous = current; // Previous points to current. current = next; // Current points to next. diff --git a/include/etl/invert.h b/include/etl/invert.h index 44398c4c5..ee9789c45 100644 --- a/include/etl/invert.h +++ b/include/etl/invert.h @@ -35,7 +35,6 @@ SOFTWARE. #include "functional.h" #include "limits.h" -#include #include namespace etl diff --git a/include/etl/ipool.h b/include/etl/ipool.h index 913e45c04..ce4c317e0 100644 --- a/include/etl/ipool.h +++ b/include/etl/ipool.h @@ -377,23 +377,48 @@ namespace etl //************************************************************************* void release_item(char* p_value) { + //// Does it belong to us? + //ETL_ASSERT(is_item_in_pool(p_value), ETL_ERROR(pool_object_not_in_pool)); + + //if (p_next != ETL_NULLPTR) + //{ + // // Point it to the current free item. + // *(uintptr_t*)p_value = reinterpret_cast(p_next); + //} + //else + //{ + // // This is the only free item. + // *((uintptr_t*)p_value) = 0; + //} + + //p_next = p_value; + + //--items_allocated; + // Does it belong to us? ETL_ASSERT(is_item_in_pool(p_value), ETL_ERROR(pool_object_not_in_pool)); - if (p_next != ETL_NULLPTR) + if (items_allocated > 0) { - // Point it to the current free item. - *(uintptr_t*)p_value = reinterpret_cast(p_next); + if (p_next != ETL_NULLPTR) + { + // Point it to the current free item. + *(uintptr_t*)p_value = reinterpret_cast(p_next); + } + else + { + // This is the only free item. + *((uintptr_t*)p_value) = 0; + } + + p_next = p_value; + + --items_allocated; } - else + else { - // This is the only free item. - *((uintptr_t*)p_value) = 0; + ETL_ASSERT_FAIL(ETL_ERROR(pool_no_allocation)); } - - p_next = p_value; - - --items_allocated; } //************************************************************************* diff --git a/include/etl/iterator.h b/include/etl/iterator.h index f60ade919..ab19db398 100644 --- a/include/etl/iterator.h +++ b/include/etl/iterator.h @@ -1147,11 +1147,11 @@ namespace etl #endif #if ETL_NOT_USING_STL || ETL_CPP17_NOT_SUPPORTED - ///************************************************************************** + //************************************************************************** /// Get the size of a container. /// Expects the container to have defined 'size_type'. ///\ingroup container - ///************************************************************************** + //************************************************************************** template ETL_CONSTEXPR typename TContainer::size_type size(const TContainer& container) { @@ -1169,13 +1169,13 @@ namespace etl } #endif - ///************************************************************************** + //************************************************************************** /// Get the size of an array in elements at compile time for C++03 ///\code /// sizeof(array_size(array)) ///\endcode ///\ingroup container - ///************************************************************************** + //************************************************************************** template char(&array_size(T(&array)[Array_Size]))[Array_Size]; diff --git a/include/etl/largest.h b/include/etl/largest.h index b3aec9ac0..0c52af2e1 100644 --- a/include/etl/largest.h +++ b/include/etl/largest.h @@ -261,7 +261,7 @@ namespace etl //*************************************************************************** /// Defines a type that is as larger or larger than the specified type. /// Will return the specified type is there is not a larger type. - ///\ingroup largest + ///\\ingroup largest //*************************************************************************** template struct larger_int_type diff --git a/include/etl/limiter.h b/include/etl/limiter.h index 06816331b..23e5fa578 100644 --- a/include/etl/limiter.h +++ b/include/etl/limiter.h @@ -36,7 +36,6 @@ SOFTWARE. #include "type_traits.h" #include "algorithm.h" -#include #include namespace etl diff --git a/include/etl/list.h b/include/etl/list.h index c3d0e0458..07e516937 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -397,7 +397,7 @@ namespace etl node_t terminal_node; ///< The node that acts as the list start and end. size_type MAX_SIZE; ///< The maximum size of the list. bool pool_is_shared; ///< If true then the pool is shared between lists. - ETL_DECLARE_DEBUG_COUNT ///< Internal debugging. + ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging. }; //*************************************************************************** @@ -857,7 +857,7 @@ namespace etl } #endif -#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT +#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_LIST_FORCE_CPP03_IMPLEMENTATION) //************************************************************************* /// Emplaces a value to the front of the list. //************************************************************************* @@ -871,11 +871,28 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(etl::forward(args)...); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; insert_node(get_head(), *p_data_node); return front(); } #else + //************************************************************************* + /// Emplaces a value to the front of the list. + //************************************************************************* + reference emplace_front() + { +#if defined(ETL_CHECK_PUSH_POP) + ETL_ASSERT(!full(), ETL_ERROR(list_full)); +#endif + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); + + data_node_t* p_data_node = allocate_data_node(); + ::new (&(p_data_node->value)) T(); + ETL_INCREMENT_DEBUG_COUNT; + insert_node(get_head(), *p_data_node); + return front(); + } + //************************************************************************* /// Emplaces a value to the front of the list. //************************************************************************* @@ -889,7 +906,7 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; insert_node(get_head(), *p_data_node); return front(); } @@ -907,7 +924,7 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1, value2); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; insert_node(get_head(), *p_data_node); return front(); } @@ -925,7 +942,7 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1, value2, value3); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; insert_node(get_head(), *p_data_node); return front(); } @@ -943,7 +960,7 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1, value2, value3, value4); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; insert_node(get_head(), *p_data_node); return front(); } @@ -999,11 +1016,25 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(etl::forward(args)...); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; insert_node(terminal_node, *p_data_node); return back(); } #else + reference emplace_back() + { +#if defined(ETL_CHECK_PUSH_POP) + ETL_ASSERT(!full(), ETL_ERROR(list_full)); +#endif + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); + + data_node_t* p_data_node = allocate_data_node(); + ::new (&(p_data_node->value)) T(); + ETL_INCREMENT_DEBUG_COUNT; + insert_node(terminal_node, *p_data_node); + return back(); + } + template reference emplace_back(const T1& value1) { @@ -1014,7 +1045,7 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; insert_node(terminal_node, *p_data_node); return back(); } @@ -1029,7 +1060,7 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1, value2); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; insert_node(terminal_node, *p_data_node); return back(); } @@ -1044,7 +1075,7 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1, value2, value3); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; insert_node(terminal_node, *p_data_node); return back(); } @@ -1059,7 +1090,7 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1, value2, value3, value4); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; insert_node(terminal_node, *p_data_node); return back(); } @@ -1108,21 +1139,34 @@ namespace etl //************************************************************************* /// Emplaces a value to the list at the specified position. //************************************************************************* -#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT +#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_LIST_FORCE_CPP03_IMPLEMENTATION) template - iterator emplace(const_iterator position, Args && ... args) + iterator emplace(const_iterator position, Args&& ... args) { ETL_ASSERT(!full(), ETL_ERROR(list_full)); ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(etl::forward(args)...); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; insert_node(*to_iterator(position).p_node, *p_data_node); return iterator(*p_data_node); } #else + iterator emplace(const_iterator position) + { + ETL_ASSERT(!full(), ETL_ERROR(list_full)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); + + data_node_t* p_data_node = allocate_data_node(); + ::new (&(p_data_node->value)) T(); + ETL_INCREMENT_DEBUG_COUNT; + insert_node(*to_iterator(position).p_node, *p_data_node); + + return iterator(*p_data_node); + } + template iterator emplace(const_iterator position, const T1& value1) { @@ -1131,8 +1175,8 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1); - ETL_INCREMENT_DEBUG_COUNT - insert_node(*position.p_node, *p_data_node); + ETL_INCREMENT_DEBUG_COUNT; + insert_node(*to_iterator(position).p_node, *p_data_node); return iterator(*p_data_node); } @@ -1145,8 +1189,8 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1, value2); - ETL_INCREMENT_DEBUG_COUNT - insert_node(*position.p_node, *p_data_node); + ETL_INCREMENT_DEBUG_COUNT; + insert_node(*to_iterator(position).p_node, *p_data_node); return iterator(*p_data_node); } @@ -1159,8 +1203,8 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1, value2, value3); - ETL_INCREMENT_DEBUG_COUNT - insert_node(*position.p_node, *p_data_node); + ETL_INCREMENT_DEBUG_COUNT; + insert_node(*to_iterator(position).p_node, *p_data_node); return iterator(*p_data_node); } @@ -1173,8 +1217,8 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value1, value2, value3, value4); - ETL_INCREMENT_DEBUG_COUNT - insert_node(*position.p_node, *p_data_node); + ETL_INCREMENT_DEBUG_COUNT; + insert_node(*to_iterator(position).p_node, *p_data_node); return iterator(*p_data_node); } @@ -1813,7 +1857,7 @@ namespace etl { ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); p_node_pool->release_all(); - ETL_RESET_DEBUG_COUNT; + ETL_RESET_DEBUG_COUNT;; } else { @@ -1955,7 +1999,7 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(value); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return *p_data_node; } @@ -1970,7 +2014,7 @@ namespace etl data_node_t* p_data_node = allocate_data_node(); ::new (&(p_data_node->value)) T(etl::move(value)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return *p_data_node; } @@ -1993,7 +2037,7 @@ namespace etl ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); node.value.~T(); p_node_pool->release(&node); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } // Disable copy construction. diff --git a/include/etl/macros.h b/include/etl/macros.h index a3353671a..27d10a467 100644 --- a/include/etl/macros.h +++ b/include/etl/macros.h @@ -33,13 +33,41 @@ SOFTWARE. #define ETL_CONCAT2(X, Y) X##Y #define ETL_CONCAT(X, Y) ETL_CONCAT2(X, Y) -#define ETL_STRINGIFY2(X) #X -#define ETL_STRINGIFY(X) ETL_STRINGIFY2(X) -#define ETL_STRING(X) ETL_CONCAT( , ETL_STRINGIFY(X)) -#define ETL_WIDE_STRING(X) ETL_CONCAT( L, ETL_STRINGIFY(X)) + +#define ETL_STRINGIFY_1(...) #__VA_ARGS__ +#define ETL_STRINGIFY(...) ETL_STRINGIFY_1(__VA_ARGS__) + +#define ETL_STRING(X) ETL_CONCAT(, ETL_STRINGIFY(X)) +#define ETL_WIDE_STRING(X) ETL_CONCAT(L, ETL_STRINGIFY(X)) #define ETL_U8_STRING(X) ETL_CONCAT(u8, ETL_STRINGIFY(X)) -#define ETL_U16_STRING(X) ETL_CONCAT( u, ETL_STRINGIFY(X)) -#define ETL_U32_STRING(X) ETL_CONCAT( U, ETL_STRINGIFY(X)) +#define ETL_U16_STRING(X) ETL_CONCAT(u, ETL_STRINGIFY(X)) +#define ETL_U32_STRING(X) ETL_CONCAT(U, ETL_STRINGIFY(X)) + +/** + * Resolves a function-like macro overload with 1 or 2 arguments. + * + * This macro can be used to call other function-like macros depending on the number of arguments + * provided by the caller. + * + * \param _1 is the first argument given to the called macro + * \param _2 is either the second argument given to the called macro + * or the name of the macro which takes two arguments + * \param SELECTED_MACRO_NAME is the name of the macro to be called + * \param ... is a non-empty list of arguments: + * The beginning of the list is a list of all macro names which accept less arguments than + * `SELECTED_MACRO_NAME`. This list may be empty. + * The last element in the list is a dummy argument. For example `""`. + * For compatibility reasons `...` should not be empty. + * + * Use this function-like macro as follows: + * + * #define TAKES1( a ) (a) //!< example macro which takes 1 argument + * #define TAKES2(a, b) (a+b) //!< example macro which takes 2 arguments + * #define TAKES_1or2(...) GET_MACRO_OVERLOAD2(__VA_ARGS__, TAKES2, TAKES1, "")(__VA_ARGS__) + * + * Now `TAKES_1or2()` can be called with 1 or 2 arguments. + */ +#define GET_MACRO_OVERLOAD2(_1, _2, SELECTED_MACRO_NAME, ...) SELECTED_MACRO_NAME #endif diff --git a/include/etl/map.h b/include/etl/map.h index 5974573a5..ce81317de 100644 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -450,7 +450,7 @@ namespace etl size_type current_size; ///< The number of the used nodes. const size_type CAPACITY; ///< The maximum size of the map. Node* root_node; ///< The node that acts as the map root. - ETL_DECLARE_DEBUG_COUNT + ETL_DECLARE_DEBUG_COUNT; }; //*************************************************************************** @@ -1498,7 +1498,7 @@ namespace etl { Data_Node& node = allocate_data_node(); ::new (&node.value) value_type(value); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return node; } @@ -1511,7 +1511,7 @@ namespace etl ::new ((void*)etl::addressof(node.value.first)) key_type(key); ::new ((void*)etl::addressof(node.value.second)) mapped_type(); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return node; } @@ -1523,7 +1523,7 @@ namespace etl { Data_Node& node = allocate_data_node(); ::new (&node.value) value_type(etl::move(value)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return node; } @@ -1536,7 +1536,7 @@ namespace etl ::new ((void*)etl::addressof(node.value.first)) key_type(etl::move(key)); ::new ((void*)etl::addressof(node.value.second)) mapped_type(); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return node; } @@ -1558,7 +1558,7 @@ namespace etl { node.value.~value_type(); p_node_pool->release(&node); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* diff --git a/include/etl/mean.h b/include/etl/mean.h index c5608151c..5be39378e 100644 --- a/include/etl/mean.h +++ b/include/etl/mean.h @@ -35,7 +35,7 @@ SOFTWARE. #include "functional.h" #include "type_traits.h" -#include +//#include #include namespace etl diff --git a/include/etl/memory.h b/include/etl/memory.h index 38e9889c0..c4eb8fa98 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -1399,7 +1399,11 @@ namespace etl pointer value = p; p = p_; - deleter(value); + + if (value != ETL_NULLPTR) + { + deleter(value); + } } //********************************* @@ -1605,7 +1609,11 @@ namespace etl pointer value = p; p = p_; - delete[] value; + + if (value != ETL_NULLPTR) + { + deleter(value); + } } //********************************* diff --git a/include/etl/message.h b/include/etl/message.h index 93e2ddadc..22a802e61 100644 --- a/include/etl/message.h +++ b/include/etl/message.h @@ -62,40 +62,127 @@ namespace etl } }; +#if ETL_HAS_VIRTUAL_MESSAGES //*************************************************************************** - // Message interface. + /// Message interface. + /// Virtual. //*************************************************************************** class imessage { public: - virtual ~imessage() + //*********************************** + virtual ~imessage() ETL_NOEXCEPT { } + //*********************************** ETL_NODISCARD virtual etl::message_id_t get_message_id() const ETL_NOEXCEPT = 0; }; //*************************************************************************** - // Message type. + /// Message type. + /// Virtual. //*************************************************************************** - template - class message : public TParent + template + class message : public TBase { - ETL_STATIC_ASSERT((etl::is_base_of::value), "TParent is not derived from etl::imessage"); - public: + //*********************************** + ETL_NODISCARD virtual etl::message_id_t get_message_id() const ETL_NOEXCEPT ETL_OVERRIDE + { + return ID; + } + + //*********************************** static ETL_CONSTANT etl::message_id_t ID = ID_; + }; + +#else + + //*************************************************************************** + /// Message interface. + /// Non-virtual. + //*************************************************************************** + class imessage + { + public: - ETL_NODISCARD etl::message_id_t get_message_id() const ETL_NOEXCEPT ETL_OVERRIDE + //*********************************** + ETL_NODISCARD etl::message_id_t get_message_id() const ETL_NOEXCEPT { - return ID; + return id; + } + + protected: + + //*********************************** + imessage(etl::message_id_t id_) ETL_NOEXCEPT + : id(id_) + { + } + + //*********************************** + imessage(const imessage& other) ETL_NOEXCEPT + : id(other.id) + { + } + + //*********************************** + imessage& operator =(const imessage& rhs) ETL_NOEXCEPT + { + id = rhs.id; + return *this; } + + //*********************************** + etl::message_id_t id; + + private: + + imessage() ETL_DELETE; + }; + + //*************************************************************************** + /// Message type. + /// Non-virtual. + //*************************************************************************** + template + class message : public TBase + { + public: + + ETL_STATIC_ASSERT((etl::is_base_of::value), "TBase is not derived from etl::imessage"); + + //*********************************** + message() ETL_NOEXCEPT + : TBase(ID) + { + } + + //*********************************** + message(const message&) ETL_NOEXCEPT + : TBase(ID) + { + } + + //*********************************** + message& operator =(const message&) ETL_NOEXCEPT + { + return *this; + } + + //*********************************** + static ETL_CONSTANT etl::message_id_t ID = ID_; }; +#endif - template - ETL_CONSTANT etl::message_id_t message::ID; + //*************************************************************************** + /// The message's static ID. + //*************************************************************************** + template + ETL_CONSTANT etl::message_id_t etl::message::ID; } #endif diff --git a/include/etl/message_packet.h b/include/etl/message_packet.h index 59597ed63..df4d6d29f 100644 --- a/include/etl/message_packet.h +++ b/include/etl/message_packet.h @@ -51,6 +51,10 @@ SOFTWARE. #ifndef ETL_MESSAGE_PACKET_INCLUDED #define ETL_MESSAGE_PACKET_INCLUDED +#include "platform.h" + +#if ETL_HAS_VIRTUAL_MESSAGES + #include "message.h" #include "error_handler.h" #include "static_assert.h" @@ -84,17 +88,17 @@ namespace etl public: //******************************************** -#include "etl/private/diagnostic_uninitialized_push.h" +#include "private/diagnostic_uninitialized_push.h" message_packet() : valid(false) { } -#include "etl/private/diagnostic_pop.h" +#include "private/diagnostic_pop.h" //******************************************** - /// + /// //******************************************** -#include "etl/private/diagnostic_uninitialized_push.h" +#include "private/diagnostic_uninitialized_push.h" template explicit message_packet(T&& msg) : valid(true) @@ -126,7 +130,7 @@ namespace etl ETL_STATIC_ASSERT(IsInMessageList, "Message not in packet type list"); } } -#include "etl/private/diagnostic_pop.h" +#include "private/diagnostic_pop.h" //********************************************** void copy(const message_packet& other) @@ -151,7 +155,7 @@ namespace etl } //********************************************** -#include "etl/private/diagnostic_uninitialized_push.h" +#include "private/diagnostic_uninitialized_push.h" message_packet& operator =(const message_packet& rhs) { delete_current_message(); @@ -163,10 +167,10 @@ namespace etl return *this; } -#include "etl/private/diagnostic_pop.h" +#include "private/diagnostic_pop.h" //********************************************** -#include "etl/private/diagnostic_uninitialized_push.h" +#include "private/diagnostic_uninitialized_push.h" message_packet& operator =(message_packet&& rhs) { delete_current_message(); @@ -178,7 +182,7 @@ namespace etl return *this; } -#include "etl/private/diagnostic_pop.h" +#include "private/diagnostic_pop.h" //******************************************** ~message_packet() @@ -255,7 +259,7 @@ namespace etl } //******************************************** -#include "etl/private/diagnostic_uninitialized_push.h" +#include "private/diagnostic_uninitialized_push.h" void delete_current_message() { if (valid) @@ -265,7 +269,7 @@ namespace etl pmsg->~imessage(); } } -#include "etl/private/diagnostic_pop.h" +#include "private/diagnostic_pop.h" //******************************************** void add_new_message(const etl::imessage& msg) @@ -279,7 +283,7 @@ namespace etl (add_new_message_type(etl::move(msg)) || ...); } -#include "etl/private/diagnostic_uninitialized_push.h" +#include "private/diagnostic_uninitialized_push.h" //******************************************** /// Only enabled for types that are in the typelist. //******************************************** @@ -290,9 +294,9 @@ namespace etl void* p = data; new (p) etl::remove_reference_t((etl::forward(msg))); } -#include "etl/private/diagnostic_pop.h" +#include "private/diagnostic_pop.h" -#include "etl/private/diagnostic_uninitialized_push.h" +#include "private/diagnostic_uninitialized_push.h" //******************************************** template bool add_new_message_type(const etl::imessage& msg) @@ -308,7 +312,7 @@ namespace etl return false; } } -#include "etl/private/diagnostic_pop.h" +#include "private/diagnostic_pop.h" //******************************************** template @@ -344,15 +348,15 @@ namespace etl public: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet() : valid(false) { } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(const etl::imessage& msg) { if (accepts(msg)) @@ -367,11 +371,11 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(etl::imessage&& msg) { if (accepts(msg)) @@ -386,12 +390,12 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value, int>::type> @@ -405,10 +409,10 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #else //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && @@ -422,11 +426,11 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(const message_packet& other) : valid(other.is_valid()) { @@ -435,11 +439,11 @@ namespace etl add_new_message(other.get()); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(message_packet&& other) : valid(other.is_valid()) { @@ -448,11 +452,11 @@ namespace etl add_new_message(etl::move(other.get())); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(const message_packet& rhs) { delete_current_message(); @@ -464,11 +468,11 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(message_packet&& rhs) { delete_current_message(); @@ -480,7 +484,7 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //******************************************** @@ -553,7 +557,7 @@ namespace etl private: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" void delete_current_message() { if (valid) @@ -563,7 +567,7 @@ namespace etl pmsg->~imessage(); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** void add_new_message(const etl::imessage& msg) @@ -639,15 +643,15 @@ namespace etl public: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet() : valid(false) { } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(const etl::imessage& msg) { if (accepts(msg)) @@ -662,11 +666,11 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(etl::imessage&& msg) { if (accepts(msg)) @@ -681,12 +685,12 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>::value, int>::type> @@ -700,10 +704,10 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #else //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && @@ -717,11 +721,11 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(const message_packet& other) : valid(other.is_valid()) { @@ -730,11 +734,11 @@ namespace etl add_new_message(other.get()); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(message_packet&& other) : valid(other.is_valid()) { @@ -743,11 +747,11 @@ namespace etl add_new_message(etl::move(other.get())); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(const message_packet& rhs) { delete_current_message(); @@ -759,11 +763,11 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(message_packet&& rhs) { delete_current_message(); @@ -775,7 +779,7 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //******************************************** @@ -848,7 +852,7 @@ namespace etl private: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" void delete_current_message() { if (valid) @@ -858,7 +862,7 @@ namespace etl pmsg->~imessage(); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** void add_new_message(const etl::imessage& msg) @@ -932,15 +936,15 @@ namespace etl public: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet() : valid(false) { } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(const etl::imessage& msg) { if (accepts(msg)) @@ -955,11 +959,11 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(etl::imessage&& msg) { if (accepts(msg)) @@ -974,12 +978,12 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>::value, int>::type> @@ -993,10 +997,10 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #else //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && @@ -1010,11 +1014,11 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(const message_packet& other) : valid(other.is_valid()) { @@ -1023,11 +1027,11 @@ namespace etl add_new_message(other.get()); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(message_packet&& other) : valid(other.is_valid()) { @@ -1036,11 +1040,11 @@ namespace etl add_new_message(etl::move(other.get())); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(const message_packet& rhs) { delete_current_message(); @@ -1052,11 +1056,11 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(message_packet&& rhs) { delete_current_message(); @@ -1068,7 +1072,7 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //******************************************** @@ -1141,7 +1145,7 @@ namespace etl private: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" void delete_current_message() { if (valid) @@ -1151,7 +1155,7 @@ namespace etl pmsg->~imessage(); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** void add_new_message(const etl::imessage& msg) @@ -1223,15 +1227,15 @@ namespace etl public: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet() : valid(false) { } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(const etl::imessage& msg) { if (accepts(msg)) @@ -1246,11 +1250,11 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(etl::imessage&& msg) { if (accepts(msg)) @@ -1265,12 +1269,12 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>::value, int>::type> @@ -1284,10 +1288,10 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #else //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && @@ -1301,11 +1305,11 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(const message_packet& other) : valid(other.is_valid()) { @@ -1314,11 +1318,11 @@ namespace etl add_new_message(other.get()); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(message_packet&& other) : valid(other.is_valid()) { @@ -1327,11 +1331,11 @@ namespace etl add_new_message(etl::move(other.get())); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(const message_packet& rhs) { delete_current_message(); @@ -1343,11 +1347,11 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(message_packet&& rhs) { delete_current_message(); @@ -1359,7 +1363,7 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //******************************************** @@ -1432,7 +1436,7 @@ namespace etl private: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" void delete_current_message() { if (valid) @@ -1442,7 +1446,7 @@ namespace etl pmsg->~imessage(); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** void add_new_message(const etl::imessage& msg) @@ -1511,15 +1515,15 @@ namespace etl public: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet() : valid(false) { } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(const etl::imessage& msg) { if (accepts(msg)) @@ -1534,11 +1538,11 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(etl::imessage&& msg) { if (accepts(msg)) @@ -1553,12 +1557,12 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>::value, int>::type> @@ -1572,10 +1576,10 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #else //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && @@ -1589,11 +1593,11 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(const message_packet& other) : valid(other.is_valid()) { @@ -1602,11 +1606,11 @@ namespace etl add_new_message(other.get()); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(message_packet&& other) : valid(other.is_valid()) { @@ -1615,11 +1619,11 @@ namespace etl add_new_message(etl::move(other.get())); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(const message_packet& rhs) { delete_current_message(); @@ -1631,11 +1635,11 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(message_packet&& rhs) { delete_current_message(); @@ -1647,7 +1651,7 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //******************************************** @@ -1717,7 +1721,7 @@ namespace etl private: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" void delete_current_message() { if (valid) @@ -1727,7 +1731,7 @@ namespace etl pmsg->~imessage(); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** void add_new_message(const etl::imessage& msg) @@ -1794,15 +1798,15 @@ namespace etl public: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet() : valid(false) { } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(const etl::imessage& msg) { if (accepts(msg)) @@ -1817,11 +1821,11 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(etl::imessage&& msg) { if (accepts(msg)) @@ -1836,12 +1840,12 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>::value, int>::type> @@ -1855,10 +1859,10 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #else //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && @@ -1872,11 +1876,11 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(const message_packet& other) : valid(other.is_valid()) { @@ -1885,11 +1889,11 @@ namespace etl add_new_message(other.get()); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(message_packet&& other) : valid(other.is_valid()) { @@ -1898,11 +1902,11 @@ namespace etl add_new_message(etl::move(other.get())); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(const message_packet& rhs) { delete_current_message(); @@ -1914,11 +1918,11 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(message_packet&& rhs) { delete_current_message(); @@ -1930,7 +1934,7 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //******************************************** @@ -2000,7 +2004,7 @@ namespace etl private: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" void delete_current_message() { if (valid) @@ -2010,7 +2014,7 @@ namespace etl pmsg->~imessage(); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** void add_new_message(const etl::imessage& msg) @@ -2075,15 +2079,15 @@ namespace etl public: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet() : valid(false) { } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(const etl::imessage& msg) { if (accepts(msg)) @@ -2098,11 +2102,11 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(etl::imessage&& msg) { if (accepts(msg)) @@ -2117,12 +2121,12 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>::value, int>::type> @@ -2136,10 +2140,10 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #else //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && @@ -2153,11 +2157,11 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(const message_packet& other) : valid(other.is_valid()) { @@ -2166,11 +2170,11 @@ namespace etl add_new_message(other.get()); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(message_packet&& other) : valid(other.is_valid()) { @@ -2179,11 +2183,11 @@ namespace etl add_new_message(etl::move(other.get())); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(const message_packet& rhs) { delete_current_message(); @@ -2195,11 +2199,11 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(message_packet&& rhs) { delete_current_message(); @@ -2211,7 +2215,7 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //******************************************** @@ -2281,7 +2285,7 @@ namespace etl private: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" void delete_current_message() { if (valid) @@ -2291,7 +2295,7 @@ namespace etl pmsg->~imessage(); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** void add_new_message(const etl::imessage& msg) @@ -2354,15 +2358,15 @@ namespace etl public: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet() : valid(false) { } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(const etl::imessage& msg) { if (accepts(msg)) @@ -2377,11 +2381,11 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(etl::imessage&& msg) { if (accepts(msg)) @@ -2396,12 +2400,12 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9>::value, int>::type> @@ -2415,10 +2419,10 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #else //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && @@ -2432,11 +2436,11 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(const message_packet& other) : valid(other.is_valid()) { @@ -2445,11 +2449,11 @@ namespace etl add_new_message(other.get()); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(message_packet&& other) : valid(other.is_valid()) { @@ -2458,11 +2462,11 @@ namespace etl add_new_message(etl::move(other.get())); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(const message_packet& rhs) { delete_current_message(); @@ -2474,11 +2478,11 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(message_packet&& rhs) { delete_current_message(); @@ -2490,7 +2494,7 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //******************************************** @@ -2560,7 +2564,7 @@ namespace etl private: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" void delete_current_message() { if (valid) @@ -2570,7 +2574,7 @@ namespace etl pmsg->~imessage(); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** void add_new_message(const etl::imessage& msg) @@ -2630,15 +2634,15 @@ namespace etl public: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet() : valid(false) { } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(const etl::imessage& msg) { if (accepts(msg)) @@ -2653,11 +2657,11 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(etl::imessage&& msg) { if (accepts(msg)) @@ -2672,12 +2676,12 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8>::value, int>::type> @@ -2691,10 +2695,10 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #else //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && @@ -2708,11 +2712,11 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(const message_packet& other) : valid(other.is_valid()) { @@ -2721,11 +2725,11 @@ namespace etl add_new_message(other.get()); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(message_packet&& other) : valid(other.is_valid()) { @@ -2734,11 +2738,11 @@ namespace etl add_new_message(etl::move(other.get())); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(const message_packet& rhs) { delete_current_message(); @@ -2750,11 +2754,11 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(message_packet&& rhs) { delete_current_message(); @@ -2766,7 +2770,7 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //******************************************** @@ -2833,7 +2837,7 @@ namespace etl private: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" void delete_current_message() { if (valid) @@ -2843,7 +2847,7 @@ namespace etl pmsg->~imessage(); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** void add_new_message(const etl::imessage& msg) @@ -2901,15 +2905,15 @@ namespace etl public: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet() : valid(false) { } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(const etl::imessage& msg) { if (accepts(msg)) @@ -2924,11 +2928,11 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(etl::imessage&& msg) { if (accepts(msg)) @@ -2943,12 +2947,12 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7>::value, int>::type> @@ -2962,10 +2966,10 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #else //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && @@ -2979,11 +2983,11 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(const message_packet& other) : valid(other.is_valid()) { @@ -2992,11 +2996,11 @@ namespace etl add_new_message(other.get()); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(message_packet&& other) : valid(other.is_valid()) { @@ -3005,11 +3009,11 @@ namespace etl add_new_message(etl::move(other.get())); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(const message_packet& rhs) { delete_current_message(); @@ -3021,11 +3025,11 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(message_packet&& rhs) { delete_current_message(); @@ -3037,7 +3041,7 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //******************************************** @@ -3104,7 +3108,7 @@ namespace etl private: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" void delete_current_message() { if (valid) @@ -3114,7 +3118,7 @@ namespace etl pmsg->~imessage(); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** void add_new_message(const etl::imessage& msg) @@ -3170,15 +3174,15 @@ namespace etl public: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet() : valid(false) { } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(const etl::imessage& msg) { if (accepts(msg)) @@ -3193,11 +3197,11 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(etl::imessage&& msg) { if (accepts(msg)) @@ -3212,12 +3216,12 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6>::value, int>::type> @@ -3231,10 +3235,10 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #else //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && @@ -3248,11 +3252,11 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(const message_packet& other) : valid(other.is_valid()) { @@ -3261,11 +3265,11 @@ namespace etl add_new_message(other.get()); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(message_packet&& other) : valid(other.is_valid()) { @@ -3274,11 +3278,11 @@ namespace etl add_new_message(etl::move(other.get())); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(const message_packet& rhs) { delete_current_message(); @@ -3290,11 +3294,11 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(message_packet&& rhs) { delete_current_message(); @@ -3306,7 +3310,7 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //******************************************** @@ -3373,7 +3377,7 @@ namespace etl private: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" void delete_current_message() { if (valid) @@ -3383,7 +3387,7 @@ namespace etl pmsg->~imessage(); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** void add_new_message(const etl::imessage& msg) @@ -3437,15 +3441,15 @@ namespace etl public: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet() : valid(false) { } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(const etl::imessage& msg) { if (accepts(msg)) @@ -3460,11 +3464,11 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(etl::imessage&& msg) { if (accepts(msg)) @@ -3479,12 +3483,12 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5>::value, int>::type> @@ -3498,10 +3502,10 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #else //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && @@ -3515,11 +3519,11 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(const message_packet& other) : valid(other.is_valid()) { @@ -3528,11 +3532,11 @@ namespace etl add_new_message(other.get()); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(message_packet&& other) : valid(other.is_valid()) { @@ -3541,11 +3545,11 @@ namespace etl add_new_message(etl::move(other.get())); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(const message_packet& rhs) { delete_current_message(); @@ -3557,11 +3561,11 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(message_packet&& rhs) { delete_current_message(); @@ -3573,7 +3577,7 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //******************************************** @@ -3640,7 +3644,7 @@ namespace etl private: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" void delete_current_message() { if (valid) @@ -3650,7 +3654,7 @@ namespace etl pmsg->~imessage(); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** void add_new_message(const etl::imessage& msg) @@ -3701,15 +3705,15 @@ namespace etl public: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet() : valid(false) { } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(const etl::imessage& msg) { if (accepts(msg)) @@ -3724,11 +3728,11 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(etl::imessage&& msg) { if (accepts(msg)) @@ -3743,12 +3747,12 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4>::value, int>::type> @@ -3762,10 +3766,10 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #else //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && @@ -3779,11 +3783,11 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(const message_packet& other) : valid(other.is_valid()) { @@ -3792,11 +3796,11 @@ namespace etl add_new_message(other.get()); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(message_packet&& other) : valid(other.is_valid()) { @@ -3805,11 +3809,11 @@ namespace etl add_new_message(etl::move(other.get())); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(const message_packet& rhs) { delete_current_message(); @@ -3821,11 +3825,11 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(message_packet&& rhs) { delete_current_message(); @@ -3837,7 +3841,7 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //******************************************** @@ -3901,7 +3905,7 @@ namespace etl private: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" void delete_current_message() { if (valid) @@ -3911,7 +3915,7 @@ namespace etl pmsg->~imessage(); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** void add_new_message(const etl::imessage& msg) @@ -3960,15 +3964,15 @@ namespace etl public: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet() : valid(false) { } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(const etl::imessage& msg) { if (accepts(msg)) @@ -3983,11 +3987,11 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(etl::imessage&& msg) { if (accepts(msg)) @@ -4002,12 +4006,12 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3>::value, int>::type> @@ -4021,10 +4025,10 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #else //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && @@ -4038,11 +4042,11 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(const message_packet& other) : valid(other.is_valid()) { @@ -4051,11 +4055,11 @@ namespace etl add_new_message(other.get()); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(message_packet&& other) : valid(other.is_valid()) { @@ -4064,11 +4068,11 @@ namespace etl add_new_message(etl::move(other.get())); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(const message_packet& rhs) { delete_current_message(); @@ -4080,11 +4084,11 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(message_packet&& rhs) { delete_current_message(); @@ -4096,7 +4100,7 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //******************************************** @@ -4160,7 +4164,7 @@ namespace etl private: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" void delete_current_message() { if (valid) @@ -4170,7 +4174,7 @@ namespace etl pmsg->~imessage(); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** void add_new_message(const etl::imessage& msg) @@ -4217,15 +4221,15 @@ namespace etl public: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet() : valid(false) { } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(const etl::imessage& msg) { if (accepts(msg)) @@ -4240,11 +4244,11 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(etl::imessage&& msg) { if (accepts(msg)) @@ -4259,12 +4263,12 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2>::value, int>::type> @@ -4278,10 +4282,10 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #else //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && @@ -4295,11 +4299,11 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(const message_packet& other) : valid(other.is_valid()) { @@ -4308,11 +4312,11 @@ namespace etl add_new_message(other.get()); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(message_packet&& other) : valid(other.is_valid()) { @@ -4321,11 +4325,11 @@ namespace etl add_new_message(etl::move(other.get())); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(const message_packet& rhs) { delete_current_message(); @@ -4337,11 +4341,11 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(message_packet&& rhs) { delete_current_message(); @@ -4353,7 +4357,7 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //******************************************** @@ -4417,7 +4421,7 @@ namespace etl private: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" void delete_current_message() { if (valid) @@ -4427,7 +4431,7 @@ namespace etl pmsg->~imessage(); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** void add_new_message(const etl::imessage& msg) @@ -4472,15 +4476,15 @@ namespace etl public: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet() : valid(false) { } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(const etl::imessage& msg) { if (accepts(msg)) @@ -4495,11 +4499,11 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" explicit message_packet(etl::imessage&& msg) { if (accepts(msg)) @@ -4514,12 +4518,12 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception)); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS) //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1>::value, int>::type> @@ -4533,10 +4537,10 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #else //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" template explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && @@ -4550,11 +4554,11 @@ namespace etl ETL_STATIC_ASSERT(Enabled, "Message not in packet type list"); } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(const message_packet& other) : valid(other.is_valid()) { @@ -4563,11 +4567,11 @@ namespace etl add_new_message(other.get()); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet(message_packet&& other) : valid(other.is_valid()) { @@ -4576,11 +4580,11 @@ namespace etl add_new_message(etl::move(other.get())); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(const message_packet& rhs) { delete_current_message(); @@ -4592,11 +4596,11 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) //********************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" message_packet& operator =(message_packet&& rhs) { delete_current_message(); @@ -4608,7 +4612,7 @@ namespace etl return *this; } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" #endif //******************************************** @@ -4672,7 +4676,7 @@ namespace etl private: //******************************************** - #include "etl/private/diagnostic_uninitialized_push.h" + #include "private/diagnostic_uninitialized_push.h" void delete_current_message() { if (valid) @@ -4682,7 +4686,7 @@ namespace etl pmsg->~imessage(); } } - #include "etl/private/diagnostic_pop.h" + #include "private/diagnostic_pop.h" //******************************************** void add_new_message(const etl::imessage& msg) @@ -4717,5 +4721,8 @@ namespace etl }; #endif } +#else + #error "etl::message_packet is not compatible with non-virtual etl::imessage" +#endif #endif diff --git a/include/etl/message_router.h b/include/etl/message_router.h index 75172e721..b7807a77c 100644 --- a/include/etl/message_router.h +++ b/include/etl/message_router.h @@ -54,7 +54,9 @@ SOFTWARE. #include "platform.h" #include "message.h" #include "shared_message.h" -#include "message_packet.h" +#if ETL_HAS_VIRTUAL_MESSAGES + #include "message_packet.h" +#endif #include "message_types.h" #include "alignment.h" #include "error_handler.h" @@ -390,7 +392,9 @@ namespace etl { public: +#if ETL_HAS_VIRTUAL_MESSAGES typedef etl::message_packet message_packet; +#endif //********************************************** message_router() @@ -538,7 +542,9 @@ namespace etl { public: + #if ETL_HAS_VIRTUAL_MESSAGES typedef etl::message_packet message_packet; + #endif //********************************************** message_router(etl::message_router_id_t id_) @@ -683,7 +689,9 @@ namespace etl { public: + #if ETL_HAS_VIRTUAL_MESSAGES typedef etl::message_packet message_packet; + #endif //********************************************** message_router(etl::message_router_id_t id_) @@ -828,7 +836,9 @@ namespace etl { public: + #if ETL_HAS_VIRTUAL_MESSAGES typedef etl::message_packet message_packet; + #endif //********************************************** message_router(etl::message_router_id_t id_) @@ -972,7 +982,9 @@ namespace etl { public: + #if ETL_HAS_VIRTUAL_MESSAGES typedef etl::message_packet message_packet; + #endif //********************************************** message_router(etl::message_router_id_t id_) @@ -1114,7 +1126,9 @@ namespace etl { public: + #if ETL_HAS_VIRTUAL_MESSAGES typedef etl::message_packet message_packet; + #endif //********************************************** message_router(etl::message_router_id_t id_) @@ -1255,7 +1269,9 @@ namespace etl { public: + #if ETL_HAS_VIRTUAL_MESSAGES typedef etl::message_packet message_packet; + #endif //********************************************** message_router(etl::message_router_id_t id_) @@ -1395,7 +1411,9 @@ namespace etl { public: + #if ETL_HAS_VIRTUAL_MESSAGES typedef etl::message_packet message_packet; + #endif //********************************************** message_router(etl::message_router_id_t id_) @@ -1534,7 +1552,9 @@ namespace etl { public: + #if ETL_HAS_VIRTUAL_MESSAGES typedef etl::message_packet message_packet; + #endif //********************************************** message_router(etl::message_router_id_t id_) @@ -1671,7 +1691,9 @@ namespace etl { public: + #if ETL_HAS_VIRTUAL_MESSAGES typedef etl::message_packet message_packet; + #endif //********************************************** message_router(etl::message_router_id_t id_) @@ -1807,7 +1829,9 @@ namespace etl { public: + #if ETL_HAS_VIRTUAL_MESSAGES typedef etl::message_packet message_packet; + #endif //********************************************** message_router(etl::message_router_id_t id_) @@ -1941,7 +1965,9 @@ namespace etl { public: + #if ETL_HAS_VIRTUAL_MESSAGES typedef etl::message_packet message_packet; + #endif //********************************************** message_router(etl::message_router_id_t id_) @@ -2074,7 +2100,9 @@ namespace etl { public: + #if ETL_HAS_VIRTUAL_MESSAGES typedef etl::message_packet message_packet; + #endif //********************************************** message_router(etl::message_router_id_t id_) @@ -2205,7 +2233,9 @@ namespace etl { public: + #if ETL_HAS_VIRTUAL_MESSAGES typedef etl::message_packet message_packet; + #endif //********************************************** message_router(etl::message_router_id_t id_) @@ -2335,7 +2365,9 @@ namespace etl { public: + #if ETL_HAS_VIRTUAL_MESSAGES typedef etl::message_packet message_packet; + #endif //********************************************** message_router(etl::message_router_id_t id_) @@ -2464,7 +2496,9 @@ namespace etl { public: + #if ETL_HAS_VIRTUAL_MESSAGES typedef etl::message_packet message_packet; + #endif //********************************************** message_router(etl::message_router_id_t id_) @@ -2592,7 +2626,9 @@ namespace etl { public: + #if ETL_HAS_VIRTUAL_MESSAGES typedef etl::message_packet< T1> message_packet; + #endif //********************************************** message_router(etl::message_router_id_t id_) diff --git a/include/etl/message_timer.h b/include/etl/message_timer.h index 4655f1ab3..075b03ade 100644 --- a/include/etl/message_timer.h +++ b/include/etl/message_timer.h @@ -86,7 +86,7 @@ namespace etl : p_message(ETL_NULLPTR), p_router(ETL_NULLPTR), period(0), - delta(etl::timer::state::INACTIVE), + delta(etl::timer::state::Inactive), destination_router_id(etl::imessage_bus::ALL_MESSAGE_ROUTERS), id(etl::timer::id::NO_TIMER), previous(etl::timer::id::NO_TIMER), @@ -105,7 +105,7 @@ namespace etl : p_message(&message_), p_router(&irouter_), period(period_), - delta(etl::timer::state::INACTIVE), + delta(etl::timer::state::Inactive), destination_router_id(destination_router_id_), id(id_), previous(etl::timer::id::NO_TIMER), @@ -119,7 +119,7 @@ namespace etl //******************************************* bool is_active() const { - return delta != etl::timer::state::INACTIVE; + return delta != etl::timer::state::Inactive; } //******************************************* @@ -127,7 +127,7 @@ namespace etl //******************************************* void set_inactive() { - delta = etl::timer::state::INACTIVE; + delta = etl::timer::state::Inactive; } const etl::imessage* p_message; @@ -271,7 +271,7 @@ namespace etl timer.previous = etl::timer::id::NO_TIMER; timer.next = etl::timer::id::NO_TIMER; - timer.delta = etl::timer::state::INACTIVE; + timer.delta = etl::timer::state::Inactive; } //******************************* @@ -280,6 +280,12 @@ namespace etl return ptimers[head]; } + //******************************* + const etl::message_timer_data& front() const + { + return ptimers[head]; + } + //******************************* etl::timer::id::type begin() { @@ -506,7 +512,7 @@ namespace etl if (timer.id != etl::timer::id::NO_TIMER) { // Has a valid period. - if (timer.period != etl::timer::state::INACTIVE) + if (timer.period != etl::timer::state::Inactive) { ETL_DISABLE_TIMER_UPDATES; if (timer.is_active()) @@ -583,6 +589,18 @@ namespace etl return false; } + //******************************************* + /// Get the time to the next timer event. + //******************************************* + uint32_t time_to_next() const + { + ETL_DISABLE_TIMER_UPDATES; + uint32_t delta = active_list.front().delta; + ETL_ENABLE_TIMER_UPDATES; + + return delta; + } + protected: //******************************************* @@ -629,7 +647,7 @@ namespace etl #endif #endif - etl::timer_semaphore_t process_semaphore; + mutable etl::timer_semaphore_t process_semaphore; #endif uint_least8_t registered_timers; diff --git a/include/etl/message_timer_atomic.h b/include/etl/message_timer_atomic.h index 4f79904bb..97fb31838 100644 --- a/include/etl/message_timer_atomic.h +++ b/include/etl/message_timer_atomic.h @@ -225,7 +225,7 @@ namespace etl if (timer.id != etl::timer::id::NO_TIMER) { // Has a valid period. - if (timer.period != etl::timer::state::INACTIVE) + if (timer.period != etl::timer::state::Inactive) { ++process_semaphore; if (timer.is_active()) @@ -302,6 +302,18 @@ namespace etl return false; } + //******************************************* + /// Get the time to the next timer event. + //******************************************* + uint32_t time_to_next() const + { + ++process_semaphore; + uint32_t delta = active_list.front().delta; + --process_semaphore; + + return delta; + } + protected: //************************************************************************* @@ -313,7 +325,7 @@ namespace etl : p_message(ETL_NULLPTR) , p_router(ETL_NULLPTR) , period(0U) - , delta(etl::timer::state::INACTIVE) + , delta(etl::timer::state::Inactive) , destination_router_id(etl::imessage_bus::ALL_MESSAGE_ROUTERS) , id(etl::timer::id::NO_TIMER) , previous(etl::timer::id::NO_TIMER) @@ -332,7 +344,7 @@ namespace etl : p_message(&message_) , p_router(&irouter_) , period(period_) - , delta(etl::timer::state::INACTIVE) + , delta(etl::timer::state::Inactive) , destination_router_id(destination_router_id_) , id(id_) , previous(etl::timer::id::NO_TIMER) @@ -346,7 +358,7 @@ namespace etl //******************************************* bool is_active() const { - return delta != etl::timer::state::INACTIVE; + return delta != etl::timer::state::Inactive; } //******************************************* @@ -354,7 +366,7 @@ namespace etl //******************************************* void set_inactive() { - delta = etl::timer::state::INACTIVE; + delta = etl::timer::state::Inactive; } const etl::imessage* p_message; @@ -405,10 +417,10 @@ namespace etl //******************************* timer_list(timer_data* ptimers_) - : head(etl::timer::id::NO_TIMER), - tail(etl::timer::id::NO_TIMER), - current(etl::timer::id::NO_TIMER), - ptimers(ptimers_) + : head(etl::timer::id::NO_TIMER) + , tail(etl::timer::id::NO_TIMER) + , current(etl::timer::id::NO_TIMER) + , ptimers(ptimers_) { } @@ -518,7 +530,7 @@ namespace etl timer.previous = etl::timer::id::NO_TIMER; timer.next = etl::timer::id::NO_TIMER; - timer.delta = etl::timer::state::INACTIVE; + timer.delta = etl::timer::state::Inactive; } //******************************* @@ -527,6 +539,12 @@ namespace etl return ptimers[head]; } + //******************************* + const timer_data& front() const + { + return ptimers[head]; + } + //******************************* etl::timer::id::type begin() { @@ -581,7 +599,7 @@ namespace etl timer_list active_list; bool enabled; - TSemaphore process_semaphore; + mutable TSemaphore process_semaphore; uint_least8_t registered_timers; public: diff --git a/include/etl/message_timer_interrupt.h b/include/etl/message_timer_interrupt.h index e7a5a4044..c906d8efb 100644 --- a/include/etl/message_timer_interrupt.h +++ b/include/etl/message_timer_interrupt.h @@ -232,7 +232,7 @@ namespace etl if (timer.id != etl::timer::id::NO_TIMER) { // Has a valid period. - if (timer.period != etl::timer::state::INACTIVE) + if (timer.period != etl::timer::state::Inactive) { TInterruptGuard guard; (void)guard; // Silence 'unused variable warnings. @@ -311,6 +311,19 @@ namespace etl return false; } + //******************************************* + /// Get the time to the next timer event. + //******************************************* + uint32_t time_to_next() const + { + TInterruptGuard guard; + (void)guard; // Silence 'unused variable warnings. + + uint32_t delta = active_list.front().delta; + + return delta; + } + protected: //************************************************************************* @@ -322,7 +335,7 @@ namespace etl : p_message(ETL_NULLPTR) , p_router(ETL_NULLPTR) , period(0) - , delta(etl::timer::state::INACTIVE) + , delta(etl::timer::state::Inactive) , destination_router_id(etl::imessage_bus::ALL_MESSAGE_ROUTERS) , id(etl::timer::id::NO_TIMER) , previous(etl::timer::id::NO_TIMER) @@ -341,7 +354,7 @@ namespace etl : p_message(&message_) , p_router(&irouter_) , period(period_) - , delta(etl::timer::state::INACTIVE) + , delta(etl::timer::state::Inactive) , destination_router_id(destination_router_id_) , id(id_) , previous(etl::timer::id::NO_TIMER) @@ -355,7 +368,7 @@ namespace etl //******************************************* bool is_active() const { - return delta != etl::timer::state::INACTIVE; + return delta != etl::timer::state::Inactive; } //******************************************* @@ -363,7 +376,7 @@ namespace etl //******************************************* void set_inactive() { - delta = etl::timer::state::INACTIVE; + delta = etl::timer::state::Inactive; } const etl::imessage* p_message; @@ -526,7 +539,7 @@ namespace etl timer.previous = etl::timer::id::NO_TIMER; timer.next = etl::timer::id::NO_TIMER; - timer.delta = etl::timer::state::INACTIVE; + timer.delta = etl::timer::state::Inactive; } //******************************* @@ -535,6 +548,12 @@ namespace etl return ptimers[head]; } + //******************************* + const timer_data& front() const + { + return ptimers[head]; + } + //******************************* etl::timer::id::type begin() { diff --git a/include/etl/message_timer_locked.h b/include/etl/message_timer_locked.h index cd9f7e788..cd44702e3 100644 --- a/include/etl/message_timer_locked.h +++ b/include/etl/message_timer_locked.h @@ -231,7 +231,7 @@ namespace etl if (timer.id != etl::timer::id::NO_TIMER) { // Has a valid period. - if (timer.period != etl::timer::state::INACTIVE) + if (timer.period != etl::timer::state::Inactive) { lock(); if (timer.is_active()) @@ -318,6 +318,18 @@ namespace etl unlock = unlock_; } + //******************************************* + /// Get the time to the next timer event. + //******************************************* + uint32_t time_to_next() const + { + lock(); + + uint32_t delta = active_list.front().delta; + + return delta; + } + protected: //************************************************************************* @@ -329,7 +341,7 @@ namespace etl : p_message(ETL_NULLPTR) , p_router(ETL_NULLPTR) , period(0) - , delta(etl::timer::state::INACTIVE) + , delta(etl::timer::state::Inactive) , destination_router_id(etl::imessage_bus::ALL_MESSAGE_ROUTERS) , id(etl::timer::id::NO_TIMER) , previous(etl::timer::id::NO_TIMER) @@ -348,7 +360,7 @@ namespace etl : p_message(&message_) , p_router(&irouter_) , period(period_) - , delta(etl::timer::state::INACTIVE) + , delta(etl::timer::state::Inactive) , destination_router_id(destination_router_id_) , id(id_) , previous(etl::timer::id::NO_TIMER) @@ -362,7 +374,7 @@ namespace etl //******************************************* bool is_active() const { - return delta != etl::timer::state::INACTIVE; + return delta != etl::timer::state::Inactive; } //******************************************* @@ -370,7 +382,7 @@ namespace etl //******************************************* void set_inactive() { - delta = etl::timer::state::INACTIVE; + delta = etl::timer::state::Inactive; } const etl::imessage* p_message; @@ -533,7 +545,7 @@ namespace etl timer.previous = etl::timer::id::NO_TIMER; timer.next = etl::timer::id::NO_TIMER; - timer.delta = etl::timer::state::INACTIVE; + timer.delta = etl::timer::state::Inactive; } //******************************* @@ -542,6 +554,12 @@ namespace etl return ptimers[head]; } + //******************************* + const timer_data& front() const + { + return ptimers[head]; + } + //******************************* etl::timer::id::type begin() { diff --git a/include/etl/multi_span.h b/include/etl/multi_span.h index c24e893a1..7f98865dc 100644 --- a/include/etl/multi_span.h +++ b/include/etl/multi_span.h @@ -134,7 +134,7 @@ namespace etl //************************************************************************* pointer operator ->() { - return *p_value; + return &operator*(); } //************************************************************************* @@ -142,7 +142,7 @@ namespace etl //************************************************************************* const_pointer operator ->() const { - return *p_value; + return &operator*(); } //************************************************************************* diff --git a/include/etl/multimap.h b/include/etl/multimap.h index 7e6f71b1a..a6411cc37 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -613,7 +613,7 @@ namespace etl size_type current_size; ///< The number of the used nodes. const size_type CAPACITY; ///< The maximum size of the map. Node* root_node; ///< The node that acts as the multimap root. - ETL_DECLARE_DEBUG_COUNT + ETL_DECLARE_DEBUG_COUNT; }; //*************************************************************************** @@ -1544,7 +1544,7 @@ namespace etl { Data_Node& node = allocate_data_node(); ::new (&node.value) const value_type(value); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return node; } @@ -1556,7 +1556,7 @@ namespace etl { Data_Node& node = allocate_data_node(); ::new (&node.value) const value_type(etl::move(value)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return node; } #endif @@ -1577,7 +1577,7 @@ namespace etl { node.value.~value_type(); p_node_pool->release(&node); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* diff --git a/include/etl/multiset.h b/include/etl/multiset.h index 0ab3671d4..d2c35f680 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -612,7 +612,7 @@ namespace etl size_type current_size; ///< The number of the used nodes. const size_type CAPACITY; ///< The maximum size of the set. Node* root_node; ///< The node that acts as the multiset root. - ETL_DECLARE_DEBUG_COUNT + ETL_DECLARE_DEBUG_COUNT; }; //*************************************************************************** @@ -1448,6 +1448,8 @@ namespace etl // Skip if doing self assignment if (this != &rhs) { + clear(); + typename etl::imultiset::iterator from = rhs.begin(); while (from != rhs.end()) @@ -1530,7 +1532,7 @@ namespace etl { Data_Node& node = allocate_data_node(); ::new ((void*)&node.value) value_type(value); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return node; } @@ -1542,7 +1544,7 @@ namespace etl { Data_Node& node = allocate_data_node(); ::new ((void*)&node.value) value_type(etl::move(value)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return node; } #endif @@ -1563,7 +1565,7 @@ namespace etl { node.value.~value_type(); p_node_pool->release(&node); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* diff --git a/include/etl/mutex/mutex_cmsis_os2.h b/include/etl/mutex/mutex_cmsis_os2.h index 202a2e758..42f177150 100644 --- a/include/etl/mutex/mutex_cmsis_os2.h +++ b/include/etl/mutex/mutex_cmsis_os2.h @@ -44,12 +44,17 @@ namespace etl public: mutex() - : id(0) + : id(NULL) { osMutexAttr_t attr = { "ETL", osMutexRecursive | osMutexPrioInherit | osMutexRobust, 0, 0 }; id = osMutexNew(&attr); } + ~mutex() + { + osMutexDelete(id); + } + void lock() { osMutexAcquire(id, osWaitForever); diff --git a/include/etl/optional.h b/include/etl/optional.h index 7f20e05fb..d85763d25 100644 --- a/include/etl/optional.h +++ b/include/etl/optional.h @@ -115,6 +115,8 @@ namespace etl { public: + typedef T value_type; + //*************************************************************************** /// Constructor. //*************************************************************************** @@ -133,7 +135,7 @@ namespace etl { } -#include "etl/private/diagnostic_uninitialized_push.h" +#include "private/diagnostic_uninitialized_push.h" //*************************************************************************** /// Copy constructor. //*************************************************************************** @@ -145,7 +147,7 @@ namespace etl storage.construct(other.value()); } } -#include "etl/private/diagnostic_pop.h" +#include "private/diagnostic_pop.h" #if ETL_USING_CPP11 //*************************************************************************** @@ -479,7 +481,7 @@ namespace etl //************************************************************************* /// Emplaces a value. ///\param args The arguments to construct with. - //************************************************************************* + //************************************************************************* template ETL_CONSTEXPR20_STL void emplace(TArgs&& ... args) @@ -487,6 +489,24 @@ namespace etl storage.construct(etl::forward(args)...); } #else + //************************************************************************* + /// Emplaces a value. + /// 1 parameter. + //************************************************************************* + T& emplace() + { + if (has_value()) + { + // Destroy the old one. + storage.destroy(); + } + + T* p = ::new (&storage.u.value) T(); + storage.valid = true; + + return *p; + } + //************************************************************************* /// Emplaces a value. /// 1 parameter. @@ -566,6 +586,8 @@ namespace etl private: + struct dummy_t {}; + struct storage_type { //******************************* @@ -641,7 +663,7 @@ namespace etl { ETL_CONSTEXPR20_STL union_type() - : dummy(0) + : dummy() { } @@ -650,8 +672,8 @@ namespace etl { } - char dummy; - T value; + dummy_t dummy; + T value; } u; bool valid; @@ -661,7 +683,7 @@ namespace etl }; //***************************************************************************** - /// For POD types. + /// For arithmetic or pointer types. ///\tparam T The type to store. ///\ingroup utilities //***************************************************************************** @@ -670,6 +692,8 @@ namespace etl { public: + typedef T value_type; + //*************************************************************************** /// Constructor. //*************************************************************************** @@ -713,8 +737,8 @@ namespace etl //*************************************************************************** ETL_CONSTEXPR14 optional(const T& value_) : valid(true) + , storage(value_) { - storage.u.value = value_; } #if ETL_USING_CPP11 @@ -723,8 +747,8 @@ namespace etl //*************************************************************************** ETL_CONSTEXPR14 optional(T&& value_) : valid(true) + , storage(etl::move(value_)) { - storage.u.value = etl::move(value_); } #endif @@ -744,8 +768,8 @@ namespace etl { if (this != &other) { - storage.u = other.storage.u; - valid = other.valid; + storage.value = other.storage.value; + valid = other.valid; } return *this; @@ -759,8 +783,8 @@ namespace etl { if (this != &other) { - storage.u = etl::move(other.storage.u); - valid = other.valid; + storage.value = etl::move(other.storage.value); + valid = other.valid; } return *this; @@ -772,7 +796,7 @@ namespace etl //*************************************************************************** ETL_CONSTEXPR14 optional& operator =(const T& value_) { - storage.u.value = value_; + storage.value = value_; valid = true; return *this; @@ -784,7 +808,7 @@ namespace etl //*************************************************************************** ETL_CONSTEXPR14 optional& operator =(T&& value_) { - storage.u.value = etl::move(value_); + storage.value = etl::move(value_); valid = true; return *this; @@ -800,7 +824,7 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(optional_invalid)); #endif - return &storage.u.value; + return &storage.value; } //*************************************************************************** @@ -812,7 +836,7 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(optional_invalid)); #endif - return &storage.u.value; + return &storage.value; } //*************************************************************************** @@ -824,7 +848,7 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(optional_invalid)); #endif - return storage.u.value; + return storage.value; } //*************************************************************************** @@ -836,7 +860,7 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(optional_invalid)); #endif - return storage.u.value; + return storage.value; } #if ETL_USING_CPP11 @@ -849,7 +873,7 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(optional_invalid)); #endif - return etl::move(storage.u.value); + return etl::move(storage.value); } //*************************************************************************** @@ -861,14 +885,14 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(optional_invalid)); #endif - return etl::move(storage.u.value); + return etl::move(storage.value); } #endif //*************************************************************************** /// Bool conversion operator. //*************************************************************************** - ETL_CONSTEXPR14 + ETL_CONSTEXPR14 ETL_EXPLICIT operator bool() const { return valid; @@ -891,7 +915,7 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(optional_invalid)); #endif - return storage.u.value; + return storage.value; } //*************************************************************************** @@ -903,7 +927,7 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(optional_invalid)); #endif - return storage.u.value; + return storage.value; } //*************************************************************************** @@ -924,7 +948,7 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(optional_invalid)); #endif - return etl::move(storage.u.value); + return etl::move(storage.value); } //*************************************************************************** @@ -936,7 +960,7 @@ namespace etl ETL_ASSERT(valid, ETL_ERROR(optional_invalid)); #endif - return etl::move(storage.u.value); + return etl::move(storage.value); } //*************************************************************************** @@ -1002,10 +1026,20 @@ namespace etl template ETL_CONSTEXPR14 void emplace(Args && ... args) { - storage.u.value = T(ETL_OR_STD::forward(args)...); + storage.value = T(ETL_OR_STD::forward(args)...); valid = true; } #else + //************************************************************************* + /// Emplaces a value. + /// 0 parameters. + //************************************************************************* + void emplace() + { + storage.value = value_type(); + valid = true; + } + //************************************************************************* /// Emplaces a value. /// 1 parameter. @@ -1013,7 +1047,7 @@ namespace etl template void emplace(const T1& value1) { - storage.u.value = value1; + storage.value = value1; valid = true; } @@ -1024,7 +1058,7 @@ namespace etl template void emplace(const T1& value1, const T2& value2) { - storage.u.value = T(value1, value2); + storage.value = T(value1, value2); valid = true; } @@ -1035,7 +1069,7 @@ namespace etl template void emplace(const T1& value1, const T2& value2, const T3& value3) { - storage.u.value = T(value1, value2, value3); + storage.value = T(value1, value2, value3); valid = true; } @@ -1046,7 +1080,7 @@ namespace etl template void emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4) { - storage.u.value = T(value1, value2, value3, value4); + storage.value = T(value1, value2, value3, value4); valid = true; } #endif @@ -1055,30 +1089,28 @@ namespace etl bool valid; - struct storage_type + struct dummy_t {}; + + union storage_type { - storage_type() + dummy_t dummy; + T value; + + ETL_CONSTEXPR storage_type() + : dummy() { } - union union_type + ETL_CONSTEXPR storage_type(const T& v) + : value(v) { - union_type() - : dummy(0) - { - } - - char dummy; - T value; - }; - - union_type u; + } }; storage_type storage; }; -#include "etl/private/diagnostic_uninitialized_push.h" +#include "private/diagnostic_uninitialized_push.h" //*************************************************************************** /// Equality operator. cppreference 1 @@ -1372,7 +1404,7 @@ namespace etl return rhs.has_value() ? lhs >= rhs.value() : true; } -#include "etl/private/diagnostic_pop.h" +#include "private/diagnostic_pop.h" //*************************************************************************** /// Make an optional. diff --git a/include/etl/overload.h b/include/etl/overload.h index 5b636c942..7ee793617 100644 --- a/include/etl/overload.h +++ b/include/etl/overload.h @@ -35,10 +35,9 @@ SOFTWARE. #include "utility.h" #include "type_traits.h" -#if ETL_USING_CPP17 - namespace etl { +#if ETL_USING_CPP17 //************************************************************************* /// Variadic template definition of overload for C++17 and above. //************************************************************************* @@ -61,8 +60,49 @@ namespace etl { return overload{ etl::forward(overloads)... }; } -} +#elif ETL_USING_CPP11 + //************************************************************************* + /// Variadic template definition of overload for C++11 & C++14. + //************************************************************************* + template + struct overload; + + //************************************************************************* + /// Specialisation for multiple overloads. + //************************************************************************* + template + struct overload : TOverload, overload + { + overload(TOverload first, TRest... rest) : TOverload(first), overload(rest...) + { + } + + using TOverload::operator(); + using overload::operator(); + }; + //************************************************************************* + /// Specialisation for one overload. + //************************************************************************* + template + struct overload : TOverload + { + overload(TOverload first) : TOverload(first) + { + } + + using TOverload::operator(); + }; + + //************************************************************************* + /// Make an overload. + //************************************************************************* + template + overload make_overload(TRest... overloads) + { + return overload(overloads...); + } #endif +} #endif diff --git a/include/etl/parameter_pack.h b/include/etl/parameter_pack.h index 6883cdbb8..a5e5ee7f2 100644 --- a/include/etl/parameter_pack.h +++ b/include/etl/parameter_pack.h @@ -134,7 +134,7 @@ namespace etl inline constexpr size_t parameter_pack_v = etl::parameter_pack::template index_of_type::value; #endif -#if ETL_USING_CPP14 +#if ETL_USING_CPP17 && (!ETL_USING_GCC_COMPILER || (__GNUC__ > 7)) //*********************************** template template diff --git a/include/etl/platform.h b/include/etl/platform.h index 6561d2b99..d53d54608 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -63,6 +63,9 @@ SOFTWARE. #include "etl_profile.h" #endif +// Null statement +#define ETL_DO_NOTHING static_cast(0) + // Determine the bit width of the platform. #define ETL_PLATFORM_16BIT (UINT16_MAX == UINTPTR_MAX) #define ETL_PLATFORM_32BIT (UINT32_MAX == UINTPTR_MAX) @@ -231,6 +234,14 @@ SOFTWARE. #define ETL_HAS_MUTABLE_ARRAY_VIEW 0 #endif +//************************************* +// Indicate if etl::imassage is to be non-virtual. +#if defined(ETL_MESSAGES_ARE_NOT_VIRTUAL) + #define ETL_HAS_VIRTUAL_MESSAGES 0 +#else + #define ETL_HAS_VIRTUAL_MESSAGES 1 +#endif + //************************************* // The macros below are dependent on the profile. // C++11 @@ -330,6 +341,14 @@ SOFTWARE. #define ETL_CONSTEXPR20_STL #endif +//************************************* +// C++23 +#if ETL_USING_CPP23 && !defined(ETL_FORCE_NO_ADVANCED_CPP) + #define ETL_ASSUME(expression) [[assume(expression)]] +#else + #define ETL_ASSUME ETL_DO_NOTHING +#endif + //************************************* // Determine if the ETL can use char8_t type. #if ETL_USING_8BIT_TYPES @@ -449,7 +468,7 @@ namespace etl static ETL_CONSTANT bool using_generic_compiler = (ETL_USING_GENERIC_COMPILER == 1); static ETL_CONSTANT bool using_legacy_bitset = (ETL_USING_LEGACY_BITSET == 1); static ETL_CONSTANT bool using_exceptions = (ETL_USING_EXCEPTIONS == 1); - + // Has... static ETL_CONSTANT bool has_initializer_list = (ETL_HAS_INITIALIZER_LIST == 1); static ETL_CONSTANT bool has_8bit_types = (ETL_USING_8BIT_TYPES == 1); @@ -467,10 +486,10 @@ namespace etl static ETL_CONSTANT bool has_ivector_repair = (ETL_HAS_IVECTOR_REPAIR == 1); static ETL_CONSTANT bool has_mutable_array_view = (ETL_HAS_MUTABLE_ARRAY_VIEW == 1); static ETL_CONSTANT bool has_ideque_repair = (ETL_HAS_IDEQUE_REPAIR == 1); + static ETL_CONSTANT bool has_virtual_messages = (ETL_HAS_VIRTUAL_MESSAGES == 1); // Is... static ETL_CONSTANT bool is_debug_build = (ETL_IS_DEBUG_BUILD == 1); - } } diff --git a/include/etl/priority_queue.h b/include/etl/priority_queue.h index d4222090f..a920d7535 100644 --- a/include/etl/priority_queue.h +++ b/include/etl/priority_queue.h @@ -197,6 +197,22 @@ namespace etl etl::push_heap(container.begin(), container.end(), compare); } #else + //************************************************************************* + /// Emplaces a value to the queue. + /// If asserts or exceptions are enabled, throws an etl::priority_queue_full + /// is the priority queue is already full. + ///\param value The value to push to the queue. + //************************************************************************* + void emplace() + { + ETL_ASSERT(!full(), ETL_ERROR(etl::priority_queue_full)); + + // Put element at end + container.emplace_back(); + // Make elements in container into heap + etl::push_heap(container.begin(), container.end(), compare); + } + //************************************************************************* /// Emplaces a value to the queue. /// If asserts or exceptions are enabled, throws an etl::priority_queue_full @@ -383,6 +399,7 @@ namespace etl { if (&rhs != this) { + clear(); move(etl::move(rhs)); } @@ -519,6 +536,7 @@ namespace etl { if (&rhs != this) { + etl::ipriority_queue::clear(); etl::ipriority_queue::move(etl::move(rhs)); } diff --git a/include/etl/private/bitset_new.h b/include/etl/private/bitset_new.h index a4b724c92..63462f211 100644 --- a/include/etl/private/bitset_new.h +++ b/include/etl/private/bitset_new.h @@ -1318,8 +1318,6 @@ namespace etl const element_type mask = element_type(element_type(1) << position); return (buffer & mask) != 0U; - - return false; } //************************************************************************* @@ -3032,8 +3030,6 @@ namespace etl const element_type mask = element_type(element_type(1) << position); return (*pbuffer & mask) != 0U; - - return false; } //************************************************************************* diff --git a/include/etl/private/diagnostic_stringop_overread_push.h b/include/etl/private/diagnostic_stringop_overread_push.h index 4069bf7f9..6d635f049 100644 --- a/include/etl/private/diagnostic_stringop_overread_push.h +++ b/include/etl/private/diagnostic_stringop_overread_push.h @@ -33,11 +33,11 @@ SOFTWARE. * This file is intended to evaluated multiple times by design. */ -#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__) - #pragma GCC diagnostic push +#if defined(__GNUC__) && (__GNUC__ >= 11) && !defined(__clang__) && !defined(__llvm__) + #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-overread" #endif #if defined(__clang__) || defined(__llvm__) - #pragma clang diagnostic push -#endif \ No newline at end of file + #pragma clang diagnostic push +#endif diff --git a/include/etl/private/ivectorpointer.h b/include/etl/private/ivectorpointer.h index ac1e07466..52b9924ca 100644 --- a/include/etl/private/ivectorpointer.h +++ b/include/etl/private/ivectorpointer.h @@ -349,6 +349,18 @@ namespace etl base_t::push_back(value); } + //********************************************************************* + /// Constructs a value at the end of the vector. + /// If asserts or exceptions are enabled, emits vector_full if the vector is already full. + ///\param value The value to add. + //********************************************************************* + reference emplace_back() + { + base_t::emplace_back(ETL_NULLPTR); + + return back(); + } + //********************************************************************* /// Constructs a value at the end of the vector. /// If asserts or exceptions are enabled, emits vector_full if the vector is already full. @@ -381,6 +393,14 @@ namespace etl return iterator(base_t::insert(base_t::iterator(position), value)); } + //************************************************************************* + /// Emplaces a value to the vector at the specified position. + //************************************************************************* + iterator emplace(const_iterator position) + { + return iterator(base_t::emplace(base_t::iterator(position), ETL_NULLPTR)); + } + //************************************************************************* /// Emplaces a value to the vector at the specified position. //************************************************************************* diff --git a/include/etl/private/pvoidvector.h b/include/etl/private/pvoidvector.h index 0561082ed..6ec32092a 100644 --- a/include/etl/private/pvoidvector.h +++ b/include/etl/private/pvoidvector.h @@ -462,6 +462,29 @@ namespace etl return position_; } + //************************************************************************* + /// Emplaces a value to the vector at the specified position. + /// If asserts or exceptions are enabled, emits vector_full if the vector is already full. + //************************************************************************* + iterator emplace(const_iterator position) + { + ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full)); + + iterator position_ = to_iterator(position); + + if (position_ != end()) + { + ++p_end; + etl::copy_backward(position_, end() - 1, end()); + *position_ = ETL_NULLPTR; + } + else + { + *p_end++ = ETL_NULLPTR; + } + + return position_; + } //************************************************************************* /// Emplaces a value to the vector at the specified position. diff --git a/include/etl/private/variant_legacy.h b/include/etl/private/variant_legacy.h index 1743558e6..c1b825668 100644 --- a/include/etl/private/variant_legacy.h +++ b/include/etl/private/variant_legacy.h @@ -460,12 +460,12 @@ namespace etl /// Default constructor. /// Sets the state of the instance to containing no valid data. //*************************************************************************** -#include "etl/private/diagnostic_uninitialized_push.h" +#include "diagnostic_uninitialized_push.h" variant() : type_id(UNSUPPORTED_TYPE_ID) { } -#include "etl/private/diagnostic_pop.h" +#include "diagnostic_pop.h" //*************************************************************************** /// Constructor that catches any types that are not supported. @@ -484,7 +484,7 @@ namespace etl /// Copy constructor. ///\param other The other variant object to copy. //*************************************************************************** -#include "etl/private/diagnostic_uninitialized_push.h" +#include "diagnostic_uninitialized_push.h" variant(const variant& other) { switch (other.type_id) @@ -502,7 +502,7 @@ namespace etl type_id = other.type_id; } -#include "etl/private/diagnostic_pop.h" +#include "diagnostic_pop.h" #if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_VARIANT_FORCE_CPP03_IMPLEMENTATION) //************************************************************************* @@ -520,6 +520,21 @@ namespace etl return *static_cast(data); } #else + //*************************************************************************** + /// Emplace with one constructor parameter. + //*************************************************************************** + template + T& emplace() + { + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + + destruct_current(); + ::new (static_cast(data)) T(); + type_id = Type_Id_Lookup::type_id; + + return *static_cast(data); + } + //*************************************************************************** /// Emplace with one constructor parameter. //*************************************************************************** @@ -854,8 +869,7 @@ namespace etl } private: - -#include "etl/private/diagnostic_uninitialized_push.h" +#include "diagnostic_uninitialized_push.h" //*************************************************************************** /// Destruct the current occupant of the variant. //*************************************************************************** @@ -876,7 +890,7 @@ namespace etl type_id = UNSUPPORTED_TYPE_ID; } -#include "etl/private/diagnostic_pop.h" +#include "diagnostic_pop.h" //*************************************************************************** /// The internal storage. @@ -995,4 +1009,3 @@ namespace etl } #endif } - diff --git a/include/etl/private/variant_variadic.h b/include/etl/private/variant_variadic.h index c7ee4d1f6..6a8d9ab0b 100644 --- a/include/etl/private/variant_variadic.h +++ b/include/etl/private/variant_variadic.h @@ -430,7 +430,7 @@ namespace etl /// 'Bad variant access' exception for the variant class. ///\ingroup variant //*************************************************************************** - class bad_variant_access : public variant_exception + class bad_variant_access : public variant_exception { public: bad_variant_access(string_type file_name_, numeric_type line_number_) @@ -524,7 +524,7 @@ namespace etl /// Default constructor. /// Sets the state of the instance to containing no valid data. //*************************************************************************** -#include "etl/private/diagnostic_uninitialized_push.h" +#include "diagnostic_uninitialized_push.h" ETL_CONSTEXPR14 variant() { using type = typename etl::private_variant::parameter_pack::template type_from_index<0U>::type; @@ -533,12 +533,12 @@ namespace etl operation = operation_type::value, etl::is_move_constructible::value>::do_operation; type_id = 0U; } -#include "etl/private/diagnostic_pop.h" +#include "diagnostic_pop.h" //*************************************************************************** /// Construct from a value. //*************************************************************************** -#include "etl/private/diagnostic_uninitialized_push.h" +#include "diagnostic_uninitialized_push.h" template , variant>::value, int> = 0> ETL_CONSTEXPR14 variant(T&& value) : operation(operation_type, etl::is_copy_constructible>::value, etl::is_move_constructible>::value>::do_operation) @@ -548,12 +548,12 @@ namespace etl construct_in_place>(data, etl::forward(value)); } -#include "etl/private/diagnostic_pop.h" +#include "diagnostic_pop.h" //*************************************************************************** /// Construct from arguments. //*************************************************************************** -#include "etl/private/diagnostic_uninitialized_push.h" +#include "diagnostic_uninitialized_push.h" template ETL_CONSTEXPR14 explicit variant(etl::in_place_type_t, TArgs&&... args) : operation(operation_type, etl::is_copy_constructible>::value, etl::is_move_constructible>::value>::do_operation) @@ -563,12 +563,12 @@ namespace etl construct_in_place_args>(data, etl::forward(args)...); } -#include "etl/private/diagnostic_pop.h" +#include "diagnostic_pop.h" //*************************************************************************** /// Construct from arguments. //*************************************************************************** -#include "etl/private/diagnostic_uninitialized_push.h" +#include "diagnostic_uninitialized_push.h" template ETL_CONSTEXPR14 explicit variant(etl::in_place_index_t, TArgs&&... args) : type_id(Index) @@ -580,13 +580,13 @@ namespace etl operation = operation_type::value, etl::is_move_constructible::value>::do_operation; } -#include "etl/private/diagnostic_pop.h" +#include "diagnostic_pop.h" #if ETL_HAS_INITIALIZER_LIST //*************************************************************************** /// Construct from type, initializer_list and arguments. //*************************************************************************** -#include "etl/private/diagnostic_uninitialized_push.h" +#include "diagnostic_uninitialized_push.h" template ETL_CONSTEXPR14 explicit variant(etl::in_place_type_t, std::initializer_list init, TArgs&&... args) : operation(operation_type, etl::is_copy_constructible>::value, etl::is_move_constructible>::value>::do_operation) @@ -596,12 +596,12 @@ namespace etl construct_in_place_args>(data, init, etl::forward(args)...); } -#include "etl/private/diagnostic_pop.h" +#include "diagnostic_pop.h" //*************************************************************************** /// Construct from index, initializer_list and arguments. //*************************************************************************** -#include "etl/private/diagnostic_uninitialized_push.h" +#include "diagnostic_uninitialized_push.h" template ETL_CONSTEXPR14 explicit variant(etl::in_place_index_t, std::initializer_list init, TArgs&&... args) : type_id(Index) @@ -613,14 +613,14 @@ namespace etl operation = operation_type::value, etl::is_move_constructible::value>::do_operation; } -#include "etl/private/diagnostic_pop.h" +#include "diagnostic_pop.h" #endif //*************************************************************************** /// Copy constructor. ///\param other The other variant object to copy. //*************************************************************************** -#include "etl/private/diagnostic_uninitialized_push.h" +#include "diagnostic_uninitialized_push.h" ETL_CONSTEXPR14 variant(const variant& other) : operation(other.operation) , type_id(other.type_id) @@ -637,13 +637,13 @@ namespace etl } } } -#include "etl/private/diagnostic_pop.h" +#include "diagnostic_pop.h" //*************************************************************************** /// Move constructor. ///\param other The other variant object to copy. //*************************************************************************** -#include "etl/private/diagnostic_uninitialized_push.h" +#include "diagnostic_uninitialized_push.h" ETL_CONSTEXPR14 variant(variant&& other) : operation(other.operation) , type_id(other.type_id) @@ -664,7 +664,7 @@ namespace etl type_id = variant_npos; } } -#include "etl/private/diagnostic_pop.h" +#include "diagnostic_pop.h" //*************************************************************************** /// Destructor. @@ -706,7 +706,7 @@ namespace etl //*************************************************************************** template typename etl::variant_alternative>::type& emplace(TArgs&&... args) - { + { static_assert(Index < etl::private_variant::parameter_pack::size, "Index out of range"); using type = typename etl::private_variant::parameter_pack::template type_from_index::type; @@ -826,7 +826,7 @@ namespace etl /// Accept an etl::visitor. //*************************************************************************** template - etl::enable_if_t::value, void> + etl::enable_if_t::value, void> accept(TVisitor& v) { #if ETL_USING_CPP17 && !defined(ETL_VARIANT_FORCE_CPP11) @@ -840,7 +840,7 @@ namespace etl /// Accept an etl::visitor. //*************************************************************************** template - etl::enable_if_t::value, void> + etl::enable_if_t::value, void> accept(TVisitor& v) const { #if ETL_USING_CPP17 && !defined(ETL_VARIANT_FORCE_CPP11) @@ -1125,7 +1125,7 @@ namespace etl { // Workaround for MSVC (2023/05/13) // It doesn't compile 'visitor.visit(etl::get(*this))' correctly for C++17 & C++20. - // Changed all of the instances for consistancy. + // Changed all of the instances for consistancy. auto& v = etl::get(*this); visitor.visit(v); return true; @@ -1146,7 +1146,7 @@ namespace etl { // Workaround for MSVC (2023/05/13) // It doesn't compile 'visitor.visit(etl::get(*this))' correctly for C++17 & C++20. - // Changed all of the instances for consistancy. + // Changed all of the instances for consistancy. auto& v = etl::get(*this); visitor.visit(v); return true; @@ -1700,7 +1700,7 @@ namespace etl struct do_visit_helper { using function_pointer = add_pointer_t; - + template static constexpr function_pointer fptr() noexcept { @@ -1715,10 +1715,10 @@ namespace etl static ETL_CONSTEXPR14 TRet do_visit(TCallable&& f, TVariant&& v, index_sequence, TVarRest&&... variants) { ETL_ASSERT(!v.valueless_by_exception(), ETL_ERROR(bad_variant_access)); - + using helper_t = do_visit_helper; using func_ptr = typename helper_t::function_pointer; - + constexpr func_ptr jmp_table[] { helper_t::template fptr()... diff --git a/include/etl/private/vector_base.h b/include/etl/private/vector_base.h index d55a41a1a..f137c61f8 100644 --- a/include/etl/private/vector_base.h +++ b/include/etl/private/vector_base.h @@ -168,7 +168,7 @@ namespace etl #endif const size_type CAPACITY; /// +//#include #include "determine_compiler.h" @@ -179,22 +179,24 @@ SOFTWARE. #endif // Language standard -#if ETL_USING_CPP23 - #define ETL_LANGUAGE_STANDARD 23 -#elif ETL_USING_CPP20 - #define ETL_LANGUAGE_STANDARD 20 -#elif ETL_USING_CPP17 - #define ETL_LANGUAGE_STANDARD 17 -#elif ETL_USING_CPP14 - #define ETL_LANGUAGE_STANDARD 14 -#elif ETL_USING_CPP11 - #define ETL_LANGUAGE_STANDARD 11 -#else - #define ETL_LANGUAGE_STANDARD 3 +#if !defined(ETL_LANGUAGE_STANDARD) + #if ETL_USING_CPP23 + #define ETL_LANGUAGE_STANDARD 23 + #elif ETL_USING_CPP20 + #define ETL_LANGUAGE_STANDARD 20 + #elif ETL_USING_CPP17 + #define ETL_LANGUAGE_STANDARD 17 + #elif ETL_USING_CPP14 + #define ETL_LANGUAGE_STANDARD 14 + #elif ETL_USING_CPP11 + #define ETL_LANGUAGE_STANDARD 11 + #else + #define ETL_LANGUAGE_STANDARD 3 + #endif #endif // NAN not defined or Rowley CrossWorks -#if !defined(NAN) || defined(__CROSSWORKS_ARM) || defined(ETL_COMPILER_ARM5) || defined(ARDUINO) +#if !defined(ETL_NO_CPP_NAN_SUPPORT) && (!defined(NAN) || defined(__CROSSWORKS_ARM) || defined(ETL_COMPILER_ARM5) || defined(ARDUINO)) #define ETL_NO_CPP_NAN_SUPPORT #endif diff --git a/include/etl/quantize.h b/include/etl/quantize.h index 26265b913..6f03e2d70 100644 --- a/include/etl/quantize.h +++ b/include/etl/quantize.h @@ -35,7 +35,7 @@ SOFTWARE. #include "functional.h" #include "type_traits.h" -#include +////#include #include namespace etl diff --git a/include/etl/queue.h b/include/etl/queue.h index b3521f397..751270940 100644 --- a/include/etl/queue.h +++ b/include/etl/queue.h @@ -193,7 +193,7 @@ namespace etl } ++current_size; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -206,7 +206,7 @@ namespace etl out = 0; } --current_size; - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* @@ -217,14 +217,14 @@ namespace etl in = 0; out = 0; current_size = 0; - ETL_RESET_DEBUG_COUNT + ETL_RESET_DEBUG_COUNT; } size_type in; ///< Where to input new data. size_type out; ///< Where to get the oldest data. size_type current_size; ///< The number of items in the queue. const size_type CAPACITY; ///< The maximum number of items in the queue. - ETL_DECLARE_DEBUG_COUNT ///< For internal debugging purposes. + ETL_DECLARE_DEBUG_COUNT; ///< For internal debugging purposes. }; @@ -349,6 +349,20 @@ namespace etl add_in(); } #else + //************************************************************************* + /// Constructs a value in the queue 'in place'. + /// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full. + ///\param value The value to use to construct the item to push to the queue. + //************************************************************************* + void emplace() + { +#if defined(ETL_CHECK_PUSH_POP) + ETL_ASSERT(!full(), ETL_ERROR(queue_full)); +#endif + ::new (&p_buffer[in]) T(); + add_in(); + } + //************************************************************************* /// Constructs a value in the queue 'in place'. /// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full. diff --git a/include/etl/queue_lockable.h b/include/etl/queue_lockable.h index f8a325b48..21841adc1 100644 --- a/include/etl/queue_lockable.h +++ b/include/etl/queue_lockable.h @@ -369,6 +369,20 @@ namespace etl return emplace_implementation(value1, value2, value3, value4); } + //************************************************************************* + /// Constructs a value in the queue 'in place'. + //************************************************************************* + bool emplace() + { + this->lock(); + + bool result = emplace_implementation(); + + this->unlock(); + + return result; + } + //************************************************************************* /// Constructs a value in the queue 'in place'. //************************************************************************* diff --git a/include/etl/queue_mpmc_mutex.h b/include/etl/queue_mpmc_mutex.h index 8c46df6bd..6e80d14f6 100644 --- a/include/etl/queue_mpmc_mutex.h +++ b/include/etl/queue_mpmc_mutex.h @@ -199,6 +199,21 @@ namespace etl return result; } #else + //************************************************************************* + /// Constructs a value in the queue 'in place'. + /// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full. + //************************************************************************* + bool emplace() + { + access.lock(); + + bool result = emplace_implementation(); + + access.unlock(); + + return result; + } + //************************************************************************* /// Constructs a value in the queue 'in place'. /// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full. @@ -470,6 +485,24 @@ namespace etl #else //************************************************************************* /// Constructs a value in the queue 'in place'. + //************************************************************************* + bool emplace_implementation() + { + if (current_size != MAX_SIZE) + { + ::new (&p_buffer[write_index]) T(); + + write_index = get_next_index(write_index, MAX_SIZE); + + ++current_size; + + return true; + } + + // Queue is full. + return false; + } + //************************************************************************* template bool emplace_implementation(const T1& value1) diff --git a/include/etl/queue_spsc_atomic.h b/include/etl/queue_spsc_atomic.h index b19e2aacd..d06dce2d9 100644 --- a/include/etl/queue_spsc_atomic.h +++ b/include/etl/queue_spsc_atomic.h @@ -272,6 +272,28 @@ namespace etl return false; } #else + //************************************************************************* + /// Constructs a value in the queue 'in place'. + /// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full. + //************************************************************************* + bool emplace() + { + size_type write_index = write.load(etl::memory_order_relaxed); + size_type next_index = get_next_index(write_index, RESERVED); + + if (next_index != read.load(etl::memory_order_acquire)) + { + ::new (&p_buffer[write_index]) T(); + + write.store(next_index, etl::memory_order_release); + + return true; + } + + // Queue is full. + return false; + } + //************************************************************************* /// Constructs a value in the queue 'in place'. /// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full. diff --git a/include/etl/queue_spsc_isr.h b/include/etl/queue_spsc_isr.h index eeb7d1557..0e9be3f19 100644 --- a/include/etl/queue_spsc_isr.h +++ b/include/etl/queue_spsc_isr.h @@ -262,6 +262,27 @@ namespace etl return false; } #else + //************************************************************************* + /// Constructs a value in the queue 'in place'. + /// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full. + //************************************************************************* + bool emplace_implementation() + { + if (current_size != MAX_SIZE) + { + ::new (&p_buffer[write_index]) T(); + + write_index = get_next_index(write_index, MAX_SIZE); + + ++current_size; + + return true; + } + + // Queue is full. + return false; + } + //************************************************************************* /// Constructs a value in the queue 'in place'. /// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full. @@ -528,6 +549,21 @@ namespace etl return result; } #else + //************************************************************************* + /// Constructs a value in the queue 'in place'. + /// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full. + //************************************************************************* + bool emplace() + { + TAccess::lock(); + + bool result = this->emplace_implementation(); + + TAccess::unlock(); + + return result; + } + //************************************************************************* /// Constructs a value in the queue 'in place'. /// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full. diff --git a/include/etl/queue_spsc_locked.h b/include/etl/queue_spsc_locked.h index 3495b2f43..a5e7ca1f0 100644 --- a/include/etl/queue_spsc_locked.h +++ b/include/etl/queue_spsc_locked.h @@ -320,6 +320,21 @@ namespace etl return emplace_implementation(value1, value2, value3, value4); } + //************************************************************************* + /// Constructs a value in the queue 'in place'. + /// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full. + //************************************************************************* + bool emplace() + { + lock(); + + bool result = emplace_implementation(); + + unlock(); + + return result; + } + //************************************************************************* /// Constructs a value in the queue 'in place'. /// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full. @@ -640,6 +655,26 @@ namespace etl return false; } #else + //************************************************************************* + /// Constructs a value in the queue 'in place'. + //************************************************************************* + bool emplace_implementation() + { + if (this->current_size != this->MAX_SIZE) + { + ::new (&p_buffer[this->write_index]) T(); + + this->write_index = this->get_next_index(this->write_index, this->MAX_SIZE); + + ++this->current_size; + + return true; + } + + // Queue is full. + return false; + } + //************************************************************************* /// Constructs a value in the queue 'in place'. //************************************************************************* diff --git a/include/etl/random.h b/include/etl/random.h index 0bca835e8..bd4097a0c 100644 --- a/include/etl/random.h +++ b/include/etl/random.h @@ -1,4 +1,4 @@ -///\file +///\file /****************************************************************************** The MIT License(MIT) diff --git a/include/etl/rescale.h b/include/etl/rescale.h index 9dfd63c63..924542a56 100644 --- a/include/etl/rescale.h +++ b/include/etl/rescale.h @@ -36,7 +36,7 @@ SOFTWARE. #include "type_traits.h" #include "algorithm.h" -#include +//#include #include namespace etl diff --git a/include/etl/set.h b/include/etl/set.h index e17e65006..6825d78c1 100644 --- a/include/etl/set.h +++ b/include/etl/set.h @@ -446,7 +446,7 @@ namespace etl size_type current_size; ///< The number of the used nodes. const size_type CAPACITY; ///< The maximum size of the set. Node* root_node; ///< The node that acts as the set root. - ETL_DECLARE_DEBUG_COUNT + ETL_DECLARE_DEBUG_COUNT; }; @@ -815,6 +815,8 @@ namespace etl // Skip if doing self assignment if (this != &rhs) { + this->clear(); + typename etl::iset::iterator from = rhs.begin(); while (from != rhs.end()) @@ -1363,7 +1365,7 @@ namespace etl { Data_Node& node = allocate_data_node(); ::new ((void*)&node.value) value_type(value); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return node; } @@ -1375,7 +1377,7 @@ namespace etl { Data_Node& node = allocate_data_node(); ::new ((void*)&node.value) value_type(etl::move(value)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return node; } #endif @@ -1396,7 +1398,7 @@ namespace etl { node.value.~value_type(); p_node_pool->release(&node); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* @@ -2603,6 +2605,8 @@ namespace etl // Skip if doing self assignment if (this != &rhs) { + this->clear(); + typename etl::iset::iterator from = rhs.begin(); while (from != rhs.end()) diff --git a/include/etl/span.h b/include/etl/span.h index 4517f15fc..797e35e5e 100644 --- a/include/etl/span.h +++ b/include/etl/span.h @@ -45,8 +45,8 @@ SOFTWARE. #include "private/dynamic_extent.h" -#if ETL_USING_STL && ETL_USING_CPP11 - #include +#if ETL_USING_CPP20 && ETL_USING_STL + #include #endif ///\defgroup span span @@ -113,64 +113,6 @@ namespace etl { } -#if ETL_USING_CPP11 - //************************************************************************* - /// Construct from etl::array. - //************************************************************************* - template , etl::remove_cv_t>::value, void>::type> - ETL_CONSTEXPR span(etl::array& a) ETL_NOEXCEPT - : pbegin(a.data()) - { - } - - //************************************************************************* - /// Construct from etl::array. - //************************************************************************* - template , etl::remove_cv_t>::value, void>::type> - ETL_CONSTEXPR span(const etl::array& a) ETL_NOEXCEPT - : pbegin(a.data()) - { - } -#else - //************************************************************************* - /// Construct from etl::array. - //************************************************************************* - template - ETL_CONSTEXPR span(etl::array& a, typename etl::enable_if<(N == Extent) && etl::is_same::type, typename etl::remove_cv::type>::value, void>::type* = 0) ETL_NOEXCEPT - : pbegin(a.data()) - { - } - - //************************************************************************* - /// Construct from etl::array. - //************************************************************************* - template - ETL_CONSTEXPR span(const etl::array& a, typename etl::enable_if<(N == Extent) && etl::is_same::type, typename etl::remove_cv::type>::value, void>::type* = 0) ETL_NOEXCEPT - : pbegin(a.data()) - { - } -#endif - -#if ETL_USING_STL && ETL_USING_CPP11 - //************************************************************************* - /// Construct from std::array. - //************************************************************************* - template , etl::remove_cv_t>::value, void>::type> - ETL_CONSTEXPR span(std::array& a) ETL_NOEXCEPT - : pbegin(a.data()) - { - } - - //************************************************************************* - /// Construct from std::array. - //************************************************************************* - template , etl::remove_cv_t>::value, void>::type> - ETL_CONSTEXPR span(const std::array& a) ETL_NOEXCEPT - : pbegin(a.data()) - { - } -#endif - #if ETL_USING_CPP11 //************************************************************************* /// Construct from a container or other type that supports @@ -347,25 +289,6 @@ namespace etl return pbegin[i]; } - ////************************************************************************* - ///// Compare two spans for equality. - ////************************************************************************* - //template ::type, value_type>::value, bool>::type = true> - //ETL_NODISCARD ETL_CONSTEXPR bool operator==(const etl::span& other) const ETL_NOEXCEPT - //{ - // return ((begin() == other.begin()) && (Extent == other.size())) || - // etl::equal(begin(), end(), other.begin(), other.end()); - //} - - ////************************************************************************* - ///// Compare two spans for non-equality. - ////************************************************************************* - //template ::type, value_type>::value, bool>::type = true> - //ETL_NODISCARD ETL_CONSTEXPR bool operator!=(const etl::span& other) const ETL_NOEXCEPT - //{ - // return !(*this == other); - //} - //************************************************************************* /// Obtains a span that is a view over the first COUNT elements of this span. //************************************************************************* @@ -447,7 +370,7 @@ namespace etl /// Span - Dynamic Extent //*************************************************************************** template - class span + class span { public: @@ -506,70 +429,6 @@ namespace etl { } -#if ETL_USING_CPP11 - //************************************************************************* - /// Construct from etl::array. - //************************************************************************* - template , etl::remove_cv_t>::value, void>::type> - ETL_CONSTEXPR span(etl::array& a) ETL_NOEXCEPT - : pbegin(a.data()) - , pend(a.data() + a.size()) - { - } - - //************************************************************************* - /// Construct from etl::array. - //************************************************************************* - template , etl::remove_cv_t>::value, void>::type> - ETL_CONSTEXPR span(const etl::array& a) ETL_NOEXCEPT - : pbegin(a.data()) - , pend(a.data() + a.size()) - { - } -#else - //************************************************************************* - /// Construct from etl::array. - //************************************************************************* - template - ETL_CONSTEXPR span(etl::array& a, typename etl::enable_if::type, typename etl::remove_cv::type>::value, void>::type* = 0) ETL_NOEXCEPT - : pbegin(a.data()) - , pend(a.data() + a.size()) - { - } - - //************************************************************************* - /// Construct from etl::array. - //************************************************************************* - template - ETL_CONSTEXPR span(const etl::array& a, typename etl::enable_if::type, typename etl::remove_cv::type>::value, void>::type* = 0) ETL_NOEXCEPT - : pbegin(a.data()) - , pend(a.data() + a.size()) - { - } -#endif - -#if ETL_USING_STL && ETL_USING_CPP11 - //************************************************************************* - /// Construct from std::array. - //************************************************************************* - template , etl::remove_cv_t>::value, void>::type> - ETL_CONSTEXPR span(std::array& a) ETL_NOEXCEPT - : pbegin(a.data()) - , pend(a.data() + a.size()) - { - } - - //************************************************************************* - /// Construct from std::array. - //************************************************************************* - template , etl::remove_cv_t>::value, void>::type> - ETL_CONSTEXPR span(const std::array& a) ETL_NOEXCEPT - : pbegin(a.data()) - , pend(a.data() + a.size()) - { - } -#endif - #if ETL_USING_CPP11 //************************************************************************* /// Construct from a container or other type that supports @@ -752,26 +611,6 @@ namespace etl return pbegin[i]; } - ////************************************************************************* - ///// Compare two spans for equality. - ////************************************************************************* - //template ::type, value_type>::value, bool>::type = true> - //ETL_NODISCARD ETL_CONSTEXPR bool operator==(const etl::span& other) const ETL_NOEXCEPT - //{ - // return (empty() && other.empty()) || - // ((begin() == other.begin()) && (end() == other.end())) || - // etl::equal(begin(), end(), other.begin(), other.end()); - //} - - ////************************************************************************* - ///// Compare two spans for non-equality. - ////************************************************************************* - //template ::type, value_type>::value, bool>::type = true> - //ETL_NODISCARD ETL_CONSTEXPR bool operator!=(const etl::span& other) const ETL_NOEXCEPT - //{ - // return !(*this == other); - //} - //************************************************************************* /// Obtains a span that is a view over the first COUNT elements of this span. //************************************************************************* diff --git a/include/etl/stack.h b/include/etl/stack.h index cea004430..f7c2bd62f 100644 --- a/include/etl/stack.h +++ b/include/etl/stack.h @@ -176,7 +176,7 @@ namespace etl void add_in() { top_index = current_size++; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -186,7 +186,7 @@ namespace etl { --top_index; --current_size; - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* @@ -196,13 +196,13 @@ namespace etl { top_index = 0; current_size = 0; - ETL_RESET_DEBUG_COUNT + ETL_RESET_DEBUG_COUNT; } size_type top_index; ///< The index of the top of the stack. size_type current_size; ///< The number of items in the stack. const size_type CAPACITY; ///< The maximum number of items in the stack. - ETL_DECLARE_DEBUG_COUNT ///< For internal debugging purposes. + ETL_DECLARE_DEBUG_COUNT; ///< For internal debugging purposes. }; //*************************************************************************** @@ -292,6 +292,20 @@ namespace etl ::new (&p_buffer[top_index]) T(etl::forward(args)...); } #else + //************************************************************************* + /// Constructs a value in the stack place'. + /// If asserts or exceptions are enabled, throws an etl::stack_full if the stack is already full. + ///\param value The value to push to the stack. + //************************************************************************* + void emplace() + { +#if defined(ETL_CHECK_PUSH_POP) + ETL_ASSERT(!full(), ETL_ERROR(stack_full)); +#endif + base_t::add_in(); + ::new (&p_buffer[top_index]) T(); + } + //************************************************************************* /// Constructs a value in the stack place'. /// If asserts or exceptions are enabled, throws an etl::stack_full if the stack is already full. diff --git a/include/etl/static_assert.h b/include/etl/static_assert.h index 4c281ade6..44af47d64 100644 --- a/include/etl/static_assert.h +++ b/include/etl/static_assert.h @@ -30,9 +30,10 @@ SOFTWARE. #define ETL_ETL_STATIC_ASSERT_INCLUDED #include "platform.h" +#include "macros.h" #if (ETL_USING_CPP11) - #define ETL_STATIC_ASSERT(Condition, Message) static_assert(Condition, Message) + #define ETL_STATIC_ASSERT2(Condition, Message) static_assert(Condition, Message) #else template struct ETL_ETL_STATIC_ASSERT_FAILED; @@ -42,11 +43,26 @@ SOFTWARE. #define ETL_SA1(a,b) a##b #define ETL_SA2(a,b) ETL_SA1(a,b) - #define ETL_STATIC_ASSERT(Condition, Message) \ + #define ETL_STATIC_ASSERT2(Condition, Message) \ enum \ { \ - ETL_SA2(dummy, __LINE__) = sizeof(ETL_ETL_STATIC_ASSERT_FAILED<(bool)(Condition)>) \ + ETL_SA2(dummy, __LINE__) = sizeof(ETL_ETL_STATIC_ASSERT_FAILED(Condition)>) \ } #endif +#if (ETL_USING_CPP17) + #define ETL_STATIC_ASSERT1(Condition) static_assert(Condition) +#else + #define ETL_STATIC_ASSERT1(Condition) ETL_STATIC_ASSERT2((Condition), ETL_STRINGIFY(Condition)) +#endif + +/** + * Overload for static_assert() with 1 or 2 arguments. + * + * Calls either STATIC_ASSERT1() or STATIC_ASSERT2(). + */ +#define ETL_STATIC_ASSERT(...) \ + GET_MACRO_OVERLOAD2(__VA_ARGS__, ETL_STATIC_ASSERT2, ETL_STATIC_ASSERT1, "") \ + (__VA_ARGS__) + #endif diff --git a/include/etl/string_view.h b/include/etl/string_view.h index d35a7140a..eebaefb96 100644 --- a/include/etl/string_view.h +++ b/include/etl/string_view.h @@ -268,7 +268,7 @@ namespace etl //************************************************************************* ETL_CONSTEXPR size_t size() const { - return (mend - mbegin); + return static_cast(mend - mbegin); } //************************************************************************* diff --git a/include/etl/stringify.h b/include/etl/stringify.h new file mode 100644 index 000000000..0b888feb8 --- /dev/null +++ b/include/etl/stringify.h @@ -0,0 +1,20 @@ +#ifndef ETL_ETL_STRINGIFY_INCLUDED +#define ETL_ETL_STRINGIFY_INCLUDED + +#ifndef STRINGIFY +/** Helper macro for STRINGIFY. */ +#define STRINGIFY_1(...) #__VA_ARGS__ + +/** + * Indirect stringification. + * + * Doing two levels allows the parameter to be a macro itself. + * For example, compile with `-DFOO=bar`, `STRINGIFY(FOO)` converts to "bar". + * + * \param x will be converted to one string, including the spaces and commas between arguments. + * For example `STRINGIFY( a , b )` will be expanded to "a , b". + */ +#define STRINGIFY(...) STRINGIFY_1(__VA_ARGS__) +#endif /* STRINGIFY */ + +#endif /* ETL_ETL_STRINGIFY_INCLUDED */ diff --git a/include/etl/threshold.h b/include/etl/threshold.h index 4e4b39752..05fb5476b 100644 --- a/include/etl/threshold.h +++ b/include/etl/threshold.h @@ -35,7 +35,7 @@ SOFTWARE. #include "functional.h" #include "type_traits.h" -#include +//#include #include namespace etl diff --git a/include/etl/timer.h b/include/etl/timer.h index 6b9411cfc..856413b07 100644 --- a/include/etl/timer.h +++ b/include/etl/timer.h @@ -59,7 +59,10 @@ namespace etl enum { SINGLE_SHOT = false, - REPEATING = true + REPEATING = true, + + Single_Shot = false, + Repeating = true }; typedef bool type; @@ -71,7 +74,10 @@ namespace etl enum { DELAYED = false, - IMMEDIATE = true + IMMEDIATE = true, + + Delayed = false, + Immediate = true }; typedef bool type; @@ -82,7 +88,8 @@ namespace etl { enum { - NO_TIMER = 255 + NO_TIMER = 255, + No_Timer = 255 }; typedef uint_least8_t type; @@ -93,7 +100,8 @@ namespace etl { enum { - INACTIVE = 0xFFFFFFFFUL + INACTIVE = 0xFFFFFFFFUL, + Inactive = 0xFFFFFFFFUL }; }; }; diff --git a/include/etl/to_arithmetic.h b/include/etl/to_arithmetic.h index 024bd8f98..e556149a2 100644 --- a/include/etl/to_arithmetic.h +++ b/include/etl/to_arithmetic.h @@ -45,6 +45,8 @@ SOFTWARE. #include "absolute.h" #include "expected.h" +#include + namespace etl { //*************************************************************************** diff --git a/include/etl/unordered_map.h b/include/etl/unordered_map.h index 77d657b8a..0e5b9e35c 100644 --- a/include/etl/unordered_map.h +++ b/include/etl/unordered_map.h @@ -663,7 +663,7 @@ namespace etl node.clear(); ::new ((void*)etl::addressof(node.key_value_pair.first)) key_type(etl::move(key)); ::new ((void*)etl::addressof(node.key_value_pair.second)) mapped_type(); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; pbucket->insert_after(pbucket->before_begin(), node); @@ -707,7 +707,7 @@ namespace etl node.clear(); ::new ((void*)etl::addressof(node.key_value_pair.first)) key_type(key); ::new ((void*)etl::addressof(node.key_value_pair.second)) mapped_type(); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; pbucket->insert_after(pbucket->before_begin(), node); @@ -838,7 +838,7 @@ namespace etl node_t& node = allocate_data_node(); node.clear(); ::new ((void*)etl::addressof(node.key_value_pair)) value_type(key_value_pair); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; // Just add the pointer to the bucket; bucket.insert_after(bucket.before_begin(), node); @@ -873,7 +873,7 @@ namespace etl node_t& node = allocate_data_node(); node.clear(); ::new ((void*)etl::addressof(node.key_value_pair)) value_type(key_value_pair); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; // Add the node to the end of the bucket; bucket.insert_after(inode_previous, node); @@ -916,7 +916,7 @@ namespace etl node_t& node = allocate_data_node(); node.clear(); ::new ((void*)etl::addressof(node.key_value_pair)) value_type(etl::move(key_value_pair)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; // Just add the pointer to the bucket; bucket.insert_after(bucket.before_begin(), node); @@ -951,7 +951,7 @@ namespace etl node_t& node = allocate_data_node(); node.clear(); ::new ((void*)etl::addressof(node.key_value_pair)) value_type(etl::move(key_value_pair)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; // Add the node to the end of the bucket; bucket.insert_after(inode_previous, node); @@ -1398,7 +1398,7 @@ namespace etl { // Destroy the value contents. it->key_value_pair.~value_type(); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; ++it; } @@ -1516,7 +1516,7 @@ namespace etl icurrent->key_value_pair.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. adjust_first_last_markers_after_erase(&bucket); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; return inext; } @@ -1544,7 +1544,7 @@ namespace etl key_equal key_equal_function; /// For library debugging purposes only. - ETL_DECLARE_DEBUG_COUNT + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/unordered_multimap.h b/include/etl/unordered_multimap.h index 07a1d12f3..174b59783 100644 --- a/include/etl/unordered_multimap.h +++ b/include/etl/unordered_multimap.h @@ -678,7 +678,7 @@ namespace etl node_t& node = allocate_data_node(); node.clear(); ::new (&node.key_value_pair) value_type(key_value_pair); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; // Just add the pointer to the bucket; bucket.insert_after(bucket.before_begin(), node); @@ -708,7 +708,7 @@ namespace etl node_t& node = allocate_data_node(); node.clear(); ::new (&node.key_value_pair) value_type(key_value_pair); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; // Add the node to the end of the bucket; bucket.insert_after(inode_previous, node); @@ -749,7 +749,7 @@ namespace etl node_t& node = allocate_data_node(); node.clear(); ::new (&node.key_value_pair) value_type(etl::move(key_value_pair)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; // Just add the pointer to the bucket; bucket.insert_after(bucket.before_begin(), node); @@ -779,7 +779,7 @@ namespace etl node_t& node = allocate_data_node(); node.clear(); ::new (&node.key_value_pair) value_type(etl::move(key_value_pair)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; // Add the node to the end of the bucket; bucket.insert_after(inode_previous, node); @@ -1254,7 +1254,7 @@ namespace etl // Destroy the value contents. it->key_value_pair.~value_type(); ++it; - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } // Now it's safe to clear the bucket. @@ -1370,7 +1370,7 @@ namespace etl icurrent->key_value_pair.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. adjust_first_last_markers_after_erase(&bucket); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; return inext; } @@ -1398,7 +1398,7 @@ namespace etl key_equal key_equal_function; /// For library debugging purposes only. - ETL_DECLARE_DEBUG_COUNT + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/unordered_multiset.h b/include/etl/unordered_multiset.h index 973bf4022..be1acee7f 100644 --- a/include/etl/unordered_multiset.h +++ b/include/etl/unordered_multiset.h @@ -667,7 +667,7 @@ namespace etl node_t& node = allocate_data_node(); node.clear(); ::new (&node.key) value_type(key); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; // Just add the pointer to the bucket; bucket.insert_after(bucket.before_begin(), node); @@ -698,7 +698,7 @@ namespace etl node_t& node = allocate_data_node(); node.clear(); ::new (&node.key) value_type(key); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; // Add the node to the end of the bucket; bucket.insert_after(inode_previous, node); @@ -738,7 +738,7 @@ namespace etl node_t& node = allocate_data_node(); node.clear(); ::new (&node.key) value_type(etl::move(key)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; // Just add the pointer to the bucket; bucket.insert_after(bucket.before_begin(), node); @@ -769,7 +769,7 @@ namespace etl node_t& node = allocate_data_node(); node.clear(); ::new (&node.key) value_type(etl::move(key)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; // Add the node to the end of the bucket; bucket.insert_after(inode_previous, node); @@ -1232,7 +1232,7 @@ namespace etl // Destroy the value contents. it->key.~value_type(); ++it; - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } // Now it's safe to clear the bucket. @@ -1348,7 +1348,7 @@ namespace etl icurrent->key.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. adjust_first_last_markers_after_erase(&bucket); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; return inext; } @@ -1376,7 +1376,7 @@ namespace etl key_equal key_equal_function; /// For library debugging purposes only. - ETL_DECLARE_DEBUG_COUNT + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/unordered_set.h b/include/etl/unordered_set.h index 10a3f3adf..788de85f9 100644 --- a/include/etl/unordered_set.h +++ b/include/etl/unordered_set.h @@ -668,7 +668,7 @@ namespace etl node_t& node = allocate_data_node(); node.clear(); ::new (&node.key) value_type(key); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; // Just add the pointer to the bucket; bucket.insert_after(bucket.before_begin(), node); @@ -702,7 +702,7 @@ namespace etl node_t& node = allocate_data_node(); node.clear(); ::new (&node.key) value_type(key); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; // Add the node to the end of the bucket; bucket.insert_after(inode_previous, node); @@ -743,7 +743,7 @@ namespace etl node_t& node = allocate_data_node(); node.clear(); ::new (&node.key) value_type(etl::move(key)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; // Just add the pointer to the bucket; bucket.insert_after(bucket.before_begin(), node); @@ -777,7 +777,7 @@ namespace etl node_t& node = allocate_data_node(); node.clear(); ::new (&node.key) value_type(etl::move(key)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; // Add the node to the end of the bucket; bucket.insert_after(inode_previous, node); @@ -1226,7 +1226,7 @@ namespace etl // Destroy the value contents. it->key.~value_type(); ++it; - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } // Now it's safe to clear the bucket. @@ -1348,7 +1348,7 @@ namespace etl icurrent->key.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. adjust_first_last_markers_after_erase(&bucket); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; return inext; } @@ -1376,7 +1376,7 @@ namespace etl key_equal key_equal_function; /// For library debugging purposes only. - ETL_DECLARE_DEBUG_COUNT + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/utility.h b/include/etl/utility.h index 08097a750..bae739f1c 100644 --- a/include/etl/utility.h +++ b/include/etl/utility.h @@ -578,7 +578,7 @@ namespace etl //************************* template struct in_place_type_t { - explicit ETL_CONSTEXPR in_place_type_t() {}; + explicit ETL_CONSTEXPR in_place_type_t() {} }; #if ETL_USING_CPP17 diff --git a/include/etl/variance.h b/include/etl/variance.h index 857269170..73310774f 100644 --- a/include/etl/variance.h +++ b/include/etl/variance.h @@ -35,7 +35,7 @@ SOFTWARE. #include "functional.h" #include "type_traits.h" -#include +//#include #include namespace etl diff --git a/include/etl/vector.h b/include/etl/vector.h index bada15ba5..af236dc7f 100644 --- a/include/etl/vector.h +++ b/include/etl/vector.h @@ -229,12 +229,12 @@ namespace etl if (current_size < new_size) { etl::uninitialized_fill_n(p_end, delta, value); - ETL_ADD_DEBUG_COUNT(delta) + ETL_ADD_DEBUG_COUNT(delta); } else { etl::destroy_n(p_end - delta, delta); - ETL_SUBTRACT_DEBUG_COUNT(delta) + ETL_SUBTRACT_DEBUG_COUNT(delta); } p_end = p_buffer + new_size; @@ -251,11 +251,11 @@ namespace etl #if defined(ETL_DEBUG_COUNT) if (size() < new_size) { - ETL_ADD_DEBUG_COUNT(new_size - size()) + ETL_ADD_DEBUG_COUNT(new_size - size()); } else { - ETL_SUBTRACT_DEBUG_COUNT(size() - new_size) + ETL_SUBTRACT_DEBUG_COUNT(size() - new_size); } #endif @@ -263,11 +263,13 @@ namespace etl } //********************************************************************* - /// Does nothing. /// For compatibility with the STL vector API. + /// Does not increase the capacity, as this is fixed. + /// Asserts an etl::vector_out_of_bounds error if the request is for more than the capacity. //********************************************************************* - void reserve(size_t) + void reserve(size_t n) { + ETL_ASSERT(n <= CAPACITY, ETL_ERROR(vector_out_of_bounds)); } //********************************************************************* @@ -363,7 +365,7 @@ namespace etl /// Returns a const pointer to the beginning of the vector data. ///\return A const pointer to the beginning of the vector data. //********************************************************************* - const_pointer data() const + ETL_CONSTEXPR const_pointer data() const { return p_buffer; } @@ -389,7 +391,7 @@ namespace etl initialise(); p_end = etl::uninitialized_copy(first, last, p_buffer); - ETL_ADD_DEBUG_COUNT(uint32_t(etl::distance(first, last))) + ETL_ADD_DEBUG_COUNT(uint32_t(etl::distance(first, last))); } //********************************************************************* @@ -405,7 +407,7 @@ namespace etl initialise(); p_end = etl::uninitialized_fill_n(p_buffer, n, value); - ETL_ADD_DEBUG_COUNT(uint32_t(n)) + ETL_ADD_DEBUG_COUNT(uint32_t(n)); } //************************************************************************* @@ -466,10 +468,26 @@ namespace etl #endif ::new (p_end) T(etl::forward(args)...); ++p_end; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return back(); } #else + //********************************************************************* + /// Constructs a value at the end of the vector. + /// If asserts or exceptions are enabled, emits vector_full if the vector is already full. + ///\param value The value to add. + //********************************************************************* + reference emplace_back() + { +#if defined(ETL_CHECK_PUSH_POP) + ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full)); +#endif + ::new (p_end) T(); + ++p_end; + ETL_INCREMENT_DEBUG_COUNT; + return back(); + } + //********************************************************************* /// Constructs a value at the end of the vector. /// If asserts or exceptions are enabled, emits vector_full if the vector is already full. @@ -483,7 +501,7 @@ namespace etl #endif ::new (p_end) T(value1); ++p_end; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return back(); } @@ -500,7 +518,7 @@ namespace etl #endif ::new (p_end) T(value1, value2); ++p_end; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return back(); } @@ -517,7 +535,7 @@ namespace etl #endif ::new (p_end) T(value1, value2, value3); ++p_end; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return back(); } @@ -534,7 +552,7 @@ namespace etl #endif ::new (p_end) T(value1, value2, value3, value4); ++p_end; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; return back(); } #endif @@ -621,7 +639,7 @@ namespace etl if (position_ == end()) { p = p_end++; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; } else { @@ -648,7 +666,7 @@ namespace etl if (position_ == end()) { p = p_end++; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; } else { @@ -675,7 +693,7 @@ namespace etl if (position_ == end()) { p = p_end++; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; } else { @@ -702,7 +720,7 @@ namespace etl if (position_ == end()) { p = p_end++; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; } else { @@ -729,7 +747,7 @@ namespace etl if (position_ == end()) { p = p_end++; - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; } else { @@ -785,14 +803,14 @@ namespace etl // Construct old. etl::uninitialized_move(p_end - construct_old_n, p_end, p_construct_old); - ETL_ADD_DEBUG_COUNT(construct_old_n) + ETL_ADD_DEBUG_COUNT(construct_old_n); // Copy old. etl::move_backward(p_buffer + insert_begin, p_buffer + insert_begin + copy_old_n, p_buffer + insert_end + copy_old_n); // Construct new. etl::uninitialized_fill_n(p_end, construct_new_n, value); - ETL_ADD_DEBUG_COUNT(construct_new_n) + ETL_ADD_DEBUG_COUNT(construct_new_n); // Copy new. etl::fill_n(p_buffer + insert_begin, copy_new_n, value); @@ -842,14 +860,14 @@ namespace etl // Move construct old. etl::uninitialized_move(p_end - construct_old_n, p_end, p_construct_old); - ETL_ADD_DEBUG_COUNT(construct_old_n) + ETL_ADD_DEBUG_COUNT(construct_old_n); // Move old. etl::move_backward(p_buffer + insert_begin, p_buffer + insert_begin + copy_old_n, p_buffer + insert_end + copy_old_n); // Copy construct new. etl::uninitialized_copy(first + copy_new_n, first + copy_new_n + construct_new_n, p_end); - ETL_ADD_DEBUG_COUNT(construct_new_n) + ETL_ADD_DEBUG_COUNT(construct_new_n); // Copy new. etl::copy(first, first + copy_new_n, p_buffer + insert_begin); @@ -909,7 +927,7 @@ namespace etl // Destroy the elements left over at the end. etl::destroy(p_end - n_delete, p_end); - ETL_SUBTRACT_DEBUG_COUNT(n_delete) + ETL_SUBTRACT_DEBUG_COUNT(n_delete); p_end -= n_delete; } @@ -956,7 +974,7 @@ namespace etl /// Gets the current size of the vector. ///\return The current size of the vector. //************************************************************************* - size_type size() const + ETL_CONSTEXPR size_type size() const { return size_t(p_end - p_buffer); } @@ -1013,7 +1031,7 @@ namespace etl void initialise() { etl::destroy(p_buffer, p_end); - ETL_SUBTRACT_DEBUG_COUNT(int32_t(etl::distance(p_buffer, p_end))) + ETL_SUBTRACT_DEBUG_COUNT(int32_t(etl::distance(p_buffer, p_end))); p_end = p_buffer; } @@ -1039,7 +1057,7 @@ namespace etl void create_back() { etl::create_value_at(p_end); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; ++p_end; } @@ -1050,7 +1068,7 @@ namespace etl void create_back(const_reference value) { etl::create_copy_at(p_end, value); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; ++p_end; } @@ -1062,7 +1080,7 @@ namespace etl void create_back(rvalue_reference value) { etl::create_copy_at(p_end, etl::move(value)); - ETL_INCREMENT_DEBUG_COUNT + ETL_INCREMENT_DEBUG_COUNT; ++p_end; } @@ -1076,7 +1094,7 @@ namespace etl --p_end; etl::destroy_at(p_end); - ETL_DECREMENT_DEBUG_COUNT + ETL_DECREMENT_DEBUG_COUNT; } // Disable copy construction. diff --git a/include/etl/version.h b/include/etl/version.h index 28171e7a3..6b446f422 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -39,8 +39,8 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 20 -#define ETL_VERSION_MINOR 37 -#define ETL_VERSION_PATCH 3 +#define ETL_VERSION_MINOR 38 +#define ETL_VERSION_PATCH 6 #define ETL_VERSION ETL_STRING(ETL_VERSION_MAJOR) "." ETL_STRING(ETL_VERSION_MINOR) "." ETL_STRING(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_WIDE_STRING(ETL_VERSION_MAJOR) L"." ETL_WIDE_STRING(ETL_VERSION_MINOR) L"." ETL_WIDE_STRING(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index a152b7e46..56cf34252 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "20.37.3", + "version": "20.38.6", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index a8877fe06..107b8b6d0 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=20.37.3 +version=20.38.6 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/scripts/update_version.bat b/scripts/update_version.bat new file mode 100644 index 000000000..73bf64fb6 --- /dev/null +++ b/scripts/update_version.bat @@ -0,0 +1 @@ +python .\update_version.py diff --git a/scripts/update_version.py b/scripts/update_version.py new file mode 100644 index 000000000..9d9fbc65c --- /dev/null +++ b/scripts/update_version.py @@ -0,0 +1,154 @@ + +import shutil +import os + +# Get the current path of the script +script_dir = os.path.dirname(os.path.abspath(__file__)) + +# Get the root folder of the ETL +etl_dir = os.path.abspath(os.path.join(script_dir, os.pardir)) + +# Get the ETL repository folder +include_dir = os.path.join(etl_dir, 'include') + +# Get the ETL headers folder +headers_dir = os.path.join(include_dir, 'etl') + +# Get the Arduino folder +arduino_dir = os.path.join(etl_dir, 'arduino') + +# Get the ETL arduino_examples folder +arduino_examples_dir = os.path.join(arduino_dir, 'examples') + +# Get the root folder of both repositories +common_dir = os.path.abspath(os.path.join(etl_dir, os.pardir)) + +# Get the ETL Arduino repository folder +etl_arduino_dir = os.path.join(common_dir, 'etl-arduino') + +# Get the ETL Arduino src repository folder +etl_arduino_src_dir = os.path.join(etl_arduino_dir, 'src') + +# Get the ETL Arduino examples repository folder +etl_arduino_examples_dir = os.path.join(etl_arduino_dir, 'examples') + +major_version = '' +minor_version = '' +patch_version = '' + +#------------------------------------------------------------------------------ +def get_version(): + version_file = os.path.join(etl_dir, 'version.txt') + print('') + print('version_file = ', version_file) + + with open(version_file) as f: + version = f.read().splitlines() + + elements = version[0].split('.', 3) + + return version[0], elements[0], elements[1], elements[2] + +#------------------------------------------------------------------------------ +def update_version_h(): + print('') + print('Creating version.h') + + version_h = os.path.join(headers_dir, 'version.h') + + with open(version_h) as f: + text = f.read().splitlines() + + search_major = '#define ETL_VERSION_MAJOR ' + search_minor = '#define ETL_VERSION_MINOR ' + search_patch = '#define ETL_VERSION_PATCH ' + + length_major = len(search_major) + length_minor = len(search_minor) + length_patch = len(search_patch) + + for i in range(len(text) - 1): + + index = text[i].find(search_major) + if index != -1: + text[i] = text[i][index:length_major] + major_version + print(text[i]) + + index = text[i].find(search_minor) + if index != -1: + text[i] = text[i][index:length_minor] + minor_version + print(text[i]) + + index = text[i].find(search_patch) + if index != -1: + text[i] = text[i][index:length_patch] + patch_version + print(text[i]) + + with open(version_h, 'w') as f: + for line in text: + f.write(line) + f.write('\n') + +#------------------------------------------------------------------------------ +def update_library_json(filename): + print('') + print('Creating %s' % filename) + + with open(filename) as f: + text = f.read().splitlines() + + search = 'version' + + for i in range(len(text) - 1): + index = text[i].find(search) + if index != -1: + text[i] = ' \"version\": \"' + full_version + '\",' + + with open(filename, 'w') as f: + for line in text: + f.write(line) + f.write('\n') + +#------------------------------------------------------------------------------ +def update_library_properties(filename): + print('') + print('Creating %s' % filename) + + with open(filename, 'r') as f: + text = f.read().splitlines() + + search = 'version' + + for i in range(len(text) - 1): + index = text[i].find(search) + if index != -1: + text[i] = 'version=' + full_version + + with open(filename, 'w') as f: + for line in text: + f.write(line) + f.write('\n') + +#------------------------------------------------------------------------------ +def update_versions(): + print('') + print('Update Versions') + + global full_version + global major_version + global minor_version + global patch_version + + full_version, major_version, minor_version, patch_version = get_version() + + print("Version = %s.%s.%s" % (major_version, minor_version, patch_version )) + + update_version_h() + + update_library_json(os.path.join(etl_dir, 'library.json')) + + update_library_properties(os.path.join(etl_dir, 'library.properties')) + +#------------------------------------------------------------------------------ +if __name__ == "__main__": + update_versions() diff --git a/support/Release notes.txt b/support/Release notes.txt index 87be8a4d2..82162061c 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,6 +1,56 @@ +=============================================================================== +20.38.6 +#777 Allow Building Tests as Submodule and GCC < 11 +Refactored etl::itr_swap for maximum efficiency. + +=============================================================================== +20.38.5 +#776 Add missing semicolons + +=============================================================================== +20.38.4 +#773 Return raw pointer for etl::multi_span::operator->() + +=============================================================================== +20.38.3 +#767 etl::pool silently produces unaligned allocations for types with stricter alignment requirements than built in types + +=============================================================================== +20.38.2 +#749 Code change causes warning with armcc compiler +#753 IAR's overload resolution struggles with etl::span::span(etl::array&) +#754 ambiguous etl::bit_stream_reader::bit_stream_reader() for some etl::span +#755 warning about constexpr in array.h +#756 Parameter pack compilation error +#758 Move assignment not working for non-empty containers +#761 Make "private" includes relative +#765 etl::optional cannot be constexpr +#766 etl::unique_ptr::reset() can call deleter with nullptr argument +Re-enabled bit_stream_writer tests + +=============================================================================== +20.38.1 +Deleted + +=============================================================================== +20.38.0 +#696 fsm/hfsm self-transitions +#702 etl::message not trivially_copyable +#744 Feature request: Get time when next timer will expire etl::callback_timer +#745 Assertion triggered in hash.h when compiling for MSP430 +#746 Missing etl::legacy::variant overload of emplace with 0 Arguments +#748 armcc error on vector::insert +Fixed unexpected pool release behavior when the pool is empty +Added C++03 compatible etl::move and etl::move_backward +Allow C++03 delegate in etl::callback_timer +Change to require semicolons after debug count macros +Re-enabled tests for etl::string_ext +Removed redundant #includes +Added MutexMessageRouter example + =============================================================================== 20.37.3 -#737 Etl::equal specialisation for etl::span is deduced wrongly when using STL and CPP20. Added C++20 four iterator std::equal variants. +#737 etl::equal specialisation for etl::span is deduced wrongly when using STL and CPP20. Added C++20 four iterator std::equal variants. #738 etl::expected assignment operator won't work when TValue and TError are the same type. Changed assignment from etl::unexpected to use variant::emplace instead of direct assignment. #739 Could not compile ETL with gcc 9.4.0 (C++11). Added compatibility for GCC-9 + C++11. Added missing return reference from emplace member function int variant_variadic.h Removed many -02 warnings for GCC-13 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6fb1de1d1..6ef5bdab4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -19,6 +19,7 @@ add_executable(etl_tests test_array_view.cpp test_array_wrapper.cpp test_atomic.cpp + test_base64.cpp test_binary.cpp test_bip_buffer_spsc_atomic.cpp test_bit.cpp @@ -221,6 +222,7 @@ add_executable(etl_tests test_state_chart_with_rvalue_data_parameter.cpp test_state_chart_compile_time.cpp test_state_chart_compile_time_with_data_parameter.cpp + test_static_assert.cpp test_string_char.cpp test_string_char_external_buffer.cpp test_string_stream.cpp @@ -321,6 +323,11 @@ if (ETL_USER_DEFINED_TYPE_TRAITS) target_compile_definitions(etl_tests PRIVATE -DETL_USER_DEFINED_TYPE_TRAITS) endif() +if (ETL_MESSAGES_ARE_NOT_VIRTUAL) + message(STATUS "Compiling for non-virtual messages") + target_compile_definitions(etl_tests PRIVATE -DETL_MESSAGES_ARE_NOT_VIRTUAL) +endif() + if (ETL_FORCE_TEST_CPP03_IMPLEMENTATION) message(STATUS "Compiling for C++03 tests") target_compile_definitions(etl_tests PRIVATE -DETL_FORCE_TEST_CPP03_IMPLEMENTATION) @@ -355,6 +362,7 @@ endif () if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") message(STATUS "Using Clang compiler") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") endif () if ((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) diff --git a/test/etl_profile.h b/test/etl_profile.h index 9ac74013d..079e24ad8 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -39,7 +39,7 @@ SOFTWARE. #define ETL_IDEQUE_REPAIR_ENABLE #define ETL_ICIRCULAR_BUFFER_REPAIR_ENABLE #define ETL_IN_UNIT_TEST -#define ETL_DEBUG_COUNT +//#define ETL_DEBUG_COUNT #define ETL_ARRAY_VIEW_IS_MUTABLE #define ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK @@ -98,6 +98,10 @@ SOFTWARE. #define ETL_DELEGATE_FORCE_CPP03_IMPLEMENTATION #define ETL_SINGLETON_FORCE_CPP03_IMPLEMENTATION #define ETL_BYTE_FORCE_CPP03_IMPLEMENTATION + #define ETL_LIST_FORCE_CPP03_IMPLEMENTATION + #define ETL_FORWARD_LIST_FORCE_CPP03_IMPLEMENTATION + #define ETL_FLAT_SET_FORCE_CPP03_IMPLEMENTATION + #define ETL_FLAT_MULTISET_FORCE_CPP03_IMPLEMENTATION #endif #if defined(ETL_FORCE_TEST_CPP11) diff --git a/test/meson.build b/test/meson.build index eefedd14a..4fe68d62e 100644 --- a/test/meson.build +++ b/test/meson.build @@ -207,6 +207,7 @@ etl_test_sources = files( 'test_state_chart_with_rvalue_data_parameter.cpp', 'test_state_chart_compile_time.cpp', 'test_state_chart_compile_time_with_data_parameter.cpp', + 'test_static_assert.cpp', 'test_string_char.cpp', 'test_string_char_external_buffer.cpp', 'test_string_stream.cpp', diff --git a/test/run-tests.sh b/test/run-tests.sh index 1e0d4f61a..6a6c8bd0d 100644 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -155,7 +155,28 @@ SetTestName "GCC - STL" PrintHeader rm * -rf gcc --version | grep gcc | tee -a log.txt -cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize .. +cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize -DETL_MESSAGES_ARE_NOT_VIRTUAL=OFF .. +cmake --build . +if [ $? -eq 0 ]; then + PassedCompilation +else + FailedCompilation + exit $? +fi +./etl_tests +if [ $? -eq 0 ]; then + PassedTests +else + FailedTests + exit $? +fi + +#****************************************************************************** +SetTestName "GCC - STL - Non-virtual messages" +PrintHeader +rm * -rf +gcc --version | grep gcc | tee -a log.txt +cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize -DETL_MESSAGES_ARE_NOT_VIRTUAL=ON .. cmake --build . if [ $? -eq 0 ]; then PassedCompilation @@ -176,7 +197,7 @@ SetTestName "GCC - STL - Force C++03" PrintHeader rm * -rf gcc --version | grep gcc | tee -a log.txt -cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize .. +cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize -DETL_MESSAGES_ARE_NOT_VIRTUAL=OFF .. cmake --build . if [ $? -eq 0 ]; then PassedCompilation @@ -197,7 +218,7 @@ SetTestName "GCC - No STL" PrintHeader rm * -rf gcc --version | grep gcc | tee -a log.txt -cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize .. +cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize -DETL_MESSAGES_ARE_NOT_VIRTUAL=OFF .. cmake --build . if [ $? -eq 0 ]; then PassedCompilation @@ -218,7 +239,7 @@ SetTestName "GCC - No STL - Force C++03" PrintHeader rm * -rf gcc --version | grep gcc | tee -a log.txt -cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize .. +cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize -DETL_MESSAGES_ARE_NOT_VIRTUAL=OFF .. cmake --build . if [ $? -eq 0 ]; then PassedCompilation @@ -241,7 +262,7 @@ SetTestName "Clang - STL" PrintHeader rm * -rf clang --version | grep clang | tee -a log.txt -cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize .. +cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize -DETL_MESSAGES_ARE_NOT_VIRTUAL=OFF .. cmake --build . if [ $? -eq 0 ]; then PassedCompilation @@ -262,7 +283,7 @@ SetTestName "Clang - STL - Force C++03" PrintHeader rm * -rf clang --version | grep clang | tee -a log.txt -cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize .. +cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize -DETL_MESSAGES_ARE_NOT_VIRTUAL=OFF .. cmake --build . if [ $? -eq 0 ]; then PassedCompilation @@ -283,7 +304,7 @@ SetTestName "Clang - No STL" PrintHeader rm * -rf clang --version | grep clang | tee -a log.txt -cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize .. +cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize -DETL_MESSAGES_ARE_NOT_VIRTUAL=OFF .. cmake --build . if [ $? -eq 0 ]; then PassedCompilation @@ -304,7 +325,7 @@ SetTestName "Clang - No STL - Force C++03" PrintHeader rm * -rf clang --version | grep clang | tee -a log.txt -cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize .. +cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize -DETL_MESSAGES_ARE_NOT_VIRTUAL=OFF .. cmake --build . if [ $? -eq 0 ]; then PassedCompilation diff --git a/test/syntax_check/base64.h.t.cpp b/test/syntax_check/base64.h.t.cpp new file mode 100644 index 000000000..184c72bce --- /dev/null +++ b/test/syntax_check/base64.h.t.cpp @@ -0,0 +1,29 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2023 John Wellbelove + +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 diff --git a/test/syntax_check/c++03/CMakeLists.txt b/test/syntax_check/c++03/CMakeLists.txt index 79058adcd..7d5f43c1f 100644 --- a/test/syntax_check/c++03/CMakeLists.txt +++ b/test/syntax_check/c++03/CMakeLists.txt @@ -46,6 +46,7 @@ target_sources(t98 PRIVATE etl_profile.h ../array_view.h.t.cpp ../array_wrapper.h.t.cpp ../atomic.h.t.cpp + ../base64.h.t.cpp ../basic_format_spec.h.t.cpp ../basic_string.h.t.cpp ../basic_string_stream.h.t.cpp diff --git a/test/syntax_check/c++11/CMakeLists.txt b/test/syntax_check/c++11/CMakeLists.txt index 178387ef0..25a620bb8 100644 --- a/test/syntax_check/c++11/CMakeLists.txt +++ b/test/syntax_check/c++11/CMakeLists.txt @@ -46,6 +46,7 @@ target_sources(t11 PRIVATE etl_profile.h ../array_view.h.t.cpp ../array_wrapper.h.t.cpp ../atomic.h.t.cpp + ../base64.h.t.cpp ../basic_format_spec.h.t.cpp ../basic_string.h.t.cpp ../basic_string_stream.h.t.cpp diff --git a/test/syntax_check/c++14/CMakeLists.txt b/test/syntax_check/c++14/CMakeLists.txt index 7eed29fbc..9c28613bf 100644 --- a/test/syntax_check/c++14/CMakeLists.txt +++ b/test/syntax_check/c++14/CMakeLists.txt @@ -46,6 +46,7 @@ target_sources(t14 PRIVATE etl_profile.h ../array_view.h.t.cpp ../array_wrapper.h.t.cpp ../atomic.h.t.cpp + ../base64.h.t.cpp ../basic_format_spec.h.t.cpp ../basic_string.h.t.cpp ../basic_string_stream.h.t.cpp diff --git a/test/syntax_check/c++17/CMakeLists.txt b/test/syntax_check/c++17/CMakeLists.txt index fbe3c6d87..3c1fe0baa 100644 --- a/test/syntax_check/c++17/CMakeLists.txt +++ b/test/syntax_check/c++17/CMakeLists.txt @@ -46,6 +46,7 @@ target_sources(t17 PRIVATE etl_profile.h ../array_view.h.t.cpp ../array_wrapper.h.t.cpp ../atomic.h.t.cpp + ../base64.h.t.cpp ../basic_format_spec.h.t.cpp ../basic_string.h.t.cpp ../basic_string_stream.h.t.cpp diff --git a/test/syntax_check/c++20/CMakeLists.txt b/test/syntax_check/c++20/CMakeLists.txt index ae020085a..4d05bc196 100644 --- a/test/syntax_check/c++20/CMakeLists.txt +++ b/test/syntax_check/c++20/CMakeLists.txt @@ -46,6 +46,7 @@ target_sources(t20 PRIVATE etl_profile.h ../array_view.h.t.cpp ../array_wrapper.h.t.cpp ../atomic.h.t.cpp + ../base64.h.t.cpp ../basic_format_spec.h.t.cpp ../basic_string.h.t.cpp ../basic_string_stream.h.t.cpp diff --git a/test/test_algorithm.cpp b/test/test_algorithm.cpp index 8828cb96f..a49e0011d 100644 --- a/test/test_algorithm.cpp +++ b/test/test_algorithm.cpp @@ -689,7 +689,7 @@ namespace } //************************************************************************* - TEST(iter_swap) + TEST(iter_swap_same_types) { int a = 1; int b = 2; @@ -699,6 +699,17 @@ namespace CHECK_EQUAL(1, b); } + //************************************************************************* + TEST(iter_swap_differnt_types) + { + int a = 1; + long b = 2; + + etl::iter_swap(&a, &b); + CHECK_EQUAL(2, a); + CHECK_EQUAL(1, b); + } + //************************************************************************* TEST(equal) { diff --git a/test/test_alignment.cpp b/test/test_alignment.cpp index 39e5dc202..29de827a1 100644 --- a/test/test_alignment.cpp +++ b/test/test_alignment.cpp @@ -143,5 +143,17 @@ namespace CHECK_FALSE(etl::is_aligned(p)); CHECK_FALSE(etl::is_aligned(p)); } + + //************************************************************************* + TEST(test_type_with_alignment) + { + CHECK_EQUAL(1, alignof(etl::type_with_alignment_t<1>)); + CHECK_EQUAL(2, alignof(etl::type_with_alignment_t<2>)); + CHECK_EQUAL(4, alignof(etl::type_with_alignment_t<4>)); + CHECK_EQUAL(8, alignof(etl::type_with_alignment_t<8>)); + CHECK_EQUAL(16, alignof(etl::type_with_alignment_t<16>)); + CHECK_EQUAL(32, alignof(etl::type_with_alignment_t<32>)); + CHECK_EQUAL(64, alignof(etl::type_with_alignment_t<64>)); + } }; } diff --git a/test/test_base64.cpp b/test/test_base64.cpp new file mode 100644 index 000000000..b26423e4c --- /dev/null +++ b/test/test_base64.cpp @@ -0,0 +1,685 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2023 John Wellbelove + +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 "unit_test_framework.h" + +#include "etl/base64.h" + +#include "etl/string.h" +#include "etl/vector.h" + +#include +#include +#include +#include + +namespace +{ + std::array input_data_unsigned_char = + { + 0x3B, 0x27, 0x03, 0x43, 0x2D, 0xFB, 0x28, 0x2A, 0x61, 0xAE, 0xBC, 0x49, 0x71, 0x32, 0x01, 0x15, + 0x69, 0x5C, 0x5E, 0xF5, 0xD5, 0x9B, 0xDE, 0xA5, 0x57, 0xC9, 0xC1, 0x7D, 0x80, 0xDE, 0x4C, 0x81, + 0xC0, 0xCF, 0x2A, 0xD1, 0x86, 0x56, 0xD5, 0x71, 0x37, 0xEB, 0x80, 0x32, 0xDF, 0xE4, 0xDF, 0xB6, + 0xEE, 0x3F, 0xDC, 0x79, 0xB3, 0x17, 0x8E, 0x76, 0x65, 0x8E, 0x96, 0x21, 0xB9, 0x88, 0xD1, 0x6D, + 0xD0, 0xDD, 0xFF, 0xDA, 0xA8, 0x7A, 0x4D, 0xF5, 0x71, 0x77, 0xFD, 0x2E, 0xF2, 0xE4, 0x40, 0x72, + 0x8C, 0x83, 0x00, 0x6F, 0x13, 0x72, 0x53, 0xE4, 0x6B, 0x70, 0x0E, 0x37, 0xCA, 0x25, 0xCD, 0x68, + 0x62, 0xC0, 0xAB, 0x14, 0xC7, 0x59, 0x83, 0xD2, 0x82, 0x8C, 0x93, 0x6D, 0x13, 0x21, 0xC0, 0x08, + 0xF9, 0x6D, 0xAC, 0x84, 0x78, 0x49, 0x84, 0x6F, 0x6B, 0xFB, 0x20, 0x3B, 0x9C, 0x49, 0xFB, 0x4E, + 0x80, 0x69, 0x82, 0x25, 0x86, 0x95, 0xD5, 0x4D, 0x91, 0xED, 0xD2, 0x77, 0x2A, 0x24, 0x40, 0x8A, + 0xDF, 0x4D, 0x80, 0x2D, 0xCD, 0xD5, 0x5A, 0x26, 0xA6, 0x71, 0x15, 0x42, 0x0E, 0x3F, 0xB2, 0x70, + 0x14, 0x29, 0x1F, 0x8D, 0x23, 0x2E, 0xC1, 0xEA, 0xCE, 0xF9, 0x7E, 0x6C, 0xDF, 0x1C, 0xA3, 0x84, + 0x2B, 0x24, 0x35, 0xA7, 0x63, 0xC8, 0x0B, 0x1F, 0x8B, 0xBA, 0x51, 0xBF, 0xE9, 0x51, 0x80, 0xD2, + 0x23, 0xB5, 0xD1, 0xB4, 0x59, 0xAE, 0x7D, 0x30, 0x1D, 0x00, 0x1C, 0xD8, 0x70, 0x6C, 0x16, 0x71, + 0xC7, 0x56, 0x08, 0xFE, 0x81, 0xAE, 0xFB, 0xE0, 0x92, 0xD8, 0xDB, 0xB9, 0x57, 0x7C, 0x99, 0xCB, + 0x42, 0xEF, 0xFC, 0xB3, 0x56, 0x1E, 0xD1, 0x42, 0xD3, 0x0C, 0x18, 0xB3, 0xEE, 0xAF, 0x1A, 0x77, + 0xA8, 0x52, 0x3C, 0x9E, 0xCD, 0xDE, 0x21, 0x34, 0x3E, 0x1F, 0xB5, 0x54, 0xD7, 0xFB, 0xB4, 0xBD + }; + + std::array input_data_int8_t = + { + int8_t(0x3B), int8_t(0x27), int8_t(0x03), int8_t(0x43), int8_t(0x2D), int8_t(0xFB), int8_t(0x28), int8_t(0x2A), int8_t(0x61), int8_t(0xAE), int8_t(0xBC), int8_t(0x49), int8_t(0x71), int8_t(0x32), int8_t(0x01), int8_t(0x15), + int8_t(0x69), int8_t(0x5C), int8_t(0x5E), int8_t(0xF5), int8_t(0xD5), int8_t(0x9B), int8_t(0xDE), int8_t(0xA5), int8_t(0x57), int8_t(0xC9), int8_t(0xC1), int8_t(0x7D), int8_t(0x80), int8_t(0xDE), int8_t(0x4C), int8_t(0x81), + int8_t(0xC0), int8_t(0xCF), int8_t(0x2A), int8_t(0xD1), int8_t(0x86), int8_t(0x56), int8_t(0xD5), int8_t(0x71), int8_t(0x37), int8_t(0xEB), int8_t(0x80), int8_t(0x32), int8_t(0xDF), int8_t(0xE4), int8_t(0xDF), int8_t(0xB6), + int8_t(0xEE), int8_t(0x3F), int8_t(0xDC), int8_t(0x79), int8_t(0xB3), int8_t(0x17), int8_t(0x8E), int8_t(0x76), int8_t(0x65), int8_t(0x8E), int8_t(0x96), int8_t(0x21), int8_t(0xB9), int8_t(0x88), int8_t(0xD1), int8_t(0x6D), + int8_t(0xD0), int8_t(0xDD), int8_t(0xFF), int8_t(0xDA), int8_t(0xA8), int8_t(0x7A), int8_t(0x4D), int8_t(0xF5), int8_t(0x71), int8_t(0x77), int8_t(0xFD), int8_t(0x2E), int8_t(0xF2), int8_t(0xE4), int8_t(0x40), int8_t(0x72), + int8_t(0x8C), int8_t(0x83), int8_t(0x00), int8_t(0x6F), int8_t(0x13), int8_t(0x72), int8_t(0x53), int8_t(0xE4), int8_t(0x6B), int8_t(0x70), int8_t(0x0E), int8_t(0x37), int8_t(0xCA), int8_t(0x25), int8_t(0xCD), int8_t(0x68), + int8_t(0x62), int8_t(0xC0), int8_t(0xAB), int8_t(0x14), int8_t(0xC7), int8_t(0x59), int8_t(0x83), int8_t(0xD2), int8_t(0x82), int8_t(0x8C), int8_t(0x93), int8_t(0x6D), int8_t(0x13), int8_t(0x21), int8_t(0xC0), int8_t(0x08), + int8_t(0xF9), int8_t(0x6D), int8_t(0xAC), int8_t(0x84), int8_t(0x78), int8_t(0x49), int8_t(0x84), int8_t(0x6F), int8_t(0x6B), int8_t(0xFB), int8_t(0x20), int8_t(0x3B), int8_t(0x9C), int8_t(0x49), int8_t(0xFB), int8_t(0x4E), + int8_t(0x80), int8_t(0x69), int8_t(0x82), int8_t(0x25), int8_t(0x86), int8_t(0x95), int8_t(0xD5), int8_t(0x4D), int8_t(0x91), int8_t(0xED), int8_t(0xD2), int8_t(0x77), int8_t(0x2A), int8_t(0x24), int8_t(0x40), int8_t(0x8A), + int8_t(0xDF), int8_t(0x4D), int8_t(0x80), int8_t(0x2D), int8_t(0xCD), int8_t(0xD5), int8_t(0x5A), int8_t(0x26), int8_t(0xA6), int8_t(0x71), int8_t(0x15), int8_t(0x42), int8_t(0x0E), int8_t(0x3F), int8_t(0xB2), int8_t(0x70), + int8_t(0x14), int8_t(0x29), int8_t(0x1F), int8_t(0x8D), int8_t(0x23), int8_t(0x2E), int8_t(0xC1), int8_t(0xEA), int8_t(0xCE), int8_t(0xF9), int8_t(0x7E), int8_t(0x6C), int8_t(0xDF), int8_t(0x1C), int8_t(0xA3), int8_t(0x84), + int8_t(0x2B), int8_t(0x24), int8_t(0x35), int8_t(0xA7), int8_t(0x63), int8_t(0xC8), int8_t(0x0B), int8_t(0x1F), int8_t(0x8B), int8_t(0xBA), int8_t(0x51), int8_t(0xBF), int8_t(0xE9), int8_t(0x51), int8_t(0x80), int8_t(0xD2), + int8_t(0x23), int8_t(0xB5), int8_t(0xD1), int8_t(0xB4), int8_t(0x59), int8_t(0xAE), int8_t(0x7D), int8_t(0x30), int8_t(0x1D), int8_t(0x00), int8_t(0x1C), int8_t(0xD8), int8_t(0x70), int8_t(0x6C), int8_t(0x16), int8_t(0x71), + int8_t(0xC7), int8_t(0x56), int8_t(0x08), int8_t(0xFE), int8_t(0x81), int8_t(0xAE), int8_t(0xFB), int8_t(0xE0), int8_t(0x92), int8_t(0xD8), int8_t(0xDB), int8_t(0xB9), int8_t(0x57), int8_t(0x7C), int8_t(0x99), int8_t(0xCB), + int8_t(0x42), int8_t(0xEF), int8_t(0xFC), int8_t(0xB3), int8_t(0x56), int8_t(0x1E), int8_t(0xD1), int8_t(0x42), int8_t(0xD3), int8_t(0x0C), int8_t(0x18), int8_t(0xB3), int8_t(0xEE), int8_t(0xAF), int8_t(0x1A), int8_t(0x77), + int8_t(0xA8), int8_t(0x52), int8_t(0x3C), int8_t(0x9E), int8_t(0xCD), int8_t(0xDE), int8_t(0x21), int8_t(0x34), int8_t(0x3E), int8_t(0x1F), int8_t(0xB5), int8_t(0x54), int8_t(0xD7), int8_t(0xFB), int8_t(0xB4), int8_t(0xBD) + }; + + std::array encoded = + { + "", + "Ow==", + "Oyc=", + "OycD", + "OycDQw==", + "OycDQy0=", + "OycDQy37", + "OycDQy37KA==", + "OycDQy37KCo=", + "OycDQy37KCph", + "OycDQy37KCphrg==", + "OycDQy37KCphrrw=", + "OycDQy37KCphrrxJ", + "OycDQy37KCphrrxJcQ==", + "OycDQy37KCphrrxJcTI=", + "OycDQy37KCphrrxJcTIB", + "OycDQy37KCphrrxJcTIBFQ==", + "OycDQy37KCphrrxJcTIBFWk=", + "OycDQy37KCphrrxJcTIBFWlc", + "OycDQy37KCphrrxJcTIBFWlcXg==", + "OycDQy37KCphrrxJcTIBFWlcXvU=", + "OycDQy37KCphrrxJcTIBFWlcXvXV", + "OycDQy37KCphrrxJcTIBFWlcXvXVmw==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm94=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96l", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lVw==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8k=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nB", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYA=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDe", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTA==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIE=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHA", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzw==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyo=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrR", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhg==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlY=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbV", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTc=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfr", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgA==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDI=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5A==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N8=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+2", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27g==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j8=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/c", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/ceQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebM=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMX", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjg==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnY=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZl", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljg==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpY=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYh", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYg=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjR", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdA=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/w==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9o=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qo", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoeg==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek0=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXc=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9Lg==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvI=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLk", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQA==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHI=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKM", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgw==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwA=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBv", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvEw==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3I=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5A==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5Gs=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5Gtw", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDg==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjc=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfK", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc0=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1o", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYg==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsA=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCr", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFA==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMc=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZ", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZgw==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9I=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KC", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjA==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJM=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNt", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEw==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyE=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHA", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACA==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPk=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPlt", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrA==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIQ=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYQ=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRv", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRvaw==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/s=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sg", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgOw==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5w=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+w==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+04=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06A", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYI=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIl", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhg==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpU=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXV", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZE=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0g==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0nc=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncq", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJA==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJEA=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK3w==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK300=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302A", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc0=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3V", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWg==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiY=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiam", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRU=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVC", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDg==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj8=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+y", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycA==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQ=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQp", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpHw==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40j", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLg==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsE=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHq", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzg==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvk=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bA==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8c", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8cow==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4Q=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4Qr", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJA==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDU=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWn", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnYw==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8g=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gL", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLHw==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4s=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6UQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub8=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/p", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYA=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDS", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSIw==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7U=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XR", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtA==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFk=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmu", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTA=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAd", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdAA==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABw=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzY", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcA==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGw=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwW", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWcQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccc=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdW", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCA==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP4=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6B", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6Brg==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6Brvs=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6Brvvg", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6Brvvgkg==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6Brvvgktg=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6Brvvgktjb", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVc=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mcs=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7w==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/w=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yz", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVg==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh4=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7R", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQg==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtM=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMM", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGA==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLM=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPu", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurw==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurxo=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurxp3", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurxp3qA==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurxp3qFI=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurxp3qFI8", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurxp3qFI8ng==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurxp3qFI8ns0=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurxp3qFI8ns3e", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurxp3qFI8ns3eIQ==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurxp3qFI8ns3eITQ=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurxp3qFI8ns3eITQ+", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurxp3qFI8ns3eITQ+Hw==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurxp3qFI8ns3eITQ+H7U=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurxp3qFI8ns3eITQ+H7VU", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurxp3qFI8ns3eITQ+H7VU1w==", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurxp3qFI8ns3eITQ+H7VU1/s=", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurxp3qFI8ns3eITQ+H7VU1/u0", + "OycDQy37KCphrrxJcTIBFWlcXvXVm96lV8nBfYDeTIHAzyrRhlbVcTfrgDLf5N+27j/cebMXjnZljpYhuYjRbdDd/9qoek31cXf9LvLkQHKMgwBvE3JT5GtwDjfKJc1oYsCrFMdZg9KCjJNtEyHACPltrIR4SYRva/sgO5xJ+06AaYIlhpXVTZHt0ncqJECK302ALc3VWiamcRVCDj+ycBQpH40jLsHqzvl+bN8co4QrJDWnY8gLH4u6Ub/pUYDSI7XRtFmufTAdABzYcGwWccdWCP6BrvvgktjbuVd8mctC7/yzVh7RQtMMGLPurxp3qFI8ns3eITQ+H7VU1/u0vQ==" + }; + + SUITE(test_base64) + { + //************************************************************************* + TEST(test_encode_unsigned_char_pointer_size) + { + std::array encoded_output; + + for (size_t i = 0; i < 256; ++i) + { + encoded_output.fill(0); + + auto size = etl::base64::encode(input_data_unsigned_char.data(), i, + encoded_output.data(), encoded_output.size()); + + std::string expected(encoded[i]); + std::string actual(encoded_output.data(), size); + + CHECK_EQUAL(expected, actual); + CHECK_EQUAL(etl::base64::encode_size(i), size); + } + } + + //************************************************************************* + TEST(test_encode_unsigned_char_pointer_pointer) + { + std::array encoded_output; + + for (size_t i = 0; i < 256; ++i) + { + encoded_output.fill(0); + + auto size = etl::base64::encode(input_data_unsigned_char.data(), input_data_unsigned_char.data() + i, + encoded_output.data(), encoded_output.data() + encoded_output.size()); + + std::string expected(encoded[i]); + std::string actual(encoded_output.data(), size); + + CHECK_EQUAL(expected, actual); + CHECK_EQUAL(etl::base64::encode_size(i), size); + } + } + + //************************************************************************* + TEST(test_encode_unsigned_char_span) + { + std::array encoded_output; + + for (size_t i = 0; i < 256; ++i) + { + encoded_output.fill(0); + + etl::span input_span(input_data_unsigned_char.data(), i); + etl::span output_span(encoded_output.data(), encoded_output.size()); + + auto size = etl::base64::encode(input_span, output_span); + + std::string expected(encoded[i]); + std::string actual(encoded_output.data(), size); + + CHECK_EQUAL(expected, actual); + CHECK_EQUAL(etl::base64::encode_size(i), size); + } + } + + //************************************************************************* + TEST(test_encode_unsigned_char_pointer_size_to_etl_string) + { + etl::string<344U> encoded_output; + + for (size_t i = 0; i < 256; ++i) + { + encoded_output.clear(); + + auto size = etl::base64::encode(input_data_unsigned_char.data(), i, + encoded_output); + + std::string expected(encoded[i]); + std::string actual(encoded_output.data(), size); + + CHECK_EQUAL(expected, actual); + CHECK_EQUAL(etl::base64::encode_size(i), size); + } + } + + //************************************************************************* + TEST(test_encode_unsigned_char_pointer_pointer_to_etl_string) + { + etl::string<344U> encoded_output; + + for (size_t i = 0; i < 256; ++i) + { + encoded_output.clear(); + + auto size = etl::base64::encode(input_data_unsigned_char.data(), input_data_unsigned_char.data() + i, + encoded_output); + + std::string expected(encoded[i]); + std::string actual(encoded_output.data(), size); + + CHECK_EQUAL(expected, actual); + CHECK_EQUAL(etl::base64::encode_size(i), size); + } + } + + //************************************************************************* + TEST(test_encode_unsigned_char_span_to_etl_string) + { + etl::string<344U> encoded_output; + + for (size_t i = 0; i < 256; ++i) + { + encoded_output.clear(); + + etl::span input_span(input_data_unsigned_char.data(), i); + + auto size = etl::base64::encode(input_span, + encoded_output); + + std::string expected(encoded[i]); + std::string actual(encoded_output.data(), size); + + CHECK_EQUAL(expected, actual); + CHECK_EQUAL(etl::base64::encode_size(i), size); + } + } + + //************************************************************************* + TEST(test_encode_int8_t_pointer_size_to_etl_string) + { + etl::string<344U> encoded_output; + + for (size_t i = 0; i < 256; ++i) + { + encoded_output.clear(); + + auto size = etl::base64::encode(input_data_int8_t.data(), i, + encoded_output); + + std::string expected(encoded[i]); + std::string actual(encoded_output.data(), size); + + CHECK_EQUAL(expected, actual); + CHECK_EQUAL(etl::base64::encode_size(i), size); + } + } + + //************************************************************************* + TEST(test_encode_int8_t_pointer_pointer_to_etl_string) + { + etl::string<344U> encoded_output; + + for (size_t i = 0; i < 256; ++i) + { + encoded_output.clear(); + + auto size = etl::base64::encode(input_data_int8_t.data(), input_data_int8_t.data() + i, + encoded_output); + + std::string expected(encoded[i]); + std::string actual(encoded_output.data(), size); + + CHECK_EQUAL(expected, actual); + CHECK_EQUAL(etl::base64::encode_size(i), size); + } + } + + //************************************************************************* + TEST(test_encode_int8_t_span_to_etl_string) + { + etl::string<344U> encoded_output; + + for (size_t i = 0; i < 256; ++i) + { + encoded_output.clear(); + + etl::span input_span(input_data_int8_t.data(), i); + + auto size = etl::base64::encode(input_span, + encoded_output); + + std::string expected(encoded[i]); + std::string actual(encoded_output.data(), size); + + CHECK_EQUAL(expected, actual); + CHECK_EQUAL(etl::base64::encode_size(i), size); + } + } + + //************************************************************************* + TEST(test_encode_int8_t_pointer_size) + { + std::array encoded_output; + + for (size_t i = 0; i < 256; ++i) + { + encoded_output.fill(0); + + auto size = etl::base64::encode(input_data_int8_t.data(), i, + encoded_output.data(), encoded_output.size()); + + std::string expected(encoded[i]); + std::string actual(encoded_output.data(), size); + + CHECK_EQUAL(expected, actual); + CHECK_EQUAL(etl::base64::encode_size(i), size); + } + } + + //************************************************************************* + TEST(test_encode_int8_t_pointer_pointer) + { + std::array encoded_output; + + for (size_t i = 0; i < 256; ++i) + { + encoded_output.fill(0); + + auto size = etl::base64::encode(input_data_int8_t.data(), input_data_int8_t.data() + i, + encoded_output.data(), encoded_output.data() + encoded_output.size()); + + std::string expected(encoded[i]); + std::string actual(encoded_output.data(), size); + + CHECK_EQUAL(expected, actual); + CHECK_EQUAL(etl::base64::encode_size(i), size); + } + } + + //************************************************************************* + TEST(test_encode_int8_t_span) + { + std::array encoded_output; + + for (size_t i = 0; i < 256; ++i) + { + encoded_output.fill(0); + + etl::span input_span(input_data_int8_t.data(), i); + etl::span output_span(encoded_output.data(), encoded_output.size()); + + auto size = etl::base64::encode(input_span, output_span); + + std::string expected(encoded[i]); + std::string actual(encoded_output.data(), size); + + CHECK_EQUAL(expected, actual); + CHECK_EQUAL(etl::base64::encode_size(i), size); + } + } + + //************************************************************************* +#if ETL_USING_CPP14 + template + constexpr auto GetConstexprBase64(const etl::array input) noexcept + { + constexpr size_t encode_size = etl::base64::encode_size(Size); + etl::array output{ 0 }; + + etl::base64::encode(input.begin(), Size, + output._buffer, encode_size); + + return output; + } + + TEST(test_encode_int8_t_constexpr) + { + constexpr etl::array input = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + + constexpr auto output{ GetConstexprBase64(input) }; + + std::string expected("AAECAwQFBgcICQ=="); + std::string actual(output.data(), output.size()); + + CHECK_EQUAL(expected, actual); + CHECK_EQUAL(etl::base64::encode_size(10), output.size()); + } +#endif + + //************************************************************************* + TEST(test_encode_overflow) + { + std::array encoded_output{ 0 }; + + CHECK_THROW((etl::base64::encode(input_data_unsigned_char.data(), 10, + encoded_output.data(), encoded_output.size())), etl::base64_overflow); + } + + //************************************************************************* + TEST(test_encode_overflow_for_etl_string) + { + etl::string<10> output; + + CHECK_THROW((etl::base64::encode(input_data_unsigned_char.data(), 10, output)), etl::base64_overflow); + } + + //************************************************************************* + TEST(test_decode_unsigned_char) + { + std::array decoded_output; + + for (size_t i = 0; i < 256; ++i) + { + decoded_output.fill(0); + + auto decoded_size = etl::base64::decode(encoded[i].data(), encoded[i].size(), + decoded_output.data(), decoded_output.size()); + + CHECK_ARRAY_EQUAL(input_data_unsigned_char.data(), decoded_output.data(), i); + CHECK_EQUAL(i, etl::base64::decode_size(encoded[i].data(), encoded[i].size())); + CHECK_EQUAL(i, decoded_size); + } + } + + //************************************************************************* + TEST(test_decode_int8_t) + { + std::array decoded_output; + + for (size_t i = 0; i < 256; ++i) + { + decoded_output.fill(0); + + auto decoded_size = etl::base64::decode(encoded[i].data(), encoded[i].size(), + decoded_output.data(), decoded_output.size()); + + CHECK_ARRAY_EQUAL(input_data_int8_t.data(), decoded_output.data(), i); + CHECK_EQUAL(i, etl::base64::decode_size(encoded[i].data(), encoded[i].size())); + CHECK_EQUAL(i, decoded_size); + } + } + + //************************************************************************* + TEST(test_decode_overflow) + { + std::array decoded_output{ 0 }; + + CHECK_THROW((etl::base64::decode(encoded[10].data(), encoded[10].size(), + decoded_output.data(), decoded_output.size())), etl::base64_overflow); + } + }; +} + diff --git a/test/test_binary.cpp b/test/test_binary.cpp index 3fe463776..9275f2692 100644 --- a/test/test_binary.cpp +++ b/test/test_binary.cpp @@ -1609,8 +1609,80 @@ namespace //************************************************************************* TEST(test_bit) { +#if ETL_USING_64BIT_TYPES + const uint64_t N = 1UL; +#else const uint32_t N = 1UL; +#endif +#if ETL_USING_CPP17 + CHECK_EQUAL(N << 0U, etl::bit_v<0>); + CHECK_EQUAL(N << 1U, etl::bit_v<1>); + CHECK_EQUAL(N << 2U, etl::bit_v<2>); + CHECK_EQUAL(N << 3U, etl::bit_v<3>); + CHECK_EQUAL(N << 4U, etl::bit_v<4>); + CHECK_EQUAL(N << 5U, etl::bit_v<5>); + CHECK_EQUAL(N << 6U, etl::bit_v<6>); + CHECK_EQUAL(N << 7U, etl::bit_v<7>); + CHECK_EQUAL(N << 8U, etl::bit_v<8>); + CHECK_EQUAL(N << 9U, etl::bit_v<9>); + CHECK_EQUAL(N << 10U, etl::bit_v<10>); + CHECK_EQUAL(N << 11U, etl::bit_v<11>); + CHECK_EQUAL(N << 12U, etl::bit_v<12>); + CHECK_EQUAL(N << 13U, etl::bit_v<13>); + CHECK_EQUAL(N << 14U, etl::bit_v<14>); + CHECK_EQUAL(N << 15U, etl::bit_v<15>); + CHECK_EQUAL(N << 16U, etl::bit_v<16>); + CHECK_EQUAL(N << 17U, etl::bit_v<17>); + CHECK_EQUAL(N << 18U, etl::bit_v<18>); + CHECK_EQUAL(N << 19U, etl::bit_v<19>); + CHECK_EQUAL(N << 20U, etl::bit_v<20>); + CHECK_EQUAL(N << 21U, etl::bit_v<21>); + CHECK_EQUAL(N << 22U, etl::bit_v<22>); + CHECK_EQUAL(N << 23U, etl::bit_v<23>); + CHECK_EQUAL(N << 24U, etl::bit_v<24>); + CHECK_EQUAL(N << 25U, etl::bit_v<25>); + CHECK_EQUAL(N << 26U, etl::bit_v<26>); + CHECK_EQUAL(N << 27U, etl::bit_v<27>); + CHECK_EQUAL(N << 28U, etl::bit_v<28>); + CHECK_EQUAL(N << 29U, etl::bit_v<29>); + CHECK_EQUAL(N << 30U, etl::bit_v<30>); + CHECK_EQUAL(N << 31U, etl::bit_v<31>); + #if ETL_USING_64BIT_TYPES + CHECK_EQUAL(N << 32U, etl::bit_v<32>); + CHECK_EQUAL(N << 33U, etl::bit_v<33>); + CHECK_EQUAL(N << 34U, etl::bit_v<34>); + CHECK_EQUAL(N << 35U, etl::bit_v<35>); + CHECK_EQUAL(N << 36U, etl::bit_v<36>); + CHECK_EQUAL(N << 37U, etl::bit_v<37>); + CHECK_EQUAL(N << 38U, etl::bit_v<38>); + CHECK_EQUAL(N << 39U, etl::bit_v<39>); + CHECK_EQUAL(N << 40U, etl::bit_v<40>); + CHECK_EQUAL(N << 41U, etl::bit_v<41>); + CHECK_EQUAL(N << 42U, etl::bit_v<42>); + CHECK_EQUAL(N << 43U, etl::bit_v<43>); + CHECK_EQUAL(N << 44U, etl::bit_v<44>); + CHECK_EQUAL(N << 45U, etl::bit_v<45>); + CHECK_EQUAL(N << 46U, etl::bit_v<46>); + CHECK_EQUAL(N << 47U, etl::bit_v<47>); + CHECK_EQUAL(N << 48U, etl::bit_v<48>); + CHECK_EQUAL(N << 49U, etl::bit_v<49>); + CHECK_EQUAL(N << 50U, etl::bit_v<50>); + CHECK_EQUAL(N << 51U, etl::bit_v<51>); + CHECK_EQUAL(N << 52U, etl::bit_v<52>); + CHECK_EQUAL(N << 53U, etl::bit_v<53>); + CHECK_EQUAL(N << 54U, etl::bit_v<54>); + CHECK_EQUAL(N << 55U, etl::bit_v<55>); + CHECK_EQUAL(N << 56U, etl::bit_v<56>); + CHECK_EQUAL(N << 57U, etl::bit_v<57>); + CHECK_EQUAL(N << 58U, etl::bit_v<58>); + CHECK_EQUAL(N << 59U, etl::bit_v<59>); + CHECK_EQUAL(N << 60U, etl::bit_v<60>); + CHECK_EQUAL(N << 61U, etl::bit_v<61>); + CHECK_EQUAL(N << 62U, etl::bit_v<62>); + CHECK_EQUAL(N << 63U, etl::bit_v<63>); + #endif +#else CHECK_EQUAL(N << 0U, etl::bit<0>::value); CHECK_EQUAL(N << 1U, etl::bit<1>::value); CHECK_EQUAL(N << 2U, etl::bit<2>::value); @@ -1643,6 +1715,109 @@ namespace CHECK_EQUAL(N << 29U, etl::bit<29>::value); CHECK_EQUAL(N << 30U, etl::bit<30>::value); CHECK_EQUAL(N << 31U, etl::bit<31>::value); + #if ETL_USING_64BIT_TYPES + CHECK_EQUAL(N << 32U, etl::bit<32>::value); + CHECK_EQUAL(N << 33U, etl::bit<33>::value); + CHECK_EQUAL(N << 34U, etl::bit<34>::value); + CHECK_EQUAL(N << 35U, etl::bit<35>::value); + CHECK_EQUAL(N << 36U, etl::bit<36>::value); + CHECK_EQUAL(N << 37U, etl::bit<37>::value); + CHECK_EQUAL(N << 38U, etl::bit<38>::value); + CHECK_EQUAL(N << 39U, etl::bit<39>::value); + CHECK_EQUAL(N << 40U, etl::bit<40>::value); + CHECK_EQUAL(N << 41U, etl::bit<41>::value); + CHECK_EQUAL(N << 42U, etl::bit<42>::value); + CHECK_EQUAL(N << 43U, etl::bit<43>::value); + CHECK_EQUAL(N << 44U, etl::bit<44>::value); + CHECK_EQUAL(N << 45U, etl::bit<45>::value); + CHECK_EQUAL(N << 46U, etl::bit<46>::value); + CHECK_EQUAL(N << 47U, etl::bit<47>::value); + CHECK_EQUAL(N << 48U, etl::bit<48>::value); + CHECK_EQUAL(N << 49U, etl::bit<49>::value); + CHECK_EQUAL(N << 50U, etl::bit<50>::value); + CHECK_EQUAL(N << 51U, etl::bit<51>::value); + CHECK_EQUAL(N << 52U, etl::bit<52>::value); + CHECK_EQUAL(N << 53U, etl::bit<53>::value); + CHECK_EQUAL(N << 54U, etl::bit<54>::value); + CHECK_EQUAL(N << 55U, etl::bit<55>::value); + CHECK_EQUAL(N << 56U, etl::bit<56>::value); + CHECK_EQUAL(N << 57U, etl::bit<57>::value); + CHECK_EQUAL(N << 58U, etl::bit<58>::value); + CHECK_EQUAL(N << 59U, etl::bit<59>::value); + CHECK_EQUAL(N << 60U, etl::bit<60>::value); + CHECK_EQUAL(N << 61U, etl::bit<61>::value); + CHECK_EQUAL(N << 62U, etl::bit<62>::value); + CHECK_EQUAL(N << 63U, etl::bit<63>::value); + #endif +#endif + + CHECK_TRUE((std::is_same, etl::bit_t<0>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<1>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<2>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<3>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<4>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<5>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<6>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<7>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<8>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<9>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<10>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<11>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<12>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<13>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<14>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<15>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<16>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<17>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<18>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<19>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<20>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<21>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<22>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<23>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<24>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<25>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<26>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<27>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<28>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<29>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<30>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<31>>::value)); + +#if ETL_USING_64BIT_TYPES + CHECK_TRUE((std::is_same, etl::bit_t<32>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<33>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<34>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<35>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<36>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<37>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<38>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<39>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<40>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<41>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<42>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<43>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<44>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<45>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<46>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<47>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<48>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<49>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<50>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<51>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<52>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<53>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<54>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<55>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<56>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<57>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<58>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<59>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<60>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<61>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<62>>::value)); + CHECK_TRUE((std::is_same, etl::bit_t<63>>::value)); +#endif } //************************************************************************* diff --git a/test/test_bit_stream_reader_big_endian.cpp b/test/test_bit_stream_reader_big_endian.cpp index 068f8371e..c2918451a 100644 --- a/test/test_bit_stream_reader_big_endian.cpp +++ b/test/test_bit_stream_reader_big_endian.cpp @@ -1046,6 +1046,366 @@ namespace CHECK_EQUAL(int8_t(0x25), result_c2.value()); } + //************************************************************************* + TEST(test_read_multiple_variable_size_using_span_char_dynamic_extent_input) + { + //int8_t c1 = 90; // 0x5A 6 bits + //uint16_t s1 = 4660; // 0x1234 13 bits + //int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits + //int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits + //uint16_t s2 = 22136; // 0x5678 11 bits + //int8_t c2 = -91; // 0xA5 7 bits + + std::array storage = { char(0x6A), char(0x46), char(0x8A), char(0xF3), + char(0x7B), char(0xDB), char(0x97), char(0x53), + char(0x19), char(0xE1), char(0x28) }; + + auto storage_span = etl::span(storage.data(), storage.size()); + + etl::bit_stream_reader bit_stream(storage_span, etl::endian::big); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + auto result_c1 = bit_stream.read(6U); + CHECK(result_c1.has_value()); + CHECK_EQUAL(int8_t(0x1A), result_c1.value()); + + auto result_s1 = bit_stream.read(13U); + CHECK(result_s1.has_value()); + CHECK_EQUAL(uint16_t(0x1234), result_s1.value()); + + auto result_i1 = bit_stream.read(23U); + CHECK(result_i1.has_value()); + CHECK_EQUAL(int32_t(0x002BCDEF), result_i1.value()); + + auto result_i2 = bit_stream.read(25U); + CHECK(result_i2.has_value()); + CHECK_EQUAL(int32_t(0x00DCBA98), result_i2.value()); + + auto result_s2 = bit_stream.read(11U); + CHECK(result_s2.has_value()); + CHECK_EQUAL(uint16_t(0x0678), result_s2.value()); + + auto result_c2 = bit_stream.read(7U); + CHECK(result_c2.has_value()); + CHECK_EQUAL(int8_t(0x25), result_c2.value()); + } + + //************************************************************************* + TEST(test_read_multiple_variable_size_using_span_unsigned_char_dynamic_extent_input) + { + //int8_t c1 = 90; // 0x5A 6 bits + //uint16_t s1 = 4660; // 0x1234 13 bits + //int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits + //int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits + //uint16_t s2 = 22136; // 0x5678 11 bits + //int8_t c2 = -91; // 0xA5 7 bits + + std::array storage = { (unsigned char)(0x6A), (unsigned char)(0x46), (unsigned char)(0x8A), (unsigned char)(0xF3), + (unsigned char)(0x7B), (unsigned char)(0xDB), (unsigned char)(0x97), (unsigned char)(0x53), + (unsigned char)(0x19), (unsigned char)(0xE1), (unsigned char)(0x28) }; + + auto storage_span = etl::span(storage.data(), storage.size()); + + etl::bit_stream_reader bit_stream(storage_span, etl::endian::big); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + auto result_c1 = bit_stream.read(6U); + CHECK(result_c1.has_value()); + CHECK_EQUAL(int8_t(0x1A), result_c1.value()); + + auto result_s1 = bit_stream.read(13U); + CHECK(result_s1.has_value()); + CHECK_EQUAL(uint16_t(0x1234), result_s1.value()); + + auto result_i1 = bit_stream.read(23U); + CHECK(result_i1.has_value()); + CHECK_EQUAL(int32_t(0x002BCDEF), result_i1.value()); + + auto result_i2 = bit_stream.read(25U); + CHECK(result_i2.has_value()); + CHECK_EQUAL(int32_t(0x00DCBA98), result_i2.value()); + + auto result_s2 = bit_stream.read(11U); + CHECK(result_s2.has_value()); + CHECK_EQUAL(uint16_t(0x0678), result_s2.value()); + + auto result_c2 = bit_stream.read(7U); + CHECK(result_c2.has_value()); + CHECK_EQUAL(int8_t(0x25), result_c2.value()); + } + + //************************************************************************* + TEST(test_read_multiple_variable_size_using_span_char_fixed_extent_input) + { + //int8_t c1 = 90; // 0x5A 6 bits + //uint16_t s1 = 4660; // 0x1234 13 bits + //int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits + //int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits + //uint16_t s2 = 22136; // 0x5678 11 bits + //int8_t c2 = -91; // 0xA5 7 bits + + std::array storage = { char(0x6A), char(0x46), char(0x8A), char(0xF3), + char(0x7B), char(0xDB), char(0x97), char(0x53), + char(0x19), char(0xE1), char(0x28) }; + + auto storage_span = etl::span(storage.data(), storage.size()); + + etl::bit_stream_reader bit_stream(storage_span, etl::endian::big); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + auto result_c1 = bit_stream.read(6U); + CHECK(result_c1.has_value()); + CHECK_EQUAL(int8_t(0x1A), result_c1.value()); + + auto result_s1 = bit_stream.read(13U); + CHECK(result_s1.has_value()); + CHECK_EQUAL(uint16_t(0x1234), result_s1.value()); + + auto result_i1 = bit_stream.read(23U); + CHECK(result_i1.has_value()); + CHECK_EQUAL(int32_t(0x002BCDEF), result_i1.value()); + + auto result_i2 = bit_stream.read(25U); + CHECK(result_i2.has_value()); + CHECK_EQUAL(int32_t(0x00DCBA98), result_i2.value()); + + auto result_s2 = bit_stream.read(11U); + CHECK(result_s2.has_value()); + CHECK_EQUAL(uint16_t(0x0678), result_s2.value()); + + auto result_c2 = bit_stream.read(7U); + CHECK(result_c2.has_value()); + CHECK_EQUAL(int8_t(0x25), result_c2.value()); + } + + //************************************************************************* + TEST(test_read_multiple_variable_size_using_span_unsigned_char_fixed_extent_input) + { + //int8_t c1 = 90; // 0x5A 6 bits + //uint16_t s1 = 4660; // 0x1234 13 bits + //int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits + //int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits + //uint16_t s2 = 22136; // 0x5678 11 bits + //int8_t c2 = -91; // 0xA5 7 bits + + std::array storage = { (unsigned char)(0x6A), (unsigned char)(0x46), (unsigned char)(0x8A), (unsigned char)(0xF3), + (unsigned char)(0x7B), (unsigned char)(0xDB), (unsigned char)(0x97), (unsigned char)(0x53), + (unsigned char)(0x19), (unsigned char)(0xE1), (unsigned char)(0x28) }; + + auto storage_span = etl::span(storage.data(), storage.size()); + + etl::bit_stream_reader bit_stream(storage_span, etl::endian::big); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + auto result_c1 = bit_stream.read(6U); + CHECK(result_c1.has_value()); + CHECK_EQUAL(int8_t(0x1A), result_c1.value()); + + auto result_s1 = bit_stream.read(13U); + CHECK(result_s1.has_value()); + CHECK_EQUAL(uint16_t(0x1234), result_s1.value()); + + auto result_i1 = bit_stream.read(23U); + CHECK(result_i1.has_value()); + CHECK_EQUAL(int32_t(0x002BCDEF), result_i1.value()); + + auto result_i2 = bit_stream.read(25U); + CHECK(result_i2.has_value()); + CHECK_EQUAL(int32_t(0x00DCBA98), result_i2.value()); + + auto result_s2 = bit_stream.read(11U); + CHECK(result_s2.has_value()); + CHECK_EQUAL(uint16_t(0x0678), result_s2.value()); + + auto result_c2 = bit_stream.read(7U); + CHECK(result_c2.has_value()); + CHECK_EQUAL(int8_t(0x25), result_c2.value()); + } + + //************************************************************************* + TEST(test_read_multiple_variable_size_using_span_const_char_dynamic_extent_input) + { + //int8_t c1 = 90; // 0x5A 6 bits + //uint16_t s1 = 4660; // 0x1234 13 bits + //int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits + //int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits + //uint16_t s2 = 22136; // 0x5678 11 bits + //int8_t c2 = -91; // 0xA5 7 bits + + std::array storage = { char(0x6A), char(0x46), char(0x8A), char(0xF3), + char(0x7B), char(0xDB), char(0x97), char(0x53), + char(0x19), char(0xE1), char(0x28) }; + + auto storage_span = etl::span(storage.data(), storage.size()); + + etl::bit_stream_reader bit_stream(storage_span, etl::endian::big); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + auto result_c1 = bit_stream.read(6U); + CHECK(result_c1.has_value()); + CHECK_EQUAL(int8_t(0x1A), result_c1.value()); + + auto result_s1 = bit_stream.read(13U); + CHECK(result_s1.has_value()); + CHECK_EQUAL(uint16_t(0x1234), result_s1.value()); + + auto result_i1 = bit_stream.read(23U); + CHECK(result_i1.has_value()); + CHECK_EQUAL(int32_t(0x002BCDEF), result_i1.value()); + + auto result_i2 = bit_stream.read(25U); + CHECK(result_i2.has_value()); + CHECK_EQUAL(int32_t(0x00DCBA98), result_i2.value()); + + auto result_s2 = bit_stream.read(11U); + CHECK(result_s2.has_value()); + CHECK_EQUAL(uint16_t(0x0678), result_s2.value()); + + auto result_c2 = bit_stream.read(7U); + CHECK(result_c2.has_value()); + CHECK_EQUAL(int8_t(0x25), result_c2.value()); + } + + //************************************************************************* + TEST(test_read_multiple_variable_size_using_span_const_unsigned_char_dynamic_extent_input) + { + //int8_t c1 = 90; // 0x5A 6 bits + //uint16_t s1 = 4660; // 0x1234 13 bits + //int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits + //int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits + //uint16_t s2 = 22136; // 0x5678 11 bits + //int8_t c2 = -91; // 0xA5 7 bits + + std::array storage = { (unsigned char)(0x6A), (unsigned char)(0x46), (unsigned char)(0x8A), (unsigned char)(0xF3), + (unsigned char)(0x7B), (unsigned char)(0xDB), (unsigned char)(0x97), (unsigned char)(0x53), + (unsigned char)(0x19), (unsigned char)(0xE1), (unsigned char)(0x28) }; + + auto storage_span = etl::span(storage.data(), storage.size()); + + etl::bit_stream_reader bit_stream(storage_span, etl::endian::big); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + auto result_c1 = bit_stream.read(6U); + CHECK(result_c1.has_value()); + CHECK_EQUAL(int8_t(0x1A), result_c1.value()); + + auto result_s1 = bit_stream.read(13U); + CHECK(result_s1.has_value()); + CHECK_EQUAL(uint16_t(0x1234), result_s1.value()); + + auto result_i1 = bit_stream.read(23U); + CHECK(result_i1.has_value()); + CHECK_EQUAL(int32_t(0x002BCDEF), result_i1.value()); + + auto result_i2 = bit_stream.read(25U); + CHECK(result_i2.has_value()); + CHECK_EQUAL(int32_t(0x00DCBA98), result_i2.value()); + + auto result_s2 = bit_stream.read(11U); + CHECK(result_s2.has_value()); + CHECK_EQUAL(uint16_t(0x0678), result_s2.value()); + + auto result_c2 = bit_stream.read(7U); + CHECK(result_c2.has_value()); + CHECK_EQUAL(int8_t(0x25), result_c2.value()); + } + + //************************************************************************* + TEST(test_read_multiple_variable_size_using_span_const_char_fixed_extent_input) + { + //int8_t c1 = 90; // 0x5A 6 bits + //uint16_t s1 = 4660; // 0x1234 13 bits + //int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits + //int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits + //uint16_t s2 = 22136; // 0x5678 11 bits + //int8_t c2 = -91; // 0xA5 7 bits + + std::array storage = { char(0x6A), char(0x46), char(0x8A), char(0xF3), + char(0x7B), char(0xDB), char(0x97), char(0x53), + char(0x19), char(0xE1), char(0x28) }; + + auto storage_span = etl::span(storage.data(), storage.size()); + + etl::bit_stream_reader bit_stream(storage_span, etl::endian::big); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + auto result_c1 = bit_stream.read(6U); + CHECK(result_c1.has_value()); + CHECK_EQUAL(int8_t(0x1A), result_c1.value()); + + auto result_s1 = bit_stream.read(13U); + CHECK(result_s1.has_value()); + CHECK_EQUAL(uint16_t(0x1234), result_s1.value()); + + auto result_i1 = bit_stream.read(23U); + CHECK(result_i1.has_value()); + CHECK_EQUAL(int32_t(0x002BCDEF), result_i1.value()); + + auto result_i2 = bit_stream.read(25U); + CHECK(result_i2.has_value()); + CHECK_EQUAL(int32_t(0x00DCBA98), result_i2.value()); + + auto result_s2 = bit_stream.read(11U); + CHECK(result_s2.has_value()); + CHECK_EQUAL(uint16_t(0x0678), result_s2.value()); + + auto result_c2 = bit_stream.read(7U); + CHECK(result_c2.has_value()); + CHECK_EQUAL(int8_t(0x25), result_c2.value()); + } + + //************************************************************************* + TEST(test_read_multiple_variable_size_using_span_const_unsigned_char_fixed_extent_input) + { + //int8_t c1 = 90; // 0x5A 6 bits + //uint16_t s1 = 4660; // 0x1234 13 bits + //int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits + //int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits + //uint16_t s2 = 22136; // 0x5678 11 bits + //int8_t c2 = -91; // 0xA5 7 bits + + std::array storage = { (unsigned char)(0x6A), (unsigned char)(0x46), (unsigned char)(0x8A), (unsigned char)(0xF3), + (unsigned char)(0x7B), (unsigned char)(0xDB), (unsigned char)(0x97), (unsigned char)(0x53), + (unsigned char)(0x19), (unsigned char)(0xE1), (unsigned char)(0x28) }; + + auto storage_span = etl::span(storage.data(), storage.size()); + + etl::bit_stream_reader bit_stream(storage_span, etl::endian::big); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + auto result_c1 = bit_stream.read(6U); + CHECK(result_c1.has_value()); + CHECK_EQUAL(int8_t(0x1A), result_c1.value()); + + auto result_s1 = bit_stream.read(13U); + CHECK(result_s1.has_value()); + CHECK_EQUAL(uint16_t(0x1234), result_s1.value()); + + auto result_i1 = bit_stream.read(23U); + CHECK(result_i1.has_value()); + CHECK_EQUAL(int32_t(0x002BCDEF), result_i1.value()); + + auto result_i2 = bit_stream.read(25U); + CHECK(result_i2.has_value()); + CHECK_EQUAL(int32_t(0x00DCBA98), result_i2.value()); + + auto result_s2 = bit_stream.read(11U); + CHECK(result_s2.has_value()); + CHECK_EQUAL(uint16_t(0x0678), result_s2.value()); + + auto result_c2 = bit_stream.read(7U); + CHECK(result_c2.has_value()); + CHECK_EQUAL(int8_t(0x25), result_c2.value()); + } + //************************************************************************* TEST(test_read_multiple_variable_size_using_non_member_functions) { diff --git a/test/test_bit_stream_reader_little_endian.cpp b/test/test_bit_stream_reader_little_endian.cpp index c6ef0d43a..31aad5f5f 100644 --- a/test/test_bit_stream_reader_little_endian.cpp +++ b/test/test_bit_stream_reader_little_endian.cpp @@ -1,1156 +1,1195 @@ -///****************************************************************************** -//The MIT License(MIT) -// -//Embedded Template Library. -//https://github.com/ETLCPP/etl -//https://www.etlcpp.com -// -//Copyright(c) 2018 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 "unit_test_framework.h" -// -//#include "etl/bit_stream.h" -// -//#include -//#include -// -//namespace -//{ -// //*********************************** -// struct Object -// { -// int16_t s; -// int32_t i; -// uint8_t c; -// }; -// -//#include "etl/private/diagnostic_unused_function_push.h" -// bool operator ==(const Object& lhs, const Object& rhs) -// { -// return (lhs.s == rhs.s) && -// (lhs.i == rhs.i) && -// (lhs.c == rhs.c); -// } -// -// std::ostream& operator << (std::ostream& os, const Object& object) -// { -// os << object.s << "," << object.i << "," << (int)object.c; -// return os; -// } -//#include "etl/private/diagnostic_pop.h" -//} -// -//namespace etl -//{ -// //*********************************** -// template <> -// Object read_unchecked(etl::bit_stream_reader& stream) -// { -// int16_t result_s = stream.read_unchecked(14); -// int32_t result_i = stream.read_unchecked(23); -// uint8_t result_c = stream.read_unchecked(); -// -// return Object{ result_s, result_i, result_c }; -// } -// -// //*********************************** -// template <> -// optional read(etl::bit_stream_reader& stream) -// { -// optional result; -// -// etl::optional result_s = stream.read(14); -// etl::optional result_i = stream.read(23); -// etl::optional result_c = stream.read(); -// -// if (result_s.has_value() && result_i.has_value() && result_c.has_value()) -// { -// result = Object{ result_s.value(), result_i.value(), result_c.value() }; -// } -// -// return result; -// } -//} -// -//namespace -//{ -// SUITE(test_bit_stream_reader) -// { -// //************************************************************************* -// TEST(test_read_bool) -// { -// char storage = 0x5AU; -// -// etl::bit_stream_reader bit_stream(&storage, 1, etl::endian::little); -// -// CHECK_EQUAL(1U, bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(false, result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(true, result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(false, result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(true, result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(true, result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(false, result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(true, result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(false, result.value()); -// -// // One too many. -// CHECK_THROW(bit_stream.read(), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_bool_using_non_member_function) -// { -// char storage = 0x5AU; -// -// etl::bit_stream_reader bit_stream(&storage, 1, etl::endian::little); -// -// CHECK_EQUAL(1U, bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = etl::read(bit_stream); -// CHECK(result.has_value()); -// CHECK_EQUAL(false, result.value()); -// -// result.reset(); -// result = etl::read(bit_stream); -// CHECK(result.has_value()); -// CHECK_EQUAL(true, result.value()); -// -// result.reset(); -// result = etl::read(bit_stream); -// CHECK(result.has_value()); -// CHECK_EQUAL(false, result.value()); -// -// result.reset(); -// result = etl::read(bit_stream); -// CHECK(result.has_value()); -// CHECK_EQUAL(true, result.value()); -// -// result.reset(); -// result = etl::read(bit_stream); -// CHECK(result.has_value()); -// CHECK_EQUAL(true, result.value()); -// -// result.reset(); -// result = etl::read(bit_stream); -// CHECK(result.has_value()); -// CHECK_EQUAL(false, result.value()); -// -// result.reset(); -// result = etl::read(bit_stream); -// CHECK(result.has_value()); -// CHECK_EQUAL(true, result.value()); -// -// result.reset(); -// result = etl::read(bit_stream); -// CHECK(result.has_value()); -// CHECK_EQUAL(false, result.value()); -// -// // One too many. -// CHECK_THROW(etl::read(bit_stream), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_int8_t) -// { -// std::array storage = { char(0x80), char(0x5A), char(0xA5), char(0xFF) }; -// std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[0]), int(result.value())); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[1]), int(result.value())); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[2]), int(result.value())); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[3]), int(result.value())); -// -// // One too many. -// CHECK_THROW(bit_stream.read(), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_checked_int8_t_using_non_member_function) -// { -// std::array storage = { char(0x80), char(0x5A), char(0xA5), char(0xFF) }; -// std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = etl::read(bit_stream); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[0]), int(result.value())); -// -// result.reset(); -// result = etl::read(bit_stream); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[1]), int(result.value())); -// -// result.reset(); -// result = etl::read(bit_stream); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[2]), int(result.value())); -// -// result.reset(); -// result = etl::read(bit_stream); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[3]), int(result.value())); -// -// // One too many. -// CHECK_THROW(etl::read(bit_stream), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_unchecked_int8_t_using_non_member_function) -// { -// std::array storage = { char(0x80), char(0x5A), char(0xA5), char(0xFF) }; -// std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// int8_t result; -// -// result = etl::read_unchecked(bit_stream); -// CHECK_EQUAL(int(expected[0]), int(result)); -// -// result = etl::read_unchecked(bit_stream); -// CHECK_EQUAL(int(expected[1]), int(result)); -// -// result = etl::read_unchecked(bit_stream); -// CHECK_EQUAL(int(expected[2]), int(result)); -// -// result = etl::read_unchecked(bit_stream); -// CHECK_EQUAL(int(expected[3]), int(result)); -// } -// -// //************************************************************************* -// TEST(test_read_int8_t_5bits) -// { -// std::array storage = { char(0x85), char(0x69), char(0xF0) }; -// std::array expected = { int8_t(0x01), int8_t(0xF5), int8_t(0x05), int8_t(0xFF) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = bit_stream.read(5U); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[0]), int(result.value())); -// -// result.reset(); -// result = bit_stream.read(5U); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[1]), int(result.value())); -// -// result.reset(); -// result = bit_stream.read(5U); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[2]), int(result.value())); -// -// result.reset(); -// result = bit_stream.read(5U); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[3]), int(result.value())); -// -// // One too many. -// CHECK_THROW(bit_stream.read(5U), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_checked_int8_t_5bits_using_non_member_function) -// { -// std::array storage = { char(0x85), char(0x69), char(0xF0) }; -// std::array expected = { int8_t(0x01), int8_t(0xF5), int8_t(0x05), int8_t(0xFF) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = etl::read(bit_stream, 5U); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[0]), int(result.value())); -// -// result.reset(); -// result = etl::read(bit_stream, 5U); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[1]), int(result.value())); -// -// result.reset(); -// result = etl::read(bit_stream, 5U); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[2]), int(result.value())); -// -// result.reset(); -// result = etl::read(bit_stream, 5U); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[3]), int(result.value())); -// -// // One too many. -// CHECK_THROW(etl::read(bit_stream, 5U), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_unchecked_int8_t_5bits_using_non_member_function) -// { -// std::array storage = { char(0x85), char(0x69), char(0xF0) }; -// std::array expected = { int8_t(0x01), int8_t(0xF5), int8_t(0x05), int8_t(0xFF) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// int8_t result; -// -// result = etl::read_unchecked(bit_stream, 5U); -// CHECK_EQUAL(int(expected[0]), int(result)); -// -// result = etl::read_unchecked(bit_stream, 5U); -// CHECK_EQUAL(int(expected[1]), int(result)); -// -// result = etl::read_unchecked(bit_stream, 5U); -// CHECK_EQUAL(int(expected[2]), int(result)); -// -// result = etl::read_unchecked(bit_stream, 5U); -// CHECK_EQUAL(int(expected[3]), int(result)); -// } -// -// //************************************************************************* -// TEST(test_read_uint8_t) -// { -// std::array storage = { char(0x80), char(0x5A), char(0xA5), char(0xFF) }; -// std::array expected = { uint8_t(0x01), uint8_t(0x5A), uint8_t(0xA5), uint8_t(0xFF) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[0]), int(result.value())); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[1]), int(result.value())); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[2]), int(result.value())); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[3]), int(result.value())); -// -// // One too many. -// CHECK_THROW(bit_stream.read(), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_uint8_t_5bits) -// { -// std::array storage = { char(0x85), char(0x69), char(0xF0) }; -// std::array expected = { uint8_t(0x01), uint8_t(0x15), uint8_t(0x05), uint8_t(0x1F) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = bit_stream.read(5U); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[0]), int(result.value())); -// -// result.reset(); -// result = bit_stream.read(5U); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[1]), int(result.value())); -// -// result.reset(); -// result = bit_stream.read(5U); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[2]), int(result.value())); -// -// result.reset(); -// result = bit_stream.read(5U); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[3]), int(result.value())); -// -// // One too many. -// CHECK_THROW(bit_stream.read(5U), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_uint8_t_5bits_with_skip) -// { -// std::array storage = { char(0x85), char(0x69), char(0xF0) }; -// std::array expected = { uint8_t(0x01), uint8_t(0x15), uint8_t(0x05), uint8_t(0x1F) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = bit_stream.read(5U); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[0]), int(result.value())); -// -// bool success = bit_stream.skip(5U); -// CHECK(success); -// -// result.reset(); -// result = bit_stream.read(5U); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[2]), int(result.value())); -// -// result.reset(); -// result = bit_stream.read(5U); -// CHECK(result.has_value()); -// CHECK_EQUAL(int(expected[3]), int(result.value())); -// -// // One too many. -// CHECK_THROW(bit_stream.read(5U), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_int16_t) -// { -// std::array storage = { char(0x80), char(0x00), char(0xA5), char(0x5A), -// char(0x5A), char(0xA5), char(0xFF), char(0xFF) }; -// std::array expected = { int16_t(0x0001), int16_t(0x5AA5), int16_t(0xA55A), int16_t(0xFFFF) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[0], result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[1], result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[2], result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[3], result.value()); -// -// // One too many. -// CHECK_THROW(bit_stream.read(), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_int16_t_10bits) -// { -// std::array storage = { char(0x80), char(0x16), char(0xAA), char(0x57), char(0xFF) }; -// std::array expected = { int16_t(0x0001), int16_t(0x015A), int16_t(0xFEA5), int16_t(0xFFFF) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = bit_stream.read(10U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[0], result.value()); -// -// result.reset(); -// result = bit_stream.read(10U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[1], result.value()); -// -// result.reset(); -// result = bit_stream.read(10U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[2], result.value()); -// -// result.reset(); -// result = bit_stream.read(10U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[3], result.value()); -// -// // One too many. -// CHECK_THROW(bit_stream.read(10U), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_uint16_t) -// { -// std::array storage = { char(0x80), char(0x00), char(0xA5), char(0x5A), -// char(0x5A), char(0xA5), char(0xFF), char(0xFF) }; -// std::array expected = { uint16_t(0x0001), uint16_t(0x5AA5), uint16_t(0xA55A), uint16_t(0xFFFF) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[0], result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[1], result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[2], result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[3], result.value()); -// -// // One too many. -// CHECK_THROW(bit_stream.read(), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_uint16_t_10bits) -// { -// std::array storage = { char(0x80), char(0x16), char(0xAA), char(0x57), char(0xFF) }; -// std::array expected = { uint16_t(0x0001), uint16_t(0x015A), uint16_t(0x02A5), uint16_t(0x03FF) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = bit_stream.read(10U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[0], result.value()); -// -// result.reset(); -// result = bit_stream.read(10U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[1], result.value()); -// -// result.reset(); -// result = bit_stream.read(10U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[2], result.value()); -// -// result.reset(); -// result = bit_stream.read(10U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[3], result.value()); -// -// // One too many. -// CHECK_THROW(bit_stream.read(10U), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_int32_t) -// { -// std::array storage = { char(0x80), char(0x00), char(0x00), char(0x00), -// char(0x5A), char(0xA5), char(0xA5), char(0x5A), -// char(0xA5), char(0x5A), char(0x5A), char(0xA5), -// char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; -// std::array expected = { int32_t(0x00000001), int32_t(0x5AA5A55A), int32_t(0xA55A5AA5), int32_t(0xFFFFFFFF) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[0], result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[1], result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[2], result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[3], result.value()); -// -// // One too many. -// CHECK_THROW(bit_stream.read(), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_int32_t_22bits) -// { -// std::array storage = { char(0x80), char(0x00), char(0x01), char(0x6A), -// char(0x95), char(0x6A), char(0x55), char(0xAA), -// char(0x7F), char(0xFF), char(0xFF) }; -// std::array expected = { int32_t(0x00000001), int32_t(0x001AA55A), int32_t(0xFFE55AA5), int32_t(0xFFFFFFFF) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = bit_stream.read(22U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[0], result.value()); -// -// result.reset(); -// result = bit_stream.read(22U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[1], result.value()); -// -// result.reset(); -// result = bit_stream.read(22U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[2], result.value()); -// -// result.reset(); -// result = bit_stream.read(22U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[3], result.value()); -// -// // One too many. -// CHECK_THROW(bit_stream.read(22U), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_uint32_t) -// { -// std::array storage = { char(0x80), char(0x00), char(0x00), char(0x00), -// char(0x5A), char(0xA5), char(0xA5), char(0x5A), -// char(0xA5), char(0x5A), char(0x5A), char(0xA5), -// char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; -// std::array expected = { int32_t(0x00000001), int32_t(0x5AA5A55A), int32_t(0xA55A5AA5), int32_t(0xFFFFFFFF) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[0], result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[1], result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[2], result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[3], result.value()); -// -// // One too many. -// CHECK_THROW(bit_stream.read(), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_uint32_t_22bits) -// { -// std::array storage = { char(0x80), char(0x00), char(0x01), char(0x6A), -// char(0x95), char(0x6A), char(0x55), char(0xAA), -// char(0x7F), char(0xFF), char(0xFF) }; -// std::array expected = { uint32_t(0x00000001), uint32_t(0x001AA55A), uint32_t(0x00255AA5), uint32_t(0x003FFFFF) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = bit_stream.read(22U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[0], result.value()); -// -// result.reset(); -// result = bit_stream.read(22U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[1], result.value()); -// -// result.reset(); -// result = bit_stream.read(22U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[2], result.value()); -// -// result.reset(); -// result = bit_stream.read(22U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[3], result.value()); -// -// // One too many. -// CHECK_THROW(bit_stream.read(22U), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_int64_t) -// { -// std::array storage = { char(0x80), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), -// char(0xA5), char(0x5A), char(0x5A), char(0xA5), char(0x5A), char(0xA5), char(0xA5), char(0x5A), -// char(0x5A), char(0xA5), char(0xA5), char(0x5A), char(0xA5), char(0x5A), char(0x5A), char(0xA5), -// char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; -// std::array expected = { int64_t(0x0000000000000001LL), int64_t(0x5AA5A55AA55A5AA5LL), int64_t(0xA55A5AA55AA5A55ALL), int64_t(0xFFFFFFFFFFFFFFFFLL) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[0], result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[1], result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[2], result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[3], result.value()); -// -// // One too many. -// CHECK_THROW(bit_stream.read(), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_int64_t_47bits) -// { -// std::array storage = { char(0x80), char(0x00), char(0x00), char(0x00), -// char(0x00), char(0x00), char(0xB5), char(0x4A), -// char(0xB5), char(0x4A), char(0xB5), char(0x4A), -// char(0x95), char(0x6A), char(0x95), char(0x6A), -// char(0x95), char(0x6F), char(0xFF), char(0xFF), -// char(0xFF), char(0xFF), char(0xFF), char(0xF0) }; -// std::array expected = { int64_t(0x0000000000000001LL), int64_t(0x0000255AA55AA55ALL), int64_t(0xFFFFDAA55AA55AA5LL), int64_t(0xFFFFFFFFFFFFFFFFLL) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = bit_stream.read(47U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[0], result.value()); -// -// result.reset(); -// result = bit_stream.read(47U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[1], result.value()); -// -// result.reset(); -// result = bit_stream.read(47U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[2], result.value()); -// -// result.reset(); -// result = bit_stream.read(47U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[3], result.value()); -// -// // One too many. -// CHECK_THROW(bit_stream.read(47U), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_uint64_t) -// { -// std::array storage = { char(0x80), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), -// char(0xA5), char(0x5A), char(0x5A), char(0xA5), char(0x5A), char(0xA5), char(0xA5), char(0x5A), -// char(0x5A), char(0xA5), char(0xA5), char(0x5A), char(0xA5), char(0x5A), char(0x5A), char(0xA5), -// char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; -// std::array expected = { uint64_t(0x0000000000000001ULL), uint64_t(0x5AA5A55AA55A5AA5ULL), uint64_t(0xA55A5AA55AA5A55AULL), uint64_t(0xFFFFFFFFFFFFFFFFULL) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[0], result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[1], result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[2], result.value()); -// -// result.reset(); -// result = bit_stream.read(); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[3], result.value()); -// -// // One too many. -// CHECK_THROW(bit_stream.read(), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_uint64_t_47bits) -// { -// std::array storage = { char(0x80), char(0x00), char(0x00), char(0x00), -// char(0x00), char(0x00), char(0xB5), char(0x4A), -// char(0xB5), char(0x4A), char(0xB5), char(0x4A), -// char(0x95), char(0x6A), char(0x95), char(0x6A), -// char(0x95), char(0x6F), char(0xFF), char(0xFF), -// char(0xFF), char(0xFF), char(0xFF), char(0xF0) }; -// std::array expected = { uint64_t(0x0000000000000001ULL), uint64_t(0x0000255AA55AA55AULL), uint64_t(0x00005AA55AA55AA5ULL), uint64_t(0x00007FFFFFFFFFFFULL) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// etl::optional result; -// -// result.reset(); -// result = bit_stream.read(47U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[0], result.value()); -// -// result.reset(); -// result = bit_stream.read(47U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[1], result.value()); -// -// result.reset(); -// result = bit_stream.read(47U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[2], result.value()); -// -// result.reset(); -// result = bit_stream.read(47U); -// CHECK(result.has_value()); -// CHECK_EQUAL(expected[3], result.value()); -// -// // One too many. -// CHECK_THROW(bit_stream.read(47U), etl::bit_stream_overflow); -// } -// -// //************************************************************************* -// TEST(test_read_multiple_full_size) -// { -// //int8_t c1 = 90; // 0x5A -// //uint16_t s1 = 4660; // 0x1234 -// //int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF -// //int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 -// //uint16_t s2 = 22136; // 0x5678 -// //int8_t c2 = -91; // 0xA5 -// -// std::array storage = { char(0x5A), -// char(0x2C), char(0x48), -// char(0xF7), char(0xB3), char(0xD5), char(0x91), -// char(0x19), char(0x5D), char(0x3B), char(0x7F), -// char(0x1E), char(0x6A), -// char(0xA5) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// auto result_c1 = bit_stream.read(); -// CHECK(result_c1.has_value()); -// CHECK_EQUAL(int8_t(0x5A), result_c1.value()); -// -// auto result_s1 = bit_stream.read(); -// CHECK(result_s1.has_value()); -// CHECK_EQUAL(uint16_t(0x1234), result_s1.value()); -// -// auto result_i1 = bit_stream.read(); -// CHECK(result_i1.has_value()); -// CHECK_EQUAL(int32_t(0x89ABCDEF), result_i1.value()); -// -// auto result_i2 = bit_stream.read(); -// CHECK(result_i2.has_value()); -// CHECK_EQUAL(int32_t(0xFEDCBA98), result_i2.value()); -// -// auto result_s2 = bit_stream.read(); -// CHECK(result_s2.has_value()); -// CHECK_EQUAL(uint16_t(0x5678), result_s2.value()); -// -// auto result_c2 = bit_stream.read(); -// CHECK(result_c2.has_value()); -// CHECK_EQUAL(int8_t(0xA5), result_c2.value()); -// } -// -// //************************************************************************* -// TEST(test_read_multiple_variable_size) -// { -// //int8_t c1 = 90; // 0x5A 6 bits -// //uint16_t s1 = 4660; // 0x1234 13 bits -// //int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits -// //int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits -// //uint16_t s2 = 22136; // 0x5678 11 bits -// //int8_t c2 = -91; // 0xA5 7 bits -// -// std::array storage = { char(0x58), char(0xB1), char(0x3E), char(0xF6), -// char(0x7A), char(0x86), char(0x57), char(0x4E), -// char(0xC3), char(0xCE), char(0x90) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// auto result_c1 = bit_stream.read(6U); -// CHECK(result_c1.has_value()); -// CHECK_EQUAL(int8_t(0x1A), result_c1.value()); -// -// auto result_s1 = bit_stream.read(13U); -// CHECK(result_s1.has_value()); -// CHECK_EQUAL(uint16_t(0x1234), result_s1.value()); -// -// auto result_i1 = bit_stream.read(23U); -// CHECK(result_i1.has_value()); -// CHECK_EQUAL(int32_t(0x002BCDEF), result_i1.value()); -// -// auto result_i2 = bit_stream.read(25U); -// CHECK(result_i2.has_value()); -// CHECK_EQUAL(int32_t(0x00DCBA98), result_i2.value()); -// -// auto result_s2 = bit_stream.read(11U); -// CHECK(result_s2.has_value()); -// CHECK_EQUAL(uint16_t(0x0678), result_s2.value()); -// -// auto result_c2 = bit_stream.read(7U); -// CHECK(result_c2.has_value()); -// CHECK_EQUAL(int8_t(0x25), result_c2.value()); -// } -// -// //************************************************************************* -// TEST(test_read_multiple_variable_size_using_non_member_functions) -// { -// //int8_t c1 = 90; // 0x5A 6 bits -// //uint16_t s1 = 4660; // 0x1234 13 bits -// //int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits -// //int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits -// //uint16_t s2 = 22136; // 0x5678 11 bits -// //int8_t c2 = -91; // 0xA5 7 bits -// -// std::array storage = { char(0x58), char(0xB1), char(0x3E), char(0xF6), -// char(0x7A), char(0x86), char(0x57), char(0x4E), -// char(0xC3), char(0xCE), char(0x90) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// auto result_c1 = etl::read(bit_stream, 6U); -// CHECK(result_c1.has_value()); -// CHECK_EQUAL(int8_t(0x1A), result_c1.value()); -// -// auto result_s1 = etl::read(bit_stream, 13U); -// CHECK(result_s1.has_value()); -// CHECK_EQUAL(uint16_t(0x1234), result_s1.value()); -// -// auto result_i1 = etl::read(bit_stream, 23U); -// CHECK(result_i1.has_value()); -// CHECK_EQUAL(int32_t(0x002BCDEF), result_i1.value()); -// -// auto result_i2 = etl::read(bit_stream, 25U); -// CHECK(result_i2.has_value()); -// CHECK_EQUAL(int32_t(0x00DCBA98), result_i2.value()); -// -// auto result_s2 = etl::read(bit_stream, 11U); -// CHECK(result_s2.has_value()); -// CHECK_EQUAL(uint16_t(0x0678), result_s2.value()); -// -// auto result_c2 = etl::read(bit_stream, 7U); -// CHECK(result_c2.has_value()); -// CHECK_EQUAL(int8_t(0x25), result_c2.value()); -// } -// -// //************************************************************************* -// TEST(test_read_checked_object) -// { -// std::array storage = { char(0x74), char(0xDE), char(0xA2), char(0xCF), -// char(0x6A), char(0xFB), char(0xA3), char(0x5E), -// char(0x5D), char(0x30), char(0x9F), char(0x80) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// Object object1 = { -1234, -2372331, 250 }; -// Object object2 = { 5678, 2201423, 126 }; -// -// etl::optional result1 = etl::read(bit_stream); -// etl::optional result2 = etl::read(bit_stream); -// -// CHECK(result1.has_value()); -// CHECK(result2.has_value()); -// -// CHECK_EQUAL(object1.s, result1.value().s); -// CHECK_EQUAL(object1.i, result1.value().i); -// CHECK_EQUAL(object1.c, result1.value().c); -// -// CHECK_EQUAL(object2.s, result2.value().s); -// CHECK_EQUAL(object2.i, result2.value().i); -// CHECK_EQUAL(object2.c, result2.value().c); -// } -// -// //************************************************************************* -// TEST(test_read_unchecked_object) -// { -// std::array storage = { char(0x74), char(0xDE), char(0xA2), char(0xCF), -// char(0x6A), char(0xFB), char(0xA3), char(0x5E), -// char(0x5D), char(0x30), char(0x9F), char(0x80) }; -// -// etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); -// -// Object object1 = { -1234, -2372331, 250 }; -// Object object2 = { 5678, 2201423, 126 }; -// -// Object result1 = etl::read_unchecked(bit_stream); -// Object result2 = etl::read_unchecked(bit_stream); -// -// CHECK_EQUAL(object1.s, result1.s); -// CHECK_EQUAL(object1.i, result1.i); -// CHECK_EQUAL(object1.c, result1.c); -// -// CHECK_EQUAL(object2.s, result2.s); -// CHECK_EQUAL(object2.i, result2.i); -// CHECK_EQUAL(object2.c, result2.c); -// } -// }; -//} -// +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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 "unit_test_framework.h" + +#include "etl/bit_stream.h" + +#include +#include + +namespace +{ + //*********************************** + struct Object + { + int16_t s; + int32_t i; + uint8_t c; + }; + +#include "etl/private/diagnostic_unused_function_push.h" + bool operator ==(const Object& lhs, const Object& rhs) + { + return (lhs.s == rhs.s) && + (lhs.i == rhs.i) && + (lhs.c == rhs.c); + } + + std::ostream& operator << (std::ostream& os, const Object& object) + { + os << object.s << "," << object.i << "," << (int)object.c; + return os; + } +#include "etl/private/diagnostic_pop.h" +} + +namespace etl +{ + //*********************************** + template <> + Object read_unchecked(etl::bit_stream_reader& stream) + { + int16_t result_s = stream.read_unchecked(14); + int32_t result_i = stream.read_unchecked(23); + uint8_t result_c = stream.read_unchecked(); + + return Object{ result_s, result_i, result_c }; + } + + //*********************************** + template <> + optional read(etl::bit_stream_reader& stream) + { + optional result; + + etl::optional result_s = stream.read(14); + etl::optional result_i = stream.read(23); + etl::optional result_c = stream.read(); + + if (result_s.has_value() && result_i.has_value() && result_c.has_value()) + { + result = Object{ result_s.value(), result_i.value(), result_c.value() }; + } + + return result; + } +} + +namespace +{ + SUITE(test_bit_stream_reader) + { + //************************************************************************* + TEST(test_read_bool) + { + char storage = 0x5AU; + + etl::bit_stream_reader bit_stream(&storage, 1, etl::endian::little); + + CHECK_EQUAL(1U, bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(false, result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(true, result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(false, result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(true, result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(true, result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(false, result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(true, result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(false, result.value()); + + // One too many. + result.reset(); + result = bit_stream.read(); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_bool_using_non_member_function) + { + char storage = 0x5AU; + + etl::bit_stream_reader bit_stream(&storage, 1, etl::endian::little); + + CHECK_EQUAL(1U, bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = etl::read(bit_stream); + CHECK(result.has_value()); + CHECK_EQUAL(false, result.value()); + + result.reset(); + result = etl::read(bit_stream); + CHECK(result.has_value()); + CHECK_EQUAL(true, result.value()); + + result.reset(); + result = etl::read(bit_stream); + CHECK(result.has_value()); + CHECK_EQUAL(false, result.value()); + + result.reset(); + result = etl::read(bit_stream); + CHECK(result.has_value()); + CHECK_EQUAL(true, result.value()); + + result.reset(); + result = etl::read(bit_stream); + CHECK(result.has_value()); + CHECK_EQUAL(true, result.value()); + + result.reset(); + result = etl::read(bit_stream); + CHECK(result.has_value()); + CHECK_EQUAL(false, result.value()); + + result.reset(); + result = etl::read(bit_stream); + CHECK(result.has_value()); + CHECK_EQUAL(true, result.value()); + + result.reset(); + result = etl::read(bit_stream); + CHECK(result.has_value()); + CHECK_EQUAL(false, result.value()); + + // One too many. + result.reset(); + result = etl::read(bit_stream); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_int8_t) + { + std::array storage = { char(0x80), char(0x5A), char(0xA5), char(0xFF) }; + std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[0]), int(result.value())); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[1]), int(result.value())); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[2]), int(result.value())); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[3]), int(result.value())); + + // One too many. + result.reset(); + result = bit_stream.read(); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_checked_int8_t_using_non_member_function) + { + std::array storage = { char(0x80), char(0x5A), char(0xA5), char(0xFF) }; + std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = etl::read(bit_stream); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[0]), int(result.value())); + + result.reset(); + result = etl::read(bit_stream); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[1]), int(result.value())); + + result.reset(); + result = etl::read(bit_stream); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[2]), int(result.value())); + + result.reset(); + result = etl::read(bit_stream); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[3]), int(result.value())); + + // One too many. + result.reset(); + result = etl::read(bit_stream); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_unchecked_int8_t_using_non_member_function) + { + std::array storage = { char(0x80), char(0x5A), char(0xA5), char(0xFF) }; + std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + int8_t result; + + result = etl::read_unchecked(bit_stream); + CHECK_EQUAL(int(expected[0]), int(result)); + + result = etl::read_unchecked(bit_stream); + CHECK_EQUAL(int(expected[1]), int(result)); + + result = etl::read_unchecked(bit_stream); + CHECK_EQUAL(int(expected[2]), int(result)); + } + + //************************************************************************* + TEST(test_read_int8_t_5bits) + { + std::array storage = { char(0x85), char(0x69), char(0xF0) }; + std::array expected = { int8_t(0x01), int8_t(0xF5), int8_t(0x05), int8_t(0xFF) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = bit_stream.read(5U); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[0]), int(result.value())); + + result.reset(); + result = bit_stream.read(5U); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[1]), int(result.value())); + + result.reset(); + result = bit_stream.read(5U); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[2]), int(result.value())); + + result.reset(); + result = bit_stream.read(5U); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[3]), int(result.value())); + + // One too many. + result.reset(); + result = bit_stream.read(5U); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_checked_int8_t_5bits_using_non_member_function) + { + std::array storage = { char(0x85), char(0x69), char(0xF0) }; + std::array expected = { int8_t(0x01), int8_t(0xF5), int8_t(0x05), int8_t(0xFF) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = etl::read(bit_stream, 5U); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[0]), int(result.value())); + + result.reset(); + result = etl::read(bit_stream, 5U); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[1]), int(result.value())); + + result.reset(); + result = etl::read(bit_stream, 5U); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[2]), int(result.value())); + + result.reset(); + result = etl::read(bit_stream, 5U); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[3]), int(result.value())); + + // One too many. + result.reset(); + result = etl::read(bit_stream, 5U); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_unchecked_int8_t_5bits_using_non_member_function) + { + std::array storage = { char(0x85), char(0x69), char(0xF0) }; + std::array expected = { int8_t(0x01), int8_t(0xF5), int8_t(0x05), int8_t(0xFF) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + int8_t result; + + result = etl::read_unchecked(bit_stream, 5U); + CHECK_EQUAL(int(expected[0]), int(result)); + + result = etl::read_unchecked(bit_stream, 5U); + CHECK_EQUAL(int(expected[1]), int(result)); + + result = etl::read_unchecked(bit_stream, 5U); + CHECK_EQUAL(int(expected[2]), int(result)); + + result = etl::read_unchecked(bit_stream, 5U); + CHECK_EQUAL(int(expected[3]), int(result)); + } + + //************************************************************************* + TEST(test_read_uint8_t) + { + std::array storage = { char(0x80), char(0x5A), char(0xA5), char(0xFF) }; + std::array expected = { uint8_t(0x01), uint8_t(0x5A), uint8_t(0xA5), uint8_t(0xFF) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[0]), int(result.value())); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[1]), int(result.value())); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[2]), int(result.value())); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[3]), int(result.value())); + + // One too many. + result.reset(); + result = bit_stream.read(); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_uint8_t_5bits) + { + std::array storage = { char(0x85), char(0x69), char(0xF0) }; + std::array expected = { uint8_t(0x01), uint8_t(0x15), uint8_t(0x05), uint8_t(0x1F) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = bit_stream.read(5U); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[0]), int(result.value())); + + result.reset(); + result = bit_stream.read(5U); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[1]), int(result.value())); + + result.reset(); + result = bit_stream.read(5U); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[2]), int(result.value())); + + result.reset(); + result = bit_stream.read(5U); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[3]), int(result.value())); + + // One too many. + result.reset(); + result = bit_stream.read(5U); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_uint8_t_5bits_with_skip) + { + std::array storage = { char(0x85), char(0x69), char(0xF0) }; + std::array expected = { uint8_t(0x01), uint8_t(0x15), uint8_t(0x05), uint8_t(0x1F) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = bit_stream.read(5U); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[0]), int(result.value())); + + bool success = bit_stream.skip(5U); + CHECK(success); + + result.reset(); + result = bit_stream.read(5U); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[2]), int(result.value())); + + result.reset(); + result = bit_stream.read(5U); + CHECK(result.has_value()); + CHECK_EQUAL(int(expected[3]), int(result.value())); + + // One too many. + result.reset(); + result = bit_stream.read(5U); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_int16_t) + { + std::array storage = { char(0x80), char(0x00), char(0xA5), char(0x5A), + char(0x5A), char(0xA5), char(0xFF), char(0xFF) }; + std::array expected = { int16_t(0x0001), int16_t(0x5AA5), int16_t(0xA55A), int16_t(0xFFFF) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[0], result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[1], result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[2], result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[3], result.value()); + + // One too many. + result.reset(); + result = bit_stream.read(); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_int16_t_10bits) + { + std::array storage = { char(0x80), char(0x16), char(0xAA), char(0x57), char(0xFF) }; + std::array expected = { int16_t(0x0001), int16_t(0x015A), int16_t(0xFEA5), int16_t(0xFFFF) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = bit_stream.read(10U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[0], result.value()); + + result.reset(); + result = bit_stream.read(10U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[1], result.value()); + + result.reset(); + result = bit_stream.read(10U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[2], result.value()); + + result.reset(); + result = bit_stream.read(10U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[3], result.value()); + + // One too many. + result.reset(); + result = bit_stream.read(10U); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_uint16_t) + { + std::array storage = { char(0x80), char(0x00), char(0xA5), char(0x5A), + char(0x5A), char(0xA5), char(0xFF), char(0xFF) }; + std::array expected = { uint16_t(0x0001), uint16_t(0x5AA5), uint16_t(0xA55A), uint16_t(0xFFFF) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[0], result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[1], result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[2], result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[3], result.value()); + + // One too many. + result.reset(); + result = bit_stream.read(); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_uint16_t_10bits) + { + std::array storage = { char(0x80), char(0x16), char(0xAA), char(0x57), char(0xFF) }; + std::array expected = { uint16_t(0x0001), uint16_t(0x015A), uint16_t(0x02A5), uint16_t(0x03FF) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = bit_stream.read(10U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[0], result.value()); + + result.reset(); + result = bit_stream.read(10U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[1], result.value()); + + result.reset(); + result = bit_stream.read(10U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[2], result.value()); + + result.reset(); + result = bit_stream.read(10U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[3], result.value()); + + // One too many. + result.reset(); + result = bit_stream.read(10U); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_int32_t) + { + std::array storage = { char(0x80), char(0x00), char(0x00), char(0x00), + char(0x5A), char(0xA5), char(0xA5), char(0x5A), + char(0xA5), char(0x5A), char(0x5A), char(0xA5), + char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; + std::array expected = { int32_t(0x00000001), int32_t(0x5AA5A55A), int32_t(0xA55A5AA5), int32_t(0xFFFFFFFF) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[0], result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[1], result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[2], result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[3], result.value()); + + // One too many. + result.reset(); + result = bit_stream.read(); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_int32_t_22bits) + { + std::array storage = { char(0x80), char(0x00), char(0x01), char(0x6A), + char(0x95), char(0x6A), char(0x55), char(0xAA), + char(0x7F), char(0xFF), char(0xFF) }; + std::array expected = { int32_t(0x00000001), int32_t(0x001AA55A), int32_t(0xFFE55AA5), int32_t(0xFFFFFFFF) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = bit_stream.read(22U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[0], result.value()); + + result.reset(); + result = bit_stream.read(22U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[1], result.value()); + + result.reset(); + result = bit_stream.read(22U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[2], result.value()); + + result.reset(); + result = bit_stream.read(22U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[3], result.value()); + + // One too many. + result.reset(); + result = bit_stream.read(22U); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_uint32_t) + { + std::array storage = { char(0x80), char(0x00), char(0x00), char(0x00), + char(0x5A), char(0xA5), char(0xA5), char(0x5A), + char(0xA5), char(0x5A), char(0x5A), char(0xA5), + char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; + std::array expected = { int32_t(0x00000001), int32_t(0x5AA5A55A), int32_t(0xA55A5AA5), int32_t(0xFFFFFFFF) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[0], result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[1], result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[2], result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[3], result.value()); + + // One too many. + result.reset(); + result = bit_stream.read(); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_uint32_t_22bits) + { + std::array storage = { char(0x80), char(0x00), char(0x01), char(0x6A), + char(0x95), char(0x6A), char(0x55), char(0xAA), + char(0x7F), char(0xFF), char(0xFF) }; + std::array expected = { uint32_t(0x00000001), uint32_t(0x001AA55A), uint32_t(0x00255AA5), uint32_t(0x003FFFFF) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = bit_stream.read(22U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[0], result.value()); + + result.reset(); + result = bit_stream.read(22U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[1], result.value()); + + result.reset(); + result = bit_stream.read(22U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[2], result.value()); + + result.reset(); + result = bit_stream.read(22U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[3], result.value()); + + // One too many. + result.reset(); + result = bit_stream.read(22U); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_int64_t) + { + std::array storage = { char(0x80), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), + char(0xA5), char(0x5A), char(0x5A), char(0xA5), char(0x5A), char(0xA5), char(0xA5), char(0x5A), + char(0x5A), char(0xA5), char(0xA5), char(0x5A), char(0xA5), char(0x5A), char(0x5A), char(0xA5), + char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; + std::array expected = { int64_t(0x0000000000000001LL), int64_t(0x5AA5A55AA55A5AA5LL), int64_t(0xA55A5AA55AA5A55ALL), int64_t(0xFFFFFFFFFFFFFFFFLL) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[0], result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[1], result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[2], result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[3], result.value()); + + // One too many. + result.reset(); + result = bit_stream.read(); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_int64_t_47bits) + { + std::array storage = { char(0x80), char(0x00), char(0x00), char(0x00), + char(0x00), char(0x00), char(0xB5), char(0x4A), + char(0xB5), char(0x4A), char(0xB5), char(0x4A), + char(0x95), char(0x6A), char(0x95), char(0x6A), + char(0x95), char(0x6F), char(0xFF), char(0xFF), + char(0xFF), char(0xFF), char(0xFF), char(0xF0) }; + std::array expected = { int64_t(0x0000000000000001LL), int64_t(0x0000255AA55AA55ALL), int64_t(0xFFFFDAA55AA55AA5LL), int64_t(0xFFFFFFFFFFFFFFFFLL) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = bit_stream.read(47U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[0], result.value()); + + result.reset(); + result = bit_stream.read(47U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[1], result.value()); + + result.reset(); + result = bit_stream.read(47U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[2], result.value()); + + result.reset(); + result = bit_stream.read(47U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[3], result.value()); + + // One too many. + result.reset(); + result = bit_stream.read(47U); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_uint64_t) + { + std::array storage = { char(0x80), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), + char(0xA5), char(0x5A), char(0x5A), char(0xA5), char(0x5A), char(0xA5), char(0xA5), char(0x5A), + char(0x5A), char(0xA5), char(0xA5), char(0x5A), char(0xA5), char(0x5A), char(0x5A), char(0xA5), + char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; + std::array expected = { uint64_t(0x0000000000000001ULL), uint64_t(0x5AA5A55AA55A5AA5ULL), uint64_t(0xA55A5AA55AA5A55AULL), uint64_t(0xFFFFFFFFFFFFFFFFULL) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[0], result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[1], result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[2], result.value()); + + result.reset(); + result = bit_stream.read(); + CHECK(result.has_value()); + CHECK_EQUAL(expected[3], result.value()); + + // One too many. + result.reset(); + result = bit_stream.read(); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_uint64_t_47bits) + { + std::array storage = { char(0x80), char(0x00), char(0x00), char(0x00), + char(0x00), char(0x00), char(0xB5), char(0x4A), + char(0xB5), char(0x4A), char(0xB5), char(0x4A), + char(0x95), char(0x6A), char(0x95), char(0x6A), + char(0x95), char(0x6F), char(0xFF), char(0xFF), + char(0xFF), char(0xFF), char(0xFF), char(0xF0) }; + std::array expected = { uint64_t(0x0000000000000001ULL), uint64_t(0x0000255AA55AA55AULL), uint64_t(0x00005AA55AA55AA5ULL), uint64_t(0x00007FFFFFFFFFFFULL) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + etl::optional result; + + result.reset(); + result = bit_stream.read(47U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[0], result.value()); + + result.reset(); + result = bit_stream.read(47U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[1], result.value()); + + result.reset(); + result = bit_stream.read(47U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[2], result.value()); + + result.reset(); + result = bit_stream.read(47U); + CHECK(result.has_value()); + CHECK_EQUAL(expected[3], result.value()); + + // One too many. + result.reset(); + result = bit_stream.read(47U); + CHECK_FALSE(result.has_value()); + } + + //************************************************************************* + TEST(test_read_multiple_full_size) + { + //int8_t c1 = 90; // 0x5A + //uint16_t s1 = 4660; // 0x1234 + //int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF + //int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 + //uint16_t s2 = 22136; // 0x5678 + //int8_t c2 = -91; // 0xA5 + + std::array storage = { char(0x5A), + char(0x2C), char(0x48), + char(0xF7), char(0xB3), char(0xD5), char(0x91), + char(0x19), char(0x5D), char(0x3B), char(0x7F), + char(0x1E), char(0x6A), + char(0xA5) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + auto result_c1 = bit_stream.read(); + CHECK(result_c1.has_value()); + CHECK_EQUAL(int8_t(0x5A), result_c1.value()); + + auto result_s1 = bit_stream.read(); + CHECK(result_s1.has_value()); + CHECK_EQUAL(uint16_t(0x1234), result_s1.value()); + + auto result_i1 = bit_stream.read(); + CHECK(result_i1.has_value()); + CHECK_EQUAL(int32_t(0x89ABCDEF), result_i1.value()); + + auto result_i2 = bit_stream.read(); + CHECK(result_i2.has_value()); + CHECK_EQUAL(int32_t(0xFEDCBA98), result_i2.value()); + + auto result_s2 = bit_stream.read(); + CHECK(result_s2.has_value()); + CHECK_EQUAL(uint16_t(0x5678), result_s2.value()); + + auto result_c2 = bit_stream.read(); + CHECK(result_c2.has_value()); + CHECK_EQUAL(int8_t(0xA5), result_c2.value()); + } + + //************************************************************************* + TEST(test_read_multiple_variable_size) + { + //int8_t c1 = 90; // 0x5A 6 bits + //uint16_t s1 = 4660; // 0x1234 13 bits + //int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits + //int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits + //uint16_t s2 = 22136; // 0x5678 11 bits + //int8_t c2 = -91; // 0xA5 7 bits + + std::array storage = { char(0x58), char(0xB1), char(0x3E), char(0xF6), + char(0x7A), char(0x86), char(0x57), char(0x4E), + char(0xC3), char(0xCE), char(0x90) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + auto result_c1 = bit_stream.read(6U); + CHECK(result_c1.has_value()); + CHECK_EQUAL(int8_t(0x1A), result_c1.value()); + + auto result_s1 = bit_stream.read(13U); + CHECK(result_s1.has_value()); + CHECK_EQUAL(uint16_t(0x1234), result_s1.value()); + + auto result_i1 = bit_stream.read(23U); + CHECK(result_i1.has_value()); + CHECK_EQUAL(int32_t(0x002BCDEF), result_i1.value()); + + auto result_i2 = bit_stream.read(25U); + CHECK(result_i2.has_value()); + CHECK_EQUAL(int32_t(0x00DCBA98), result_i2.value()); + + auto result_s2 = bit_stream.read(11U); + CHECK(result_s2.has_value()); + CHECK_EQUAL(uint16_t(0x0678), result_s2.value()); + + auto result_c2 = bit_stream.read(7U); + CHECK(result_c2.has_value()); + CHECK_EQUAL(int8_t(0x25), result_c2.value()); + } + + //************************************************************************* + TEST(test_read_multiple_variable_size_using_non_member_functions) + { + //int8_t c1 = 90; // 0x5A 6 bits + //uint16_t s1 = 4660; // 0x1234 13 bits + //int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits + //int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits + //uint16_t s2 = 22136; // 0x5678 11 bits + //int8_t c2 = -91; // 0xA5 7 bits + + std::array storage = { char(0x58), char(0xB1), char(0x3E), char(0xF6), + char(0x7A), char(0x86), char(0x57), char(0x4E), + char(0xC3), char(0xCE), char(0x90) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + auto result_c1 = etl::read(bit_stream, 6U); + CHECK(result_c1.has_value()); + CHECK_EQUAL(int8_t(0x1A), result_c1.value()); + + auto result_s1 = etl::read(bit_stream, 13U); + CHECK(result_s1.has_value()); + CHECK_EQUAL(uint16_t(0x1234), result_s1.value()); + + auto result_i1 = etl::read(bit_stream, 23U); + CHECK(result_i1.has_value()); + CHECK_EQUAL(int32_t(0x002BCDEF), result_i1.value()); + + auto result_i2 = etl::read(bit_stream, 25U); + CHECK(result_i2.has_value()); + CHECK_EQUAL(int32_t(0x00DCBA98), result_i2.value()); + + auto result_s2 = etl::read(bit_stream, 11U); + CHECK(result_s2.has_value()); + CHECK_EQUAL(uint16_t(0x0678), result_s2.value()); + + auto result_c2 = etl::read(bit_stream, 7U); + CHECK(result_c2.has_value()); + CHECK_EQUAL(int8_t(0x25), result_c2.value()); + } + + //************************************************************************* + TEST(test_read_checked_object) + { + std::array storage = { char(0x74), char(0xDE), char(0xA2), char(0xCF), + char(0x6A), char(0xFB), char(0xA3), char(0x5E), + char(0x5D), char(0x30), char(0x9F), char(0x80) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + Object object1 = { -1234, -2372331, 250 }; + Object object2 = { 5678, 2201423, 126 }; + + etl::optional result1 = etl::read(bit_stream); + etl::optional result2 = etl::read(bit_stream); + + CHECK(result1.has_value()); + CHECK(result2.has_value()); + + CHECK_EQUAL(object1.s, result1.value().s); + CHECK_EQUAL(object1.i, result1.value().i); + CHECK_EQUAL(object1.c, result1.value().c); + + CHECK_EQUAL(object2.s, result2.value().s); + CHECK_EQUAL(object2.i, result2.value().i); + CHECK_EQUAL(object2.c, result2.value().c); + } + + //************************************************************************* + TEST(test_read_unchecked_object) + { + std::array storage = { char(0x74), char(0xDE), char(0xA2), char(0xCF), + char(0x6A), char(0xFB), char(0xA3), char(0x5E), + char(0x5D), char(0x30), char(0x9F), char(0x80) }; + + etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.size_bytes()); + + Object object1 = { -1234, -2372331, 250 }; + Object object2 = { 5678, 2201423, 126 }; + + Object result1 = etl::read_unchecked(bit_stream); + Object result2 = etl::read_unchecked(bit_stream); + + CHECK_EQUAL(object1.s, result1.s); + CHECK_EQUAL(object1.i, result1.i); + CHECK_EQUAL(object1.c, result1.c); + + CHECK_EQUAL(object2.s, result2.s); + CHECK_EQUAL(object2.i, result2.i); + CHECK_EQUAL(object2.c, result2.c); + } + }; +} + diff --git a/test/test_bit_stream_writer_big_endian.cpp b/test/test_bit_stream_writer_big_endian.cpp index 4ee14e831..31f6a676f 100644 --- a/test/test_bit_stream_writer_big_endian.cpp +++ b/test/test_bit_stream_writer_big_endian.cpp @@ -1,796 +1,796 @@ -///****************************************************************************** -//The MIT License(MIT) -// -//Embedded Template Library. -//https://github.com/ETLCPP/etl -//https://www.etlcpp.com -// -//Copyright(c) 2022 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 "unit_test_framework.h" -// -//#include "etl/bit_stream.h" -// -//#include -//#include -//#include -// -//namespace -//{ -// //*********************************** -// struct Object -// { -// int16_t s; -// int32_t i; -// uint8_t c; -// }; -// -//#include "etl/private/diagnostic_unused_function_push.h" -// bool operator ==(const Object& lhs, const Object& rhs) -// { -// return (lhs.s == rhs.s) && -// (lhs.i == rhs.i) && -// (lhs.c == rhs.c); -// } -// -// std::ostream& operator << (std::ostream& os, const Object& object) -// { -// os << object.s << "," << object.i << "," << (int)object.c; -// return os; -// } -//#include "etl/private/diagnostic_pop.h" -//} -// -//namespace etl -//{ -// //*********************************** -// bool write(etl::bit_stream_writer& stream, const Object& object) -// { -// bool success = true; -// -// if (!stream.write(object.s, 14)) -// { -// success = false; -// } -// -// if (!stream.write(object.i, 23)) -// { -// success = false; -// } -// -// if (!stream.write(object.c)) -// { -// success = false; -// } -// -// return success; -// } -//} -// -//namespace -//{ -// class Accumulator -// { -// public: -// -// void Add(etl::bit_stream_writer::callback_parameter_type s) -// { -// data.insert(data.end(), s.begin(), s.end()); -// } -// -// void Clear() -// { -// data.clear(); -// } -// -// const std::vector& GetData() const -// { -// return data; -// } -// -// private: -// -// std::vector data; -// }; -// -// SUITE(test_bit_stream_big_endian) -// { -// //************************************************************************* -// TEST(test_bit_stream_writer_construction) -// { -// std::array storage; -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); -// -// CHECK_EQUAL(storage.size(), bit_stream.available(CHAR_BIT)); -// CHECK_EQUAL(storage.size(), bit_stream.available()); -// CHECK_EQUAL(storage.size(), bit_stream.available()); -// -// CHECK_EQUAL(storage.size() * CHAR_BIT, bit_stream.available_bits()); -// -// CHECK_EQUAL(0U, bit_stream.size_bits()); -// CHECK_EQUAL(0U, bit_stream.size_bytes()); -// -// CHECK_EQUAL(storage.size(), bit_stream.data().size()); -// CHECK_EQUAL(0U, bit_stream.used_data().size()); -// } -// -// //************************************************************************* -// TEST(test_write_bool) -// { -// unsigned char storage = 0; -// unsigned char expected = 0x5AU; -// -// etl::bit_stream_writer bit_stream(&storage, 1U, etl::endian::big); -// -// CHECK(bit_stream.write(false)); -// CHECK_EQUAL(1U, bit_stream.used_data().size()); -// CHECK(bit_stream.write(true)); -// CHECK_EQUAL(1U, bit_stream.used_data().size()); -// CHECK(bit_stream.write(false)); -// CHECK_EQUAL(1U, bit_stream.used_data().size()); -// CHECK(bit_stream.write(true)); -// CHECK_EQUAL(1U, bit_stream.used_data().size()); -// CHECK(bit_stream.write(true)); -// CHECK_EQUAL(1U, bit_stream.used_data().size()); -// CHECK(bit_stream.write(false)); -// CHECK_EQUAL(1U, bit_stream.used_data().size()); -// CHECK(bit_stream.write(true)); -// CHECK_EQUAL(1U, bit_stream.used_data().size()); -// CHECK(bit_stream.write(false)); -// CHECK_EQUAL(1U, bit_stream.used_data().size()); -// -// // One too many. -// CHECK_THROW(bit_stream.write(true), etl::bit_stream_overflow); -// -// CHECK_EQUAL(1U, bit_stream.data().size()); -// CHECK_EQUAL(1U, bit_stream.used_data().size()); -// -// CHECK_EQUAL(int(expected), int(storage)); -// } -// -// //************************************************************************* -// TEST(test_write_int8_t) -// { -// std::array storage; -// -// std::array expected; -// std::iota(expected.begin(), expected.end(), 0); -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); -// -// for (size_t i = 0UL; i < 256UL; ++i) -// { -// CHECK(bit_stream.write(int8_t(i))); -// CHECK_EQUAL(i + 1U, bit_stream.used_data().size()); -// } -// -// // One too many. -// CHECK_THROW(bit_stream.write(int8_t(0)), etl::bit_stream_overflow); -// -// CHECK_EQUAL(256U, bit_stream.data().size()); -// CHECK_EQUAL(256U, bit_stream.used_data().size()); -// -// for (size_t i = 0UL; i < storage.size(); ++i) -// { -// CHECK_EQUAL(int(expected[i]), int(storage[i])); -// } -// } -// -// //************************************************************************* -// TEST(test_write_uint8_t) -// { -// std::array storage; -// -// std::array expected; -// std::iota(expected.begin(), expected.end(), 0); -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); -// -// for (size_t i = 0UL; i < 256UL; ++i) -// { -// CHECK(bit_stream.write(uint8_t(i))); -// CHECK_EQUAL(i + 1U, bit_stream.used_data().size()); -// } -// -// // One too many. -// CHECK_THROW(bit_stream.write(int8_t(0)), etl::bit_stream_overflow); -// -// CHECK_EQUAL(256U, bit_stream.data().size()); -// CHECK_EQUAL(256U, bit_stream.used_data().size()); -// -// for (size_t i = 0UL; i < storage.size(); ++i) -// { -// CHECK_EQUAL(int(expected[i]), int(storage[i])); -// } -// } -// -// //************************************************************************* -// TEST(test_write_int16_t) -// { -// std::array storage; -// std::array expected = { char(0x00), char(0x01), -// char(0x5A), char(0xA5), -// char(0xA5), char(0x5A), -// char(0xFF), char(0xFF) }; -// -// CHECK(expected.size() == storage.size()); -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); -// -// CHECK(bit_stream.write(int16_t(0x0001))); -// CHECK_EQUAL(sizeof(int16_t) * 1, bit_stream.used_data().size()); -// CHECK(bit_stream.write(int16_t(0x5AA5))); -// CHECK_EQUAL(sizeof(int16_t) * 2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(int16_t(0xA55A))); -// CHECK_EQUAL(sizeof(int16_t) * 3, bit_stream.used_data().size()); -// CHECK(bit_stream.write(int16_t(0xFFFF))); -// CHECK_EQUAL(sizeof(int16_t) * 4, bit_stream.used_data().size()); -// -// // One too many. -// CHECK_THROW(bit_stream.write(int16_t(0)), etl::bit_stream_overflow); -// -// CHECK_EQUAL(sizeof(int16_t) * 4, bit_stream.data().size()); -// CHECK_EQUAL(sizeof(int16_t) * 4, bit_stream.used_data().size()); -// -// for (size_t i = 0UL; i < storage.size(); ++i) -// { -// CHECK_EQUAL(int(expected[i]), int(storage[i])); -// } -// } -// -// //************************************************************************* -// TEST(test_write_uint16_t) -// { -// std::array storage; -// std::array expected = { char(0x00), char(0x01), -// char(0x5A), char(0xA5), -// char(0xA5), char(0x5A), -// char(0xFF), char(0xFF) }; -// -// CHECK(expected.size() == storage.size()); -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); -// -// CHECK(bit_stream.write(uint16_t(0x0001))); -// CHECK_EQUAL(sizeof(uint16_t) * 1, bit_stream.used_data().size()); -// CHECK(bit_stream.write(uint16_t(0x5AA5))); -// CHECK_EQUAL(sizeof(uint16_t) * 2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(uint16_t(0xA55A))); -// CHECK_EQUAL(sizeof(uint16_t) * 3, bit_stream.used_data().size()); -// CHECK(bit_stream.write(uint16_t(0xFFFF))); -// CHECK_EQUAL(sizeof(uint16_t) * 4, bit_stream.used_data().size()); -// -// // One too many. -// CHECK_THROW(bit_stream.write(uint16_t(0)), etl::bit_stream_overflow); -// -// CHECK_EQUAL(sizeof(uint16_t) * 4, bit_stream.data().size()); -// CHECK_EQUAL(sizeof(uint16_t) * 4, bit_stream.used_data().size()); -// -// for (size_t i = 0UL; i < storage.size(); ++i) -// { -// CHECK_EQUAL(int(expected[i]), int(storage[i])); -// } -// } -// -// //************************************************************************* -// TEST(test_write_int32_t) -// { -// std::array storage; -// std::array expected = { char(0x00), char(0x00), char(0x00), char(0x01), -// char(0x5A), char(0xA5), char(0xA5), char(0x5A), -// char(0xA5), char(0x5A), char(0x5A), char(0xA5), -// char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; -// -// CHECK(expected.size() == storage.size()); -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); -// -// CHECK(bit_stream.write(int32_t(0x00000001))); -// CHECK_EQUAL(sizeof(int32_t) * 1, bit_stream.used_data().size()); -// CHECK(bit_stream.write(int32_t(0x5AA5A55A))); -// CHECK_EQUAL(sizeof(int32_t) * 2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(int32_t(0xA55A5AA5))); -// CHECK_EQUAL(sizeof(int32_t) * 3, bit_stream.used_data().size()); -// CHECK(bit_stream.write(int32_t(0xFFFFFFFF))); -// CHECK_EQUAL(sizeof(int32_t) * 4, bit_stream.used_data().size()); -// -// // One too many. -// CHECK_THROW(bit_stream.write(int32_t(0)), etl::bit_stream_overflow); -// -// CHECK_EQUAL(sizeof(int32_t) * 4, bit_stream.data().size()); -// CHECK_EQUAL(sizeof(int32_t) * 4, bit_stream.used_data().size()); -// -// for (size_t i = 0UL; i < storage.size(); ++i) -// { -// CHECK_EQUAL(int(expected[i]), int(storage[i])); -// } -// } -// -// //************************************************************************* -// TEST(test_write_uint32_t) -// { -// std::array storage; -// std::array expected = { char(0x00), char(0x00), char(0x00), char(0x01), -// char(0x5A), char(0xA5), char(0xA5), char(0x5A), -// char(0xA5), char(0x5A), char(0x5A), char(0xA5), -// char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; -// -// CHECK(expected.size() == storage.size()); -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); -// -// CHECK(bit_stream.write(uint32_t(0x00000001))); -// CHECK_EQUAL(sizeof(uint32_t) * 1, bit_stream.used_data().size()); -// CHECK(bit_stream.write(uint32_t(0x5AA5A55A))); -// CHECK_EQUAL(sizeof(uint32_t) * 2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(uint32_t(0xA55A5AA5))); -// CHECK_EQUAL(sizeof(uint32_t) * 3, bit_stream.used_data().size()); -// CHECK(bit_stream.write(uint32_t(0xFFFFFFFF))); -// CHECK_EQUAL(sizeof(uint32_t) * 4, bit_stream.used_data().size()); -// -// // One too many. -// CHECK_THROW(bit_stream.write(uint32_t(0)), etl::bit_stream_overflow); -// -// CHECK_EQUAL(sizeof(uint32_t) * 4, bit_stream.data().size()); -// CHECK_EQUAL(sizeof(uint32_t) * 4, bit_stream.used_data().size()); -// -// for (size_t i = 0UL; i < storage.size(); ++i) -// { -// CHECK_EQUAL(int(expected[i]), int(storage[i])); -// } -// } -// -// //************************************************************************* -// TEST(test_write_int64_t) -// { -// std::array storage; -// std::array expected = { char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x01), -// char(0x5A), char(0xA5), char(0xA5), char(0x5A), char(0xA5), char(0x5A), char(0x5A), char(0xA5), -// char(0xA5), char(0x5A), char(0x5A), char(0xA5), char(0x5A), char(0xA5), char(0xA5), char(0x5A), -// char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; -// -// CHECK(expected.size() == storage.size()); -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); -// -// CHECK(bit_stream.write(int64_t(0x0000000000000001LL))); -// CHECK_EQUAL(sizeof(int64_t) * 1, bit_stream.used_data().size()); -// CHECK(bit_stream.write(int64_t(0x5AA5A55AA55A5AA5LL))); -// CHECK_EQUAL(sizeof(int64_t) * 2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(int64_t(0xA55A5AA55AA5A55ALL))); -// CHECK_EQUAL(sizeof(int64_t) * 3, bit_stream.used_data().size()); -// CHECK(bit_stream.write(int64_t(0xFFFFFFFFFFFFFFFFLL))); -// CHECK_EQUAL(sizeof(int64_t) * 4, bit_stream.used_data().size()); -// -// // One too many. -// CHECK_THROW(bit_stream.write(int64_t(0)), etl::bit_stream_overflow); -// -// CHECK_EQUAL(sizeof(int64_t) * 4, bit_stream.data().size()); -// CHECK_EQUAL(sizeof(int64_t) * 4, bit_stream.used_data().size()); -// -// for (size_t i = 0UL; i < storage.size(); ++i) -// { -// CHECK_EQUAL(int(expected[i]), int(storage[i])); -// } -// } -// -// //************************************************************************* -// TEST(test_write_uint64_t) -// { -// std::array storage; -// std::array expected = { char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x01), -// char(0x5A), char(0xA5), char(0xA5), char(0x5A), char(0xA5), char(0x5A), char(0x5A), char(0xA5), -// char(0xA5), char(0x5A), char(0x5A), char(0xA5), char(0x5A), char(0xA5), char(0xA5), char(0x5A), -// char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; -// -// CHECK(expected.size() == storage.size()); -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); -// -// CHECK(bit_stream.write(uint64_t(0x0000000000000001LL))); -// CHECK_EQUAL(sizeof(uint64_t) * 1, bit_stream.used_data().size()); -// CHECK(bit_stream.write(uint64_t(0x5AA5A55AA55A5AA5LL))); -// CHECK_EQUAL(sizeof(uint64_t) * 2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(uint64_t(0xA55A5AA55AA5A55ALL))); -// CHECK_EQUAL(sizeof(uint64_t) * 3, bit_stream.used_data().size()); -// CHECK(bit_stream.write(uint64_t(0xFFFFFFFFFFFFFFFFLL))); -// CHECK_EQUAL(sizeof(uint64_t) * 4, bit_stream.used_data().size()); -// -// // One too many. -// CHECK_THROW(bit_stream.write(uint64_t(0)), etl::bit_stream_overflow); -// -// CHECK_EQUAL(sizeof(uint64_t) * 4, bit_stream.data().size()); -// CHECK_EQUAL(sizeof(uint64_t) * 4, bit_stream.used_data().size()); -// -// for (size_t i = 0UL; i < storage.size(); ++i) -// { -// CHECK_EQUAL(int(expected[i]), int(storage[i])); -// } -// } -// -// //************************************************************************* -// TEST(test_write_int8_t_5bits) -// { -// std::array storage; -// std::array write_data = { int8_t(0x01), int8_t(0xF5), int8_t(0x05), int8_t(0xFF) }; // 1, -11, 10, -1 -// std::array expected = { char(0x0D), char(0x4B), char(0xF0), char(0x00) }; // 1, -11, 10, -1 -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); -// -// // Insert into the stream -// CHECK(bit_stream.write(write_data[0], 5)); -// CHECK_EQUAL(1, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[1], 5)); -// CHECK_EQUAL(2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[2], 5)); -// CHECK_EQUAL(2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[3], 5)); -// CHECK_EQUAL(3, bit_stream.used_data().size()); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// // 4th byte not used. -// } -// -// //************************************************************************* -// TEST(test_write_int16_t_10bits) -// { -// std::array storage; -// std::array write_data = { int16_t(0x0001), int16_t(0xA55A), int16_t(0x5AA5), int16_t(0xFFFF) }; -// std::array expected = { char(0x00), char(0x55), char(0xAA), char(0x97), -// char(0xFF), char(0x00), char(0x00), char(0x00) }; -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); -// -// // Insert into the stream -// CHECK(bit_stream.write(write_data[0], 10)); -// CHECK_EQUAL(2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[1], 10)); -// CHECK_EQUAL(3, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[2], 10)); -// CHECK_EQUAL(4, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[3], 10)); -// CHECK_EQUAL(5, bit_stream.used_data().size()); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// CHECK_EQUAL((int)expected[3], (int)storage[3]); -// CHECK_EQUAL((int)expected[4], (int)storage[4]); -// // 6th to 8th bytes not used. -// } -// -// //************************************************************************* -// TEST(test_write_uint32_t_22bits) -// { -// std::array storage; -// std::array write_data = { uint32_t(0x00000001UL), uint32_t(0xA55AA55AUL), uint32_t(0x5AA55AA5UL), uint32_t(0xFFFFFFFFUL) }; -// std::array expected = { char(0x00), char(0x00), char(0x05), char(0xAA), -// char(0x55), char(0xA9), char(0x56), char(0xA9), -// char(0x7F), char(0xFF), char(0xFF), char(0x00), -// char(0x00), char(0x00), char(0x00), char(0x00) }; -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); -// -// // Insert into the stream -// CHECK(bit_stream.write(write_data[0], 22)); -// CHECK_EQUAL(3, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[1], 22)); -// CHECK_EQUAL(6, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[2], 22)); -// CHECK_EQUAL(9, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[3], 22)); -// CHECK_EQUAL(11, bit_stream.used_data().size()); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// CHECK_EQUAL((int)expected[3], (int)storage[3]); -// CHECK_EQUAL((int)expected[4], (int)storage[4]); -// CHECK_EQUAL((int)expected[5], (int)storage[5]); -// CHECK_EQUAL((int)expected[6], (int)storage[6]); -// CHECK_EQUAL((int)expected[7], (int)storage[7]); -// CHECK_EQUAL((int)expected[8], (int)storage[8]); -// CHECK_EQUAL((int)expected[9], (int)storage[9]); -// CHECK_EQUAL((int)expected[10], (int)storage[10]); -// // 12th to 16th to bytes not used. -// } -// -// //************************************************************************* -// TEST(test_write_int64_t_47bits) -// { -// std::array storage; -// std::array write_data = { int64_t(0x0000000000000001LL), int64_t(0xA55AA55AA55AA55ALL), int64_t(0x5AA55AA55AA55AA5LL), int64_t(0xFFFFFFFFFFFFFFFFLL) }; -// std::array expected = { char(0x00), char(0x00), char(0x00), char(0x00), -// char(0x00), char(0x02), char(0x95), char(0x6A), -// char(0x95), char(0x6A), char(0x95), char(0x6A), -// char(0xD5), char(0x2A), char(0xD5), char(0x2A), -// char(0xD5), char(0x2F), char(0xFF), char(0xFF), -// char(0xFF), char(0xFF), char(0xFF), char(0xF0) }; -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); -// -// // Insert into the stream -// bit_stream.write(write_data[0], 47); -// CHECK_EQUAL(6, bit_stream.used_data().size()); -// bit_stream.write(write_data[1], 47); -// CHECK_EQUAL(12, bit_stream.used_data().size()); -// bit_stream.write(write_data[2], 47); -// CHECK_EQUAL(18, bit_stream.used_data().size()); -// bit_stream.write(write_data[3], 47); -// CHECK_EQUAL(24, bit_stream.used_data().size()); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// CHECK_EQUAL((int)expected[3], (int)storage[3]); -// CHECK_EQUAL((int)expected[4], (int)storage[4]); -// CHECK_EQUAL((int)expected[5], (int)storage[5]); -// CHECK_EQUAL((int)expected[6], (int)storage[6]); -// CHECK_EQUAL((int)expected[7], (int)storage[7]); -// CHECK_EQUAL((int)expected[8], (int)storage[8]); -// CHECK_EQUAL((int)expected[9], (int)storage[9]); -// CHECK_EQUAL((int)expected[10], (int)storage[10]); -// CHECK_EQUAL((int)expected[11], (int)storage[11]); -// CHECK_EQUAL((int)expected[12], (int)storage[12]); -// CHECK_EQUAL((int)expected[13], (int)storage[13]); -// CHECK_EQUAL((int)expected[14], (int)storage[14]); -// CHECK_EQUAL((int)expected[15], (int)storage[15]); -// CHECK_EQUAL((int)expected[16], (int)storage[16]); -// CHECK_EQUAL((int)expected[17], (int)storage[17]); -// CHECK_EQUAL((int)expected[18], (int)storage[18]); -// CHECK_EQUAL((int)expected[19], (int)storage[19]); -// CHECK_EQUAL((int)expected[20], (int)storage[20]); -// CHECK_EQUAL((int)expected[21], (int)storage[21]); -// CHECK_EQUAL((int)expected[22], (int)storage[22]); -// CHECK_EQUAL((int)expected[23], (int)storage[23]); -// // 25th to 32nd bytes not used. -// } -// -// //************************************************************************* -// TEST(test_write_uint64_t_47bits) -// { -// std::array storage; -// std::array write_data = { uint64_t(0x0000000000000001ULL), uint64_t(0xA55AA55AA55AA55AULL), uint64_t(0x5AA55AA55AA55AA5ULL), uint64_t(0xFFFFFFFFFFFFFFFFULL) }; -// std::array expected = { char(0x00), char(0x00), char(0x00), char(0x00), -// char(0x00), char(0x02), char(0x95), char(0x6A), -// char(0x95), char(0x6A), char(0x95), char(0x6A), -// char(0xD5), char(0x2A), char(0xD5), char(0x2A), -// char(0xD5), char(0x2F), char(0xFF), char(0xFF), -// char(0xFF), char(0xFF), char(0xFF), char(0xF0) }; -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); -// -// // Insert into the stream -// bit_stream.write(write_data[0], 47); -// CHECK_EQUAL(6, bit_stream.used_data().size()); -// bit_stream.write(write_data[1], 47); -// CHECK_EQUAL(12, bit_stream.used_data().size()); -// bit_stream.write(write_data[2], 47); -// CHECK_EQUAL(18, bit_stream.used_data().size()); -// bit_stream.write(write_data[3], 47); -// CHECK_EQUAL(24, bit_stream.used_data().size()); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// CHECK_EQUAL((int)expected[3], (int)storage[3]); -// CHECK_EQUAL((int)expected[4], (int)storage[4]); -// CHECK_EQUAL((int)expected[5], (int)storage[5]); -// CHECK_EQUAL((int)expected[6], (int)storage[6]); -// CHECK_EQUAL((int)expected[7], (int)storage[7]); -// CHECK_EQUAL((int)expected[8], (int)storage[8]); -// CHECK_EQUAL((int)expected[9], (int)storage[9]); -// CHECK_EQUAL((int)expected[10], (int)storage[10]); -// CHECK_EQUAL((int)expected[11], (int)storage[11]); -// CHECK_EQUAL((int)expected[12], (int)storage[12]); -// CHECK_EQUAL((int)expected[13], (int)storage[13]); -// CHECK_EQUAL((int)expected[14], (int)storage[14]); -// CHECK_EQUAL((int)expected[15], (int)storage[15]); -// CHECK_EQUAL((int)expected[16], (int)storage[16]); -// CHECK_EQUAL((int)expected[17], (int)storage[17]); -// CHECK_EQUAL((int)expected[18], (int)storage[18]); -// CHECK_EQUAL((int)expected[19], (int)storage[19]); -// CHECK_EQUAL((int)expected[20], (int)storage[20]); -// CHECK_EQUAL((int)expected[21], (int)storage[21]); -// CHECK_EQUAL((int)expected[22], (int)storage[22]); -// CHECK_EQUAL((int)expected[23], (int)storage[23]); -// // 25th to 32nd bytes not used. -// } -// -// //************************************************************************* -// TEST(test_write_multiple_full_size) -// { -// char c1 = 90; // 0x5A -// char c2 = -91; // 0xA5 -// unsigned short s1 = 4660; // 0x1234 -// unsigned short s2 = 22136; // 0x5678 -// int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF -// int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 -// -// std::array storage; -// std::array expected = { char(0x5A), -// char(0x12), char(0x34), -// char(0x89), char(0xAB), char(0xCD), char(0xEF), -// char(0xFE), char(0xDC), char(0xBA), char(0x98), -// char(0x56), char(0x78), -// char(0xA5) }; -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); -// -// // Insert into the stream. -// bit_stream.write(c1); -// CHECK_EQUAL(1, bit_stream.used_data().size()); -// bit_stream.write(s1); -// CHECK_EQUAL(3, bit_stream.used_data().size()); -// bit_stream.write(i1); -// CHECK_EQUAL(7, bit_stream.used_data().size()); -// bit_stream.write(i2); -// CHECK_EQUAL(11, bit_stream.used_data().size()); -// bit_stream.write(s2); -// CHECK_EQUAL(13, bit_stream.used_data().size()); -// bit_stream.write(c2); -// CHECK_EQUAL(14, bit_stream.used_data().size()); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// CHECK_EQUAL((int)expected[3], (int)storage[3]); -// CHECK_EQUAL((int)expected[4], (int)storage[4]); -// CHECK_EQUAL((int)expected[5], (int)storage[5]); -// CHECK_EQUAL((int)expected[6], (int)storage[6]); -// CHECK_EQUAL((int)expected[7], (int)storage[7]); -// CHECK_EQUAL((int)expected[8], (int)storage[8]); -// CHECK_EQUAL((int)expected[9], (int)storage[9]); -// CHECK_EQUAL((int)expected[10], (int)storage[10]); -// CHECK_EQUAL((int)expected[11], (int)storage[11]); -// CHECK_EQUAL((int)expected[12], (int)storage[12]); -// CHECK_EQUAL((int)expected[13], (int)storage[13]); -// } -// -// //************************************************************************* -// TEST(test_write_multiple_variable_size) -// { -// char c1 = 90; // 0x5A 6 bits -// char c2 = -91; // 0xA5 7 bits -// unsigned short s1 = 4660; // 0x1234 13 bits -// unsigned short s2 = 22136; // 0x5678 11 bits -// int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits -// int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits -// -// std::array storage; -// std::array expected = { char(0x6A), char(0x46), char(0x8A), char(0xF3), -// char(0x7B), char(0xDB), char(0x97), char(0x53), -// char(0x19), char(0xE1), char(0x28) }; -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); -// -// // Insert into the stream. -// bit_stream.write(c1, 6); -// CHECK_EQUAL(1, bit_stream.used_data().size()); -// bit_stream.write(s1, 13); -// CHECK_EQUAL(3, bit_stream.used_data().size()); -// bit_stream.write(i1, 23); -// CHECK_EQUAL(6, bit_stream.used_data().size()); -// bit_stream.write(i2, 25); -// CHECK_EQUAL(9, bit_stream.used_data().size()); -// bit_stream.write(s2, 11); -// CHECK_EQUAL(10, bit_stream.used_data().size()); -// bit_stream.write(c2, 7); -// CHECK_EQUAL(11, bit_stream.used_data().size()); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// CHECK_EQUAL((int)expected[3], (int)storage[3]); -// CHECK_EQUAL((int)expected[4], (int)storage[4]); -// CHECK_EQUAL((int)expected[5], (int)storage[5]); -// CHECK_EQUAL((int)expected[6], (int)storage[6]); -// CHECK_EQUAL((int)expected[7], (int)storage[7]); -// CHECK_EQUAL((int)expected[8], (int)storage[8]); -// CHECK_EQUAL((int)expected[9], (int)storage[9]); -// CHECK_EQUAL((int)expected[10], (int)storage[10]); -// } -// -// //************************************************************************* -// TEST(test_write_multiple_variable_size_with_callback) -// { -// Accumulator accumulator; -// -// char c1 = 90; // 0x5A 6 bits -// char c2 = -91; // 0xA5 7 bits -// unsigned short s1 = 4660U; // 0x1234 13 bits -// unsigned short s2 = 22136U; // 0x5678 11 bits -// int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits -// int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits -// -// std::array storage; -// storage.fill(0); -// std::array expected = { char(0x6A), char(0x46), char(0x8A), char(0xF3), -// char(0x7B), char(0xDB), char(0x97), char(0x53), -// char(0x19), char(0xE1), char(0x28) }; -// -// auto callback = etl::bit_stream_writer::callback_type::create(accumulator); -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big, callback); -// -// // Insert into the stream. -// bit_stream.write(c1, 6); -// bit_stream.write(s1, 13); -// bit_stream.write(i1, 23); -// bit_stream.write(i2, 25); -// bit_stream.write(s2, 11); -// bit_stream.write(c2, 7); -// bit_stream.flush(); -// -// CHECK_EQUAL(bit_stream.capacity_bytes(), bit_stream.available()); -// -// CHECK_EQUAL(11U, accumulator.GetData().size()); -// -// CHECK_EQUAL((int)expected[0], (int)accumulator.GetData()[0]); -// CHECK_EQUAL((int)expected[1], (int)accumulator.GetData()[1]); -// CHECK_EQUAL((int)expected[2], (int)accumulator.GetData()[2]); -// CHECK_EQUAL((int)expected[3], (int)accumulator.GetData()[3]); -// CHECK_EQUAL((int)expected[4], (int)accumulator.GetData()[4]); -// CHECK_EQUAL((int)expected[5], (int)accumulator.GetData()[5]); -// CHECK_EQUAL((int)expected[6], (int)accumulator.GetData()[6]); -// CHECK_EQUAL((int)expected[7], (int)accumulator.GetData()[7]); -// CHECK_EQUAL((int)expected[8], (int)accumulator.GetData()[8]); -// CHECK_EQUAL((int)expected[9], (int)accumulator.GetData()[9]); -// CHECK_EQUAL((int)expected[10], (int)accumulator.GetData()[10]); -// } -// -// //************************************************************************* -// TEST(test_write_object) -// { -// std::array storage; -// storage.fill(0); -// std::array expected{ char(0xEC), char(0xBA), char(0xDE), char(0x68), -// char(0xAF), char(0xD2), char(0xC5), char(0xC8), -// char(0x65), char(0xD3), char(0xDF), char(0x80) }; -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); -// -// Object object1 = { -1234, 123456789, 250 }; -// Object object2 = { 5678, -987654321, 126 }; -// -// CHECK(etl::write(bit_stream, object1)); -// CHECK(etl::write(bit_stream, object2)); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// CHECK_EQUAL((int)expected[3], (int)storage[3]); -// CHECK_EQUAL((int)expected[4], (int)storage[4]); -// CHECK_EQUAL((int)expected[5], (int)storage[5]); -// CHECK_EQUAL((int)expected[6], (int)storage[6]); -// CHECK_EQUAL((int)expected[7], (int)storage[7]); -// CHECK_EQUAL((int)expected[8], (int)storage[8]); -// CHECK_EQUAL((int)expected[9], (int)storage[9]); -// CHECK_EQUAL((int)expected[10], (int)storage[10]); -// CHECK_EQUAL((int)expected[11], (int)storage[11]); -// } -// }; -//} -// +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2022 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 "unit_test_framework.h" + +#include "etl/bit_stream.h" + +#include +#include +#include + +namespace +{ + //*********************************** + struct Object + { + int16_t s; + int32_t i; + uint8_t c; + }; + +#include "etl/private/diagnostic_unused_function_push.h" + bool operator ==(const Object& lhs, const Object& rhs) + { + return (lhs.s == rhs.s) && + (lhs.i == rhs.i) && + (lhs.c == rhs.c); + } + + std::ostream& operator << (std::ostream& os, const Object& object) + { + os << object.s << "," << object.i << "," << (int)object.c; + return os; + } +#include "etl/private/diagnostic_pop.h" +} + +namespace etl +{ + //*********************************** + bool write(etl::bit_stream_writer& stream, const Object& object) + { + bool success = true; + + if (!stream.write(object.s, 14)) + { + success = false; + } + + if (!stream.write(object.i, 23)) + { + success = false; + } + + if (!stream.write(object.c)) + { + success = false; + } + + return success; + } +} + +namespace +{ + class Accumulator + { + public: + + void Add(etl::bit_stream_writer::callback_parameter_type s) + { + data.insert(data.end(), s.begin(), s.end()); + } + + void Clear() + { + data.clear(); + } + + const std::vector& GetData() const + { + return data; + } + + private: + + std::vector data; + }; + + SUITE(test_bit_stream_big_endian) + { + //************************************************************************* + TEST(test_bit_stream_writer_construction) + { + std::array storage; + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); + + CHECK_EQUAL(storage.size(), bit_stream.available(CHAR_BIT)); + CHECK_EQUAL(storage.size(), bit_stream.available()); + CHECK_EQUAL(storage.size(), bit_stream.available()); + + CHECK_EQUAL(storage.size() * CHAR_BIT, bit_stream.available_bits()); + + CHECK_EQUAL(0U, bit_stream.size_bits()); + CHECK_EQUAL(0U, bit_stream.size_bytes()); + + CHECK_EQUAL(storage.size(), bit_stream.data().size()); + CHECK_EQUAL(0U, bit_stream.used_data().size()); + } + + //************************************************************************* + TEST(test_write_bool) + { + unsigned char storage = 0; + unsigned char expected = 0x5AU; + + etl::bit_stream_writer bit_stream(&storage, 1U, etl::endian::big); + + CHECK(bit_stream.write(false)); + CHECK_EQUAL(1U, bit_stream.used_data().size()); + CHECK(bit_stream.write(true)); + CHECK_EQUAL(1U, bit_stream.used_data().size()); + CHECK(bit_stream.write(false)); + CHECK_EQUAL(1U, bit_stream.used_data().size()); + CHECK(bit_stream.write(true)); + CHECK_EQUAL(1U, bit_stream.used_data().size()); + CHECK(bit_stream.write(true)); + CHECK_EQUAL(1U, bit_stream.used_data().size()); + CHECK(bit_stream.write(false)); + CHECK_EQUAL(1U, bit_stream.used_data().size()); + CHECK(bit_stream.write(true)); + CHECK_EQUAL(1U, bit_stream.used_data().size()); + CHECK(bit_stream.write(false)); + CHECK_EQUAL(1U, bit_stream.used_data().size()); + + // One too many. + CHECK_FALSE(bit_stream.write(true)); + + CHECK_EQUAL(1U, bit_stream.data().size()); + CHECK_EQUAL(1U, bit_stream.used_data().size()); + + CHECK_EQUAL(int(expected), int(storage)); + } + + //************************************************************************* + TEST(test_write_int8_t) + { + std::array storage; + + std::array expected; + std::iota(expected.begin(), expected.end(), 0); + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); + + for (size_t i = 0UL; i < 256UL; ++i) + { + CHECK(bit_stream.write(int8_t(i))); + CHECK_EQUAL(i + 1U, bit_stream.used_data().size()); + } + + // One too many. + CHECK_FALSE(bit_stream.write(int8_t(0))); + + CHECK_EQUAL(256U, bit_stream.data().size()); + CHECK_EQUAL(256U, bit_stream.used_data().size()); + + for (size_t i = 0UL; i < storage.size(); ++i) + { + CHECK_EQUAL(int(expected[i]), int(storage[i])); + } + } + + //************************************************************************* + TEST(test_write_uint8_t) + { + std::array storage; + + std::array expected; + std::iota(expected.begin(), expected.end(), 0); + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); + + for (size_t i = 0UL; i < 256UL; ++i) + { + CHECK(bit_stream.write(uint8_t(i))); + CHECK_EQUAL(i + 1U, bit_stream.used_data().size()); + } + + // One too many. + CHECK_FALSE(bit_stream.write(int8_t(0))); + + CHECK_EQUAL(256U, bit_stream.data().size()); + CHECK_EQUAL(256U, bit_stream.used_data().size()); + + for (size_t i = 0UL; i < storage.size(); ++i) + { + CHECK_EQUAL(int(expected[i]), int(storage[i])); + } + } + + //************************************************************************* + TEST(test_write_int16_t) + { + std::array storage; + std::array expected = { char(0x00), char(0x01), + char(0x5A), char(0xA5), + char(0xA5), char(0x5A), + char(0xFF), char(0xFF) }; + + CHECK(expected.size() == storage.size()); + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); + + CHECK(bit_stream.write(int16_t(0x0001))); + CHECK_EQUAL(sizeof(int16_t) * 1, bit_stream.used_data().size()); + CHECK(bit_stream.write(int16_t(0x5AA5))); + CHECK_EQUAL(sizeof(int16_t) * 2, bit_stream.used_data().size()); + CHECK(bit_stream.write(int16_t(0xA55A))); + CHECK_EQUAL(sizeof(int16_t) * 3, bit_stream.used_data().size()); + CHECK(bit_stream.write(int16_t(0xFFFF))); + CHECK_EQUAL(sizeof(int16_t) * 4, bit_stream.used_data().size()); + + // One too many. + CHECK_FALSE(bit_stream.write(int16_t(0))); + + CHECK_EQUAL(sizeof(int16_t) * 4, bit_stream.data().size()); + CHECK_EQUAL(sizeof(int16_t) * 4, bit_stream.used_data().size()); + + for (size_t i = 0UL; i < storage.size(); ++i) + { + CHECK_EQUAL(int(expected[i]), int(storage[i])); + } + } + + //************************************************************************* + TEST(test_write_uint16_t) + { + std::array storage; + std::array expected = { char(0x00), char(0x01), + char(0x5A), char(0xA5), + char(0xA5), char(0x5A), + char(0xFF), char(0xFF) }; + + CHECK(expected.size() == storage.size()); + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); + + CHECK(bit_stream.write(uint16_t(0x0001))); + CHECK_EQUAL(sizeof(uint16_t) * 1, bit_stream.used_data().size()); + CHECK(bit_stream.write(uint16_t(0x5AA5))); + CHECK_EQUAL(sizeof(uint16_t) * 2, bit_stream.used_data().size()); + CHECK(bit_stream.write(uint16_t(0xA55A))); + CHECK_EQUAL(sizeof(uint16_t) * 3, bit_stream.used_data().size()); + CHECK(bit_stream.write(uint16_t(0xFFFF))); + CHECK_EQUAL(sizeof(uint16_t) * 4, bit_stream.used_data().size()); + + // One too many. + CHECK_FALSE(bit_stream.write(uint16_t(0))); + + CHECK_EQUAL(sizeof(uint16_t) * 4, bit_stream.data().size()); + CHECK_EQUAL(sizeof(uint16_t) * 4, bit_stream.used_data().size()); + + for (size_t i = 0UL; i < storage.size(); ++i) + { + CHECK_EQUAL(int(expected[i]), int(storage[i])); + } + } + + //************************************************************************* + TEST(test_write_int32_t) + { + std::array storage; + std::array expected = { char(0x00), char(0x00), char(0x00), char(0x01), + char(0x5A), char(0xA5), char(0xA5), char(0x5A), + char(0xA5), char(0x5A), char(0x5A), char(0xA5), + char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; + + CHECK(expected.size() == storage.size()); + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); + + CHECK(bit_stream.write(int32_t(0x00000001))); + CHECK_EQUAL(sizeof(int32_t) * 1, bit_stream.used_data().size()); + CHECK(bit_stream.write(int32_t(0x5AA5A55A))); + CHECK_EQUAL(sizeof(int32_t) * 2, bit_stream.used_data().size()); + CHECK(bit_stream.write(int32_t(0xA55A5AA5))); + CHECK_EQUAL(sizeof(int32_t) * 3, bit_stream.used_data().size()); + CHECK(bit_stream.write(int32_t(0xFFFFFFFF))); + CHECK_EQUAL(sizeof(int32_t) * 4, bit_stream.used_data().size()); + + // One too many. + CHECK_FALSE(bit_stream.write(int32_t(0))); + + CHECK_EQUAL(sizeof(int32_t) * 4, bit_stream.data().size()); + CHECK_EQUAL(sizeof(int32_t) * 4, bit_stream.used_data().size()); + + for (size_t i = 0UL; i < storage.size(); ++i) + { + CHECK_EQUAL(int(expected[i]), int(storage[i])); + } + } + + //************************************************************************* + TEST(test_write_uint32_t) + { + std::array storage; + std::array expected = { char(0x00), char(0x00), char(0x00), char(0x01), + char(0x5A), char(0xA5), char(0xA5), char(0x5A), + char(0xA5), char(0x5A), char(0x5A), char(0xA5), + char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; + + CHECK(expected.size() == storage.size()); + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); + + CHECK(bit_stream.write(uint32_t(0x00000001))); + CHECK_EQUAL(sizeof(uint32_t) * 1, bit_stream.used_data().size()); + CHECK(bit_stream.write(uint32_t(0x5AA5A55A))); + CHECK_EQUAL(sizeof(uint32_t) * 2, bit_stream.used_data().size()); + CHECK(bit_stream.write(uint32_t(0xA55A5AA5))); + CHECK_EQUAL(sizeof(uint32_t) * 3, bit_stream.used_data().size()); + CHECK(bit_stream.write(uint32_t(0xFFFFFFFF))); + CHECK_EQUAL(sizeof(uint32_t) * 4, bit_stream.used_data().size()); + + // One too many. + CHECK_FALSE(bit_stream.write(uint32_t(0))); + + CHECK_EQUAL(sizeof(uint32_t) * 4, bit_stream.data().size()); + CHECK_EQUAL(sizeof(uint32_t) * 4, bit_stream.used_data().size()); + + for (size_t i = 0UL; i < storage.size(); ++i) + { + CHECK_EQUAL(int(expected[i]), int(storage[i])); + } + } + + //************************************************************************* + TEST(test_write_int64_t) + { + std::array storage; + std::array expected = { char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x01), + char(0x5A), char(0xA5), char(0xA5), char(0x5A), char(0xA5), char(0x5A), char(0x5A), char(0xA5), + char(0xA5), char(0x5A), char(0x5A), char(0xA5), char(0x5A), char(0xA5), char(0xA5), char(0x5A), + char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; + + CHECK(expected.size() == storage.size()); + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); + + CHECK(bit_stream.write(int64_t(0x0000000000000001LL))); + CHECK_EQUAL(sizeof(int64_t) * 1, bit_stream.used_data().size()); + CHECK(bit_stream.write(int64_t(0x5AA5A55AA55A5AA5LL))); + CHECK_EQUAL(sizeof(int64_t) * 2, bit_stream.used_data().size()); + CHECK(bit_stream.write(int64_t(0xA55A5AA55AA5A55ALL))); + CHECK_EQUAL(sizeof(int64_t) * 3, bit_stream.used_data().size()); + CHECK(bit_stream.write(int64_t(0xFFFFFFFFFFFFFFFFLL))); + CHECK_EQUAL(sizeof(int64_t) * 4, bit_stream.used_data().size()); + + // One too many. + CHECK_FALSE(bit_stream.write(int64_t(0))); + + CHECK_EQUAL(sizeof(int64_t) * 4, bit_stream.data().size()); + CHECK_EQUAL(sizeof(int64_t) * 4, bit_stream.used_data().size()); + + for (size_t i = 0UL; i < storage.size(); ++i) + { + CHECK_EQUAL(int(expected[i]), int(storage[i])); + } + } + + //************************************************************************* + TEST(test_write_uint64_t) + { + std::array storage; + std::array expected = { char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x01), + char(0x5A), char(0xA5), char(0xA5), char(0x5A), char(0xA5), char(0x5A), char(0x5A), char(0xA5), + char(0xA5), char(0x5A), char(0x5A), char(0xA5), char(0x5A), char(0xA5), char(0xA5), char(0x5A), + char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; + + CHECK(expected.size() == storage.size()); + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); + + CHECK(bit_stream.write(uint64_t(0x0000000000000001LL))); + CHECK_EQUAL(sizeof(uint64_t) * 1, bit_stream.used_data().size()); + CHECK(bit_stream.write(uint64_t(0x5AA5A55AA55A5AA5LL))); + CHECK_EQUAL(sizeof(uint64_t) * 2, bit_stream.used_data().size()); + CHECK(bit_stream.write(uint64_t(0xA55A5AA55AA5A55ALL))); + CHECK_EQUAL(sizeof(uint64_t) * 3, bit_stream.used_data().size()); + CHECK(bit_stream.write(uint64_t(0xFFFFFFFFFFFFFFFFLL))); + CHECK_EQUAL(sizeof(uint64_t) * 4, bit_stream.used_data().size()); + + // One too many. + CHECK_FALSE(bit_stream.write(uint64_t(0))); + + CHECK_EQUAL(sizeof(uint64_t) * 4, bit_stream.data().size()); + CHECK_EQUAL(sizeof(uint64_t) * 4, bit_stream.used_data().size()); + + for (size_t i = 0UL; i < storage.size(); ++i) + { + CHECK_EQUAL(int(expected[i]), int(storage[i])); + } + } + + //************************************************************************* + TEST(test_write_int8_t_5bits) + { + std::array storage; + std::array write_data = { int8_t(0x01), int8_t(0xF5), int8_t(0x05), int8_t(0xFF) }; // 1, -11, 10, -1 + std::array expected = { char(0x0D), char(0x4B), char(0xF0), char(0x00) }; // 1, -11, 10, -1 + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); + + // Insert into the stream + CHECK(bit_stream.write(write_data[0], 5)); + CHECK_EQUAL(1, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[1], 5)); + CHECK_EQUAL(2, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[2], 5)); + CHECK_EQUAL(2, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[3], 5)); + CHECK_EQUAL(3, bit_stream.used_data().size()); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + // 4th byte not used. + } + + //************************************************************************* + TEST(test_write_int16_t_10bits) + { + std::array storage; + std::array write_data = { int16_t(0x0001), int16_t(0xA55A), int16_t(0x5AA5), int16_t(0xFFFF) }; + std::array expected = { char(0x00), char(0x55), char(0xAA), char(0x97), + char(0xFF), char(0x00), char(0x00), char(0x00) }; + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); + + // Insert into the stream + CHECK(bit_stream.write(write_data[0], 10)); + CHECK_EQUAL(2, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[1], 10)); + CHECK_EQUAL(3, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[2], 10)); + CHECK_EQUAL(4, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[3], 10)); + CHECK_EQUAL(5, bit_stream.used_data().size()); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + CHECK_EQUAL((int)expected[3], (int)storage[3]); + CHECK_EQUAL((int)expected[4], (int)storage[4]); + // 6th to 8th bytes not used. + } + + //************************************************************************* + TEST(test_write_uint32_t_22bits) + { + std::array storage; + std::array write_data = { uint32_t(0x00000001UL), uint32_t(0xA55AA55AUL), uint32_t(0x5AA55AA5UL), uint32_t(0xFFFFFFFFUL) }; + std::array expected = { char(0x00), char(0x00), char(0x05), char(0xAA), + char(0x55), char(0xA9), char(0x56), char(0xA9), + char(0x7F), char(0xFF), char(0xFF), char(0x00), + char(0x00), char(0x00), char(0x00), char(0x00) }; + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); + + // Insert into the stream + CHECK(bit_stream.write(write_data[0], 22)); + CHECK_EQUAL(3, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[1], 22)); + CHECK_EQUAL(6, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[2], 22)); + CHECK_EQUAL(9, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[3], 22)); + CHECK_EQUAL(11, bit_stream.used_data().size()); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + CHECK_EQUAL((int)expected[3], (int)storage[3]); + CHECK_EQUAL((int)expected[4], (int)storage[4]); + CHECK_EQUAL((int)expected[5], (int)storage[5]); + CHECK_EQUAL((int)expected[6], (int)storage[6]); + CHECK_EQUAL((int)expected[7], (int)storage[7]); + CHECK_EQUAL((int)expected[8], (int)storage[8]); + CHECK_EQUAL((int)expected[9], (int)storage[9]); + CHECK_EQUAL((int)expected[10], (int)storage[10]); + // 12th to 16th to bytes not used. + } + + //************************************************************************* + TEST(test_write_int64_t_47bits) + { + std::array storage; + std::array write_data = { int64_t(0x0000000000000001LL), int64_t(0xA55AA55AA55AA55ALL), int64_t(0x5AA55AA55AA55AA5LL), int64_t(0xFFFFFFFFFFFFFFFFLL) }; + std::array expected = { char(0x00), char(0x00), char(0x00), char(0x00), + char(0x00), char(0x02), char(0x95), char(0x6A), + char(0x95), char(0x6A), char(0x95), char(0x6A), + char(0xD5), char(0x2A), char(0xD5), char(0x2A), + char(0xD5), char(0x2F), char(0xFF), char(0xFF), + char(0xFF), char(0xFF), char(0xFF), char(0xF0) }; + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); + + // Insert into the stream + bit_stream.write(write_data[0], 47); + CHECK_EQUAL(6, bit_stream.used_data().size()); + bit_stream.write(write_data[1], 47); + CHECK_EQUAL(12, bit_stream.used_data().size()); + bit_stream.write(write_data[2], 47); + CHECK_EQUAL(18, bit_stream.used_data().size()); + bit_stream.write(write_data[3], 47); + CHECK_EQUAL(24, bit_stream.used_data().size()); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + CHECK_EQUAL((int)expected[3], (int)storage[3]); + CHECK_EQUAL((int)expected[4], (int)storage[4]); + CHECK_EQUAL((int)expected[5], (int)storage[5]); + CHECK_EQUAL((int)expected[6], (int)storage[6]); + CHECK_EQUAL((int)expected[7], (int)storage[7]); + CHECK_EQUAL((int)expected[8], (int)storage[8]); + CHECK_EQUAL((int)expected[9], (int)storage[9]); + CHECK_EQUAL((int)expected[10], (int)storage[10]); + CHECK_EQUAL((int)expected[11], (int)storage[11]); + CHECK_EQUAL((int)expected[12], (int)storage[12]); + CHECK_EQUAL((int)expected[13], (int)storage[13]); + CHECK_EQUAL((int)expected[14], (int)storage[14]); + CHECK_EQUAL((int)expected[15], (int)storage[15]); + CHECK_EQUAL((int)expected[16], (int)storage[16]); + CHECK_EQUAL((int)expected[17], (int)storage[17]); + CHECK_EQUAL((int)expected[18], (int)storage[18]); + CHECK_EQUAL((int)expected[19], (int)storage[19]); + CHECK_EQUAL((int)expected[20], (int)storage[20]); + CHECK_EQUAL((int)expected[21], (int)storage[21]); + CHECK_EQUAL((int)expected[22], (int)storage[22]); + CHECK_EQUAL((int)expected[23], (int)storage[23]); + // 25th to 32nd bytes not used. + } + + //************************************************************************* + TEST(test_write_uint64_t_47bits) + { + std::array storage; + std::array write_data = { uint64_t(0x0000000000000001ULL), uint64_t(0xA55AA55AA55AA55AULL), uint64_t(0x5AA55AA55AA55AA5ULL), uint64_t(0xFFFFFFFFFFFFFFFFULL) }; + std::array expected = { char(0x00), char(0x00), char(0x00), char(0x00), + char(0x00), char(0x02), char(0x95), char(0x6A), + char(0x95), char(0x6A), char(0x95), char(0x6A), + char(0xD5), char(0x2A), char(0xD5), char(0x2A), + char(0xD5), char(0x2F), char(0xFF), char(0xFF), + char(0xFF), char(0xFF), char(0xFF), char(0xF0) }; + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); + + // Insert into the stream + bit_stream.write(write_data[0], 47); + CHECK_EQUAL(6, bit_stream.used_data().size()); + bit_stream.write(write_data[1], 47); + CHECK_EQUAL(12, bit_stream.used_data().size()); + bit_stream.write(write_data[2], 47); + CHECK_EQUAL(18, bit_stream.used_data().size()); + bit_stream.write(write_data[3], 47); + CHECK_EQUAL(24, bit_stream.used_data().size()); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + CHECK_EQUAL((int)expected[3], (int)storage[3]); + CHECK_EQUAL((int)expected[4], (int)storage[4]); + CHECK_EQUAL((int)expected[5], (int)storage[5]); + CHECK_EQUAL((int)expected[6], (int)storage[6]); + CHECK_EQUAL((int)expected[7], (int)storage[7]); + CHECK_EQUAL((int)expected[8], (int)storage[8]); + CHECK_EQUAL((int)expected[9], (int)storage[9]); + CHECK_EQUAL((int)expected[10], (int)storage[10]); + CHECK_EQUAL((int)expected[11], (int)storage[11]); + CHECK_EQUAL((int)expected[12], (int)storage[12]); + CHECK_EQUAL((int)expected[13], (int)storage[13]); + CHECK_EQUAL((int)expected[14], (int)storage[14]); + CHECK_EQUAL((int)expected[15], (int)storage[15]); + CHECK_EQUAL((int)expected[16], (int)storage[16]); + CHECK_EQUAL((int)expected[17], (int)storage[17]); + CHECK_EQUAL((int)expected[18], (int)storage[18]); + CHECK_EQUAL((int)expected[19], (int)storage[19]); + CHECK_EQUAL((int)expected[20], (int)storage[20]); + CHECK_EQUAL((int)expected[21], (int)storage[21]); + CHECK_EQUAL((int)expected[22], (int)storage[22]); + CHECK_EQUAL((int)expected[23], (int)storage[23]); + // 25th to 32nd bytes not used. + } + + //************************************************************************* + TEST(test_write_multiple_full_size) + { + char c1 = 90; // 0x5A + char c2 = -91; // 0xA5 + unsigned short s1 = 4660; // 0x1234 + unsigned short s2 = 22136; // 0x5678 + int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF + int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 + + std::array storage; + std::array expected = { char(0x5A), + char(0x12), char(0x34), + char(0x89), char(0xAB), char(0xCD), char(0xEF), + char(0xFE), char(0xDC), char(0xBA), char(0x98), + char(0x56), char(0x78), + char(0xA5) }; + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); + + // Insert into the stream. + bit_stream.write(c1); + CHECK_EQUAL(1, bit_stream.used_data().size()); + bit_stream.write(s1); + CHECK_EQUAL(3, bit_stream.used_data().size()); + bit_stream.write(i1); + CHECK_EQUAL(7, bit_stream.used_data().size()); + bit_stream.write(i2); + CHECK_EQUAL(11, bit_stream.used_data().size()); + bit_stream.write(s2); + CHECK_EQUAL(13, bit_stream.used_data().size()); + bit_stream.write(c2); + CHECK_EQUAL(14, bit_stream.used_data().size()); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + CHECK_EQUAL((int)expected[3], (int)storage[3]); + CHECK_EQUAL((int)expected[4], (int)storage[4]); + CHECK_EQUAL((int)expected[5], (int)storage[5]); + CHECK_EQUAL((int)expected[6], (int)storage[6]); + CHECK_EQUAL((int)expected[7], (int)storage[7]); + CHECK_EQUAL((int)expected[8], (int)storage[8]); + CHECK_EQUAL((int)expected[9], (int)storage[9]); + CHECK_EQUAL((int)expected[10], (int)storage[10]); + CHECK_EQUAL((int)expected[11], (int)storage[11]); + CHECK_EQUAL((int)expected[12], (int)storage[12]); + CHECK_EQUAL((int)expected[13], (int)storage[13]); + } + + //************************************************************************* + TEST(test_write_multiple_variable_size) + { + char c1 = 90; // 0x5A 6 bits + char c2 = -91; // 0xA5 7 bits + unsigned short s1 = 4660; // 0x1234 13 bits + unsigned short s2 = 22136; // 0x5678 11 bits + int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits + int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits + + std::array storage; + std::array expected = { char(0x6A), char(0x46), char(0x8A), char(0xF3), + char(0x7B), char(0xDB), char(0x97), char(0x53), + char(0x19), char(0xE1), char(0x28) }; + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); + + // Insert into the stream. + bit_stream.write(c1, 6); + CHECK_EQUAL(1, bit_stream.used_data().size()); + bit_stream.write(s1, 13); + CHECK_EQUAL(3, bit_stream.used_data().size()); + bit_stream.write(i1, 23); + CHECK_EQUAL(6, bit_stream.used_data().size()); + bit_stream.write(i2, 25); + CHECK_EQUAL(9, bit_stream.used_data().size()); + bit_stream.write(s2, 11); + CHECK_EQUAL(10, bit_stream.used_data().size()); + bit_stream.write(c2, 7); + CHECK_EQUAL(11, bit_stream.used_data().size()); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + CHECK_EQUAL((int)expected[3], (int)storage[3]); + CHECK_EQUAL((int)expected[4], (int)storage[4]); + CHECK_EQUAL((int)expected[5], (int)storage[5]); + CHECK_EQUAL((int)expected[6], (int)storage[6]); + CHECK_EQUAL((int)expected[7], (int)storage[7]); + CHECK_EQUAL((int)expected[8], (int)storage[8]); + CHECK_EQUAL((int)expected[9], (int)storage[9]); + CHECK_EQUAL((int)expected[10], (int)storage[10]); + } + + //************************************************************************* + TEST(test_write_multiple_variable_size_with_callback) + { + Accumulator accumulator; + + char c1 = 90; // 0x5A 6 bits + char c2 = -91; // 0xA5 7 bits + unsigned short s1 = 4660U; // 0x1234 13 bits + unsigned short s2 = 22136U; // 0x5678 11 bits + int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits + int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits + + std::array storage; + storage.fill(0); + std::array expected = { char(0x6A), char(0x46), char(0x8A), char(0xF3), + char(0x7B), char(0xDB), char(0x97), char(0x53), + char(0x19), char(0xE1), char(0x28) }; + + auto callback = etl::bit_stream_writer::callback_type::create(accumulator); + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big, callback); + + // Insert into the stream. + bit_stream.write(c1, 6); + bit_stream.write(s1, 13); + bit_stream.write(i1, 23); + bit_stream.write(i2, 25); + bit_stream.write(s2, 11); + bit_stream.write(c2, 7); + bit_stream.flush(); + + CHECK_EQUAL(bit_stream.capacity_bytes(), bit_stream.available()); + + CHECK_EQUAL(11U, accumulator.GetData().size()); + + CHECK_EQUAL((int)expected[0], (int)accumulator.GetData()[0]); + CHECK_EQUAL((int)expected[1], (int)accumulator.GetData()[1]); + CHECK_EQUAL((int)expected[2], (int)accumulator.GetData()[2]); + CHECK_EQUAL((int)expected[3], (int)accumulator.GetData()[3]); + CHECK_EQUAL((int)expected[4], (int)accumulator.GetData()[4]); + CHECK_EQUAL((int)expected[5], (int)accumulator.GetData()[5]); + CHECK_EQUAL((int)expected[6], (int)accumulator.GetData()[6]); + CHECK_EQUAL((int)expected[7], (int)accumulator.GetData()[7]); + CHECK_EQUAL((int)expected[8], (int)accumulator.GetData()[8]); + CHECK_EQUAL((int)expected[9], (int)accumulator.GetData()[9]); + CHECK_EQUAL((int)expected[10], (int)accumulator.GetData()[10]); + } + + //************************************************************************* + TEST(test_write_object) + { + std::array storage; + storage.fill(0); + std::array expected{ char(0xEC), char(0xBA), char(0xDE), char(0x68), + char(0xAF), char(0xD2), char(0xC5), char(0xC8), + char(0x65), char(0xD3), char(0xDF), char(0x80) }; + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::big); + + Object object1 = { -1234, 123456789, 250 }; + Object object2 = { 5678, -987654321, 126 }; + + CHECK(etl::write(bit_stream, object1)); + CHECK(etl::write(bit_stream, object2)); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + CHECK_EQUAL((int)expected[3], (int)storage[3]); + CHECK_EQUAL((int)expected[4], (int)storage[4]); + CHECK_EQUAL((int)expected[5], (int)storage[5]); + CHECK_EQUAL((int)expected[6], (int)storage[6]); + CHECK_EQUAL((int)expected[7], (int)storage[7]); + CHECK_EQUAL((int)expected[8], (int)storage[8]); + CHECK_EQUAL((int)expected[9], (int)storage[9]); + CHECK_EQUAL((int)expected[10], (int)storage[10]); + CHECK_EQUAL((int)expected[11], (int)storage[11]); + } + }; +} + diff --git a/test/test_bit_stream_writer_little_endian.cpp b/test/test_bit_stream_writer_little_endian.cpp index ddb958b64..f53b7682d 100644 --- a/test/test_bit_stream_writer_little_endian.cpp +++ b/test/test_bit_stream_writer_little_endian.cpp @@ -1,883 +1,883 @@ -///****************************************************************************** -//The MIT License(MIT) -// -//Embedded Template Library. -//https://github.com/ETLCPP/etl -//https://www.etlcpp.com -// -//Copyright(c) 2022 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 "unit_test_framework.h" -// -//#include "etl/bit_stream.h" -// -//#include -//#include -//#include -// -//namespace -//{ -// //*********************************** -// struct Object -// { -// int16_t s; -// int32_t i; -// uint8_t c; -// }; -// -//#include "etl/private/diagnostic_unused_function_push.h" -// bool operator ==(const Object& lhs, const Object& rhs) -// { -// return (lhs.s == rhs.s) && -// (lhs.i == rhs.i) && -// (lhs.c == rhs.c); -// } -// -// std::ostream& operator << (std::ostream& os, const Object& object) -// { -// os << object.s << "," << object.i << "," << (int)object.c; -// return os; -// } -//#include "etl/private/diagnostic_pop.h" -//} -// -//namespace etl -//{ -// //*********************************** -// bool write(etl::bit_stream_writer& stream, const Object& object) -// { -// bool success = true; -// -// if (!stream.write(object.s, 14)) -// { -// success = false; -// } -// -// if (!stream.write(object.i, 23)) -// { -// success = false; -// } -// -// if (!stream.write(object.c)) -// { -// success = false; -// } -// -// return success; -// } -//} -// -//namespace -//{ -// class Accumulator -// { -// public: -// -// void Add(etl::bit_stream_writer::callback_parameter_type s) -// { -// data.insert(data.end(), s.begin(), s.end()); -// } -// -// void Clear() -// { -// data.clear(); -// } -// -// const std::vector& GetData() const -// { -// return data; -// } -// -// private: -// -// std::vector data; -// }; -// -// SUITE(test_bit_stream_little_endian) -// { -// //************************************************************************* -// TEST(test_bit_stream_writer_construction) -// { -// std::array storage; -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK_EQUAL(storage.size(), bit_stream.available(CHAR_BIT)); -// CHECK_EQUAL(storage.size(), bit_stream.available()); -// CHECK_EQUAL(storage.size(), bit_stream.available()); -// -// CHECK_EQUAL(storage.size() * CHAR_BIT, bit_stream.available_bits()); -// -// CHECK_EQUAL(0U, bit_stream.size_bits()); -// CHECK_EQUAL(0U, bit_stream.size_bytes()); -// -// CHECK_EQUAL(storage.size(), bit_stream.data().size()); -// CHECK_EQUAL(0U, bit_stream.used_data().size()); -// } -// -// //************************************************************************* -// TEST(test_write_bool) -// { -// unsigned char storage = 0; -// unsigned char expected = 0x5AU; -// -// etl::bit_stream_writer bit_stream(&storage, 1U, etl::endian::little); -// -// CHECK(bit_stream.write(false)); -// CHECK_EQUAL(1U, bit_stream.used_data().size()); -// CHECK(bit_stream.write(true)); -// CHECK_EQUAL(1U, bit_stream.used_data().size()); -// CHECK(bit_stream.write(false)); -// CHECK_EQUAL(1U, bit_stream.used_data().size()); -// CHECK(bit_stream.write(true)); -// CHECK_EQUAL(1U, bit_stream.used_data().size()); -// CHECK(bit_stream.write(true)); -// CHECK_EQUAL(1U, bit_stream.used_data().size()); -// CHECK(bit_stream.write(false)); -// CHECK_EQUAL(1U, bit_stream.used_data().size()); -// CHECK(bit_stream.write(true)); -// CHECK_EQUAL(1U, bit_stream.used_data().size()); -// CHECK(bit_stream.write(false)); -// CHECK_EQUAL(1U, bit_stream.used_data().size()); -// -// // One too many. -// CHECK_THROW(bit_stream.write(true), etl::bit_stream_overflow); -// -// CHECK_EQUAL(1U, bit_stream.data().size()); -// CHECK_EQUAL(1U, bit_stream.used_data().size()); -// -// CHECK_EQUAL(int(expected), int(storage)); -// } -// -// //************************************************************************* -// TEST(test_write_int8_t) -// { -// std::array storage; -// -// std::array expected; -// std::iota(expected.begin(), expected.end(), 0); -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// for (size_t i = 0UL; i < 256UL; ++i) -// { -// CHECK(bit_stream.write(int8_t(i))); -// CHECK_EQUAL(i + 1U, bit_stream.used_data().size()); -// } -// -// // One too many. -// CHECK_THROW(bit_stream.write(int8_t(0)), etl::bit_stream_overflow); -// -// CHECK_EQUAL(256U, bit_stream.data().size()); -// CHECK_EQUAL(256U, bit_stream.used_data().size()); -// -// for (size_t i = 0UL; i < storage.size(); ++i) -// { -// CHECK_EQUAL(int(etl::reverse_bits(expected[i])), int(storage[i])); -// } -// } -// -// //************************************************************************* -// TEST(test_write_uint8_t) -// { -// std::array storage; -// -// std::array expected; -// std::iota(expected.begin(), expected.end(), 0); -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// for (size_t i = 0UL; i < 256UL; ++i) -// { -// CHECK(bit_stream.write(uint8_t(i))); -// CHECK_EQUAL(i + 1U, bit_stream.used_data().size()); -// } -// -// // One too many. -// CHECK_THROW(bit_stream.write(int8_t(0)), etl::bit_stream_overflow); -// -// CHECK_EQUAL(256U, bit_stream.data().size()); -// CHECK_EQUAL(256U, bit_stream.used_data().size()); -// -// for (size_t i = 0UL; i < storage.size(); ++i) -// { -// CHECK_EQUAL(int(etl::reverse_bits(expected[i])), int(storage[i])); -// } -// } -// -// //************************************************************************* -// TEST(test_write_int16_t) -// { -// std::array storage; -// std::array expected = { char(0x80), char(0x00), -// char(0xA5), char(0x5A), -// char(0x5A), char(0xA5), -// char(0xFF), char(0xFF) }; -// -// CHECK(expected.size() == storage.size()); -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK(bit_stream.write(int16_t(0x0001))); -// CHECK_EQUAL(sizeof(int16_t) * 1, bit_stream.used_data().size()); -// CHECK(bit_stream.write(int16_t(0x5AA5))); -// CHECK_EQUAL(sizeof(int16_t) * 2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(int16_t(0xA55A))); -// CHECK_EQUAL(sizeof(int16_t) * 3, bit_stream.used_data().size()); -// CHECK(bit_stream.write(int16_t(0xFFFF))); -// CHECK_EQUAL(sizeof(int16_t) * 4, bit_stream.used_data().size()); -// -// // One too many. -// CHECK_THROW(bit_stream.write(int16_t(0)), etl::bit_stream_overflow); -// -// CHECK_EQUAL(sizeof(int16_t) * 4, bit_stream.data().size()); -// CHECK_EQUAL(sizeof(int16_t) * 4, bit_stream.used_data().size()); -// -// for (size_t i = 0UL; i < storage.size(); ++i) -// { -// CHECK_EQUAL(int(expected[i]), int(storage[i])); -// } -// } -// -// //************************************************************************* -// TEST(test_write_uint16_t) -// { -// std::array storage; -// std::array expected = { char(0x80), char(0x00), -// char(0xA5), char(0x5A), -// char(0x5A), char(0xA5), -// char(0xFF), char(0xFF) }; -// -// CHECK(expected.size() == storage.size()); -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK(bit_stream.write(uint16_t(0x0001))); -// CHECK_EQUAL(sizeof(uint16_t) * 1, bit_stream.used_data().size()); -// CHECK(bit_stream.write(uint16_t(0x5AA5))); -// CHECK_EQUAL(sizeof(uint16_t) * 2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(uint16_t(0xA55A))); -// CHECK_EQUAL(sizeof(uint16_t) * 3, bit_stream.used_data().size()); -// CHECK(bit_stream.write(uint16_t(0xFFFF))); -// CHECK_EQUAL(sizeof(uint16_t) * 4, bit_stream.used_data().size()); -// -// // One too many. -// CHECK_THROW(bit_stream.write(uint16_t(0)), etl::bit_stream_overflow); -// -// CHECK_EQUAL(sizeof(uint16_t) * 4, bit_stream.data().size()); -// CHECK_EQUAL(sizeof(uint16_t) * 4, bit_stream.used_data().size()); -// -// for (size_t i = 0UL; i < storage.size(); ++i) -// { -// CHECK_EQUAL(int(expected[i]), int(storage[i])); -// } -// } -// -// //************************************************************************* -// TEST(test_write_int32_t) -// { -// std::array storage; -// std::array expected = { char(0x80), char(0x00), char(0x00), char(0x00), -// char(0x5A), char(0xA5), char(0xA5), char(0x5A), -// char(0xA5), char(0x5A), char(0x5A), char(0xA5), -// char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; -// -// CHECK(expected.size() == storage.size()); -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK(bit_stream.write(int32_t(0x00000001))); -// CHECK_EQUAL(sizeof(int32_t) * 1, bit_stream.used_data().size()); -// CHECK(bit_stream.write(int32_t(0x5AA5A55A))); -// CHECK_EQUAL(sizeof(int32_t) * 2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(int32_t(0xA55A5AA5))); -// CHECK_EQUAL(sizeof(int32_t) * 3, bit_stream.used_data().size()); -// CHECK(bit_stream.write(int32_t(0xFFFFFFFF))); -// CHECK_EQUAL(sizeof(int32_t) * 4, bit_stream.used_data().size()); -// -// // One too many. -// CHECK_THROW(bit_stream.write(int32_t(0)), etl::bit_stream_overflow); -// -// CHECK_EQUAL(sizeof(int32_t) * 4, bit_stream.data().size()); -// CHECK_EQUAL(sizeof(int32_t) * 4, bit_stream.used_data().size()); -// -// for (size_t i = 0UL; i < storage.size(); ++i) -// { -// CHECK_EQUAL(int(expected[i]), int(storage[i])); -// } -// } -// -// //************************************************************************* -// TEST(test_write_uint32_t) -// { -// std::array storage; -// std::array expected = { char(0x80), char(0x00), char(0x00), char(0x00), -// char(0x5A), char(0xA5), char(0xA5), char(0x5A), -// char(0xA5), char(0x5A), char(0x5A), char(0xA5), -// char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; -// -// CHECK(expected.size() == storage.size()); -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK(bit_stream.write(uint32_t(0x00000001))); -// CHECK_EQUAL(sizeof(uint32_t) * 1, bit_stream.used_data().size()); -// CHECK(bit_stream.write(uint32_t(0x5AA5A55A))); -// CHECK_EQUAL(sizeof(uint32_t) * 2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(uint32_t(0xA55A5AA5))); -// CHECK_EQUAL(sizeof(uint32_t) * 3, bit_stream.used_data().size()); -// CHECK(bit_stream.write(uint32_t(0xFFFFFFFF))); -// CHECK_EQUAL(sizeof(uint32_t) * 4, bit_stream.used_data().size()); -// -// // One too many. -// CHECK_THROW(bit_stream.write(uint32_t(0)), etl::bit_stream_overflow); -// -// CHECK_EQUAL(sizeof(uint32_t) * 4, bit_stream.data().size()); -// CHECK_EQUAL(sizeof(uint32_t) * 4, bit_stream.used_data().size()); -// -// for (size_t i = 0UL; i < storage.size(); ++i) -// { -// CHECK_EQUAL(int(expected[i]), int(storage[i])); -// } -// } -// -// //************************************************************************* -// TEST(test_write_int64_t) -// { -// std::array storage; -// std::array expected = { char(0x80), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), -// char(0xA5), char(0x5A), char(0x5A), char(0xA5), char(0x5A), char(0xA5), char(0xA5), char(0x5A), -// char(0x5A), char(0xA5), char(0xA5), char(0x5A), char(0xA5), char(0x5A), char(0x5A), char(0xA5), -// char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; -// -// CHECK(expected.size() == storage.size()); -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK(bit_stream.write(int64_t(0x0000000000000001LL))); -// CHECK_EQUAL(sizeof(int64_t) * 1, bit_stream.used_data().size()); -// CHECK(bit_stream.write(int64_t(0x5AA5A55AA55A5AA5LL))); -// CHECK_EQUAL(sizeof(int64_t) * 2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(int64_t(0xA55A5AA55AA5A55ALL))); -// CHECK_EQUAL(sizeof(int64_t) * 3, bit_stream.used_data().size()); -// CHECK(bit_stream.write(int64_t(0xFFFFFFFFFFFFFFFFLL))); -// CHECK_EQUAL(sizeof(int64_t) * 4, bit_stream.used_data().size()); -// -// // One too many. -// CHECK_THROW(bit_stream.write(int64_t(0)), etl::bit_stream_overflow); -// -// CHECK_EQUAL(sizeof(int64_t) * 4, bit_stream.data().size()); -// CHECK_EQUAL(sizeof(int64_t) * 4, bit_stream.used_data().size()); -// -// for (size_t i = 0UL; i < storage.size(); ++i) -// { -// CHECK_EQUAL(int(expected[i]), int(storage[i])); -// } -// } -// -// //************************************************************************* -// TEST(test_write_uint64_t) -// { -// std::array storage; -// std::array expected = { char(0x80), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), -// char(0xA5), char(0x5A), char(0x5A), char(0xA5), char(0x5A), char(0xA5), char(0xA5), char(0x5A), -// char(0x5A), char(0xA5), char(0xA5), char(0x5A), char(0xA5), char(0x5A), char(0x5A), char(0xA5), -// char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; -// -// CHECK(expected.size() == storage.size()); -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// CHECK(bit_stream.write(uint64_t(0x0000000000000001LL))); -// CHECK_EQUAL(sizeof(uint64_t) * 1, bit_stream.used_data().size()); -// CHECK(bit_stream.write(uint64_t(0x5AA5A55AA55A5AA5LL))); -// CHECK_EQUAL(sizeof(uint64_t) * 2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(uint64_t(0xA55A5AA55AA5A55ALL))); -// CHECK_EQUAL(sizeof(uint64_t) * 3, bit_stream.used_data().size()); -// CHECK(bit_stream.write(uint64_t(0xFFFFFFFFFFFFFFFFLL))); -// CHECK_EQUAL(sizeof(uint64_t) * 4, bit_stream.used_data().size()); -// -// // One too many. -// CHECK_THROW(bit_stream.write(uint64_t(0)), etl::bit_stream_overflow); -// -// CHECK_EQUAL(sizeof(uint64_t) * 4, bit_stream.data().size()); -// CHECK_EQUAL(sizeof(uint64_t) * 4, bit_stream.used_data().size()); -// -// for (size_t i = 0UL; i < storage.size(); ++i) -// { -// CHECK_EQUAL(int(expected[i]), int(storage[i])); -// } -// } -// -// //************************************************************************* -// TEST(test_write_int8_t_5bits) -// { -// std::array storage; -// std::array write_data = { int8_t(0x01), int8_t(0xF5), int8_t(0x05), int8_t(0xFF) }; // 1, -11, 10, -1 -// std::array expected = { char(0x85), char(0x69), char(0xF0), char(0x00) }; // 1, -11, 10, -1 -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// // Insert into the stream -// CHECK(bit_stream.write(write_data[0], 5)); -// CHECK_EQUAL(1, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[1], 5)); -// CHECK_EQUAL(2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[2], 5)); -// CHECK_EQUAL(2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[3], 5)); -// CHECK_EQUAL(3, bit_stream.used_data().size()); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// // 4th byte not used. -// } -// -// //************************************************************************* -// TEST(test_write_uint8_t_5bits) -// { -// std::array storage; -// std::array write_data = { uint8_t(0x01), uint8_t(0xF5), uint8_t(0x05), uint8_t(0xFF) }; // 1, -11, 10, -1 -// std::array expected = { char(0x85), char(0x69), char(0xF0), char(0x00) }; // 1, -11, 10, -1 -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// // Insert into the stream -// CHECK(bit_stream.write(write_data[0], 5)); -// CHECK_EQUAL(1, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[1], 5)); -// CHECK_EQUAL(2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[2], 5)); -// CHECK_EQUAL(2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[3], 5)); -// CHECK_EQUAL(3, bit_stream.used_data().size()); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// // 4th byte not used. -// } -// -// //************************************************************************* -// TEST(test_write_int16_t_10bits) -// { -// std::array storage; -// std::array write_data = { int16_t(0x0001), int16_t(0xA55A), int16_t(0x5AA5), int16_t(0xFFFF) }; -// std::array expected = { char(0x80), char(0x16), char(0xAA), char(0x57), -// char(0xFF), char(0x00), char(0x00), char(0x00) }; -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// // Insert into the stream -// CHECK(bit_stream.write(write_data[0], 10)); -// CHECK_EQUAL(2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[1], 10)); -// CHECK_EQUAL(3, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[2], 10)); -// CHECK_EQUAL(4, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[3], 10)); -// CHECK_EQUAL(5, bit_stream.used_data().size()); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// CHECK_EQUAL((int)expected[3], (int)storage[3]); -// CHECK_EQUAL((int)expected[4], (int)storage[4]); -// // 6th to 8th bytes not used. -// } -// -// //************************************************************************* -// TEST(test_write_uint16_t_10bits) -// { -// std::array storage; -// std::array write_data = { uint16_t(0x0001), uint16_t(0xA55A), uint16_t(0x5AA5), uint16_t(0xFFFF) }; -// std::array expected = { char(0x80), char(0x16), char(0xAA), char(0x57), -// char(0xFF), char(0x00), char(0x00), char(0x00) }; -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// // Insert into the stream -// CHECK(bit_stream.write(write_data[0], 10)); -// CHECK_EQUAL(2, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[1], 10)); -// CHECK_EQUAL(3, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[2], 10)); -// CHECK_EQUAL(4, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[3], 10)); -// CHECK_EQUAL(5, bit_stream.used_data().size()); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// CHECK_EQUAL((int)expected[3], (int)storage[3]); -// CHECK_EQUAL((int)expected[4], (int)storage[4]); -// // 6th to 8th bytes not used. -// } -// -// //************************************************************************* -// TEST(test_write_int32_t_22bits) -// { -// std::array storage; -// std::array write_data = { int32_t(0x00000001UL), int32_t(0xA55AA55AUL), int32_t(0x5AA55AA5UL), int32_t(0xFFFFFFFFUL) }; -// std::array expected = { char(0x80), char(0x00), char(0x01), char(0x6A), -// char(0x95), char(0x6A), char(0x55), char(0xAA), -// char(0x7F), char(0xFF), char(0xFF), char(0x00), -// char(0x00), char(0x00), char(0x00), char(0x00) }; -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// // Insert into the stream -// CHECK(bit_stream.write(write_data[0], 22)); -// CHECK_EQUAL(3, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[1], 22)); -// CHECK_EQUAL(6, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[2], 22)); -// CHECK_EQUAL(9, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[3], 22)); -// CHECK_EQUAL(11, bit_stream.used_data().size()); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// CHECK_EQUAL((int)expected[3], (int)storage[3]); -// CHECK_EQUAL((int)expected[4], (int)storage[4]); -// CHECK_EQUAL((int)expected[5], (int)storage[5]); -// CHECK_EQUAL((int)expected[6], (int)storage[6]); -// CHECK_EQUAL((int)expected[7], (int)storage[7]); -// CHECK_EQUAL((int)expected[8], (int)storage[8]); -// CHECK_EQUAL((int)expected[9], (int)storage[9]); -// CHECK_EQUAL((int)expected[10], (int)storage[10]); -// // 12th to 16th to bytes not used. -// } -// -// //************************************************************************* -// TEST(test_write_uint32_t_22bits) -// { -// std::array storage; -// std::array write_data = { uint32_t(0x00000001UL), uint32_t(0xA55AA55AUL), uint32_t(0x5AA55AA5UL), uint32_t(0xFFFFFFFFUL) }; -// std::array expected = { char(0x80), char(0x00), char(0x01), char(0x6A), -// char(0x95), char(0x6A), char(0x55), char(0xAA), -// char(0x7F), char(0xFF), char(0xFF), char(0x00), -// char(0x00), char(0x00), char(0x00), char(0x00) }; -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// // Insert into the stream -// CHECK(bit_stream.write(write_data[0], 22)); -// CHECK_EQUAL(3, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[1], 22)); -// CHECK_EQUAL(6, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[2], 22)); -// CHECK_EQUAL(9, bit_stream.used_data().size()); -// CHECK(bit_stream.write(write_data[3], 22)); -// CHECK_EQUAL(11, bit_stream.used_data().size()); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// CHECK_EQUAL((int)expected[3], (int)storage[3]); -// CHECK_EQUAL((int)expected[4], (int)storage[4]); -// CHECK_EQUAL((int)expected[5], (int)storage[5]); -// CHECK_EQUAL((int)expected[6], (int)storage[6]); -// CHECK_EQUAL((int)expected[7], (int)storage[7]); -// CHECK_EQUAL((int)expected[8], (int)storage[8]); -// CHECK_EQUAL((int)expected[9], (int)storage[9]); -// CHECK_EQUAL((int)expected[10], (int)storage[10]); -// // 12th to 16th to bytes not used. -// } -// -// //************************************************************************* -// TEST(test_write_int64_t_47bits) -// { -// std::array storage; -// std::array write_data = { int64_t(0x0000000000000001LL), int64_t(0xA55AA55AA55AA55ALL), int64_t(0x5AA55AA55AA55AA5LL), int64_t(0xFFFFFFFFFFFFFFFFLL) }; -// std::array expected = { char(0x80), char(0x00), char(0x00), char(0x00), -// char(0x00), char(0x00), char(0xB5), char(0x4A), -// char(0xB5), char(0x4A), char(0xB5), char(0x4A), -// char(0x95), char(0x6A), char(0x95), char(0x6A), -// char(0x95), char(0x6F), char(0xFF), char(0xFF), -// char(0xFF), char(0xFF), char(0xFF), char(0xF0) }; -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// // Insert into the stream -// bit_stream.write(write_data[0], 47); -// CHECK_EQUAL(6, bit_stream.used_data().size()); -// bit_stream.write(write_data[1], 47); -// CHECK_EQUAL(12, bit_stream.used_data().size()); -// bit_stream.write(write_data[2], 47); -// CHECK_EQUAL(18, bit_stream.used_data().size()); -// bit_stream.write(write_data[3], 47); -// CHECK_EQUAL(24, bit_stream.used_data().size()); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// CHECK_EQUAL((int)expected[3], (int)storage[3]); -// CHECK_EQUAL((int)expected[4], (int)storage[4]); -// CHECK_EQUAL((int)expected[5], (int)storage[5]); -// CHECK_EQUAL((int)expected[6], (int)storage[6]); -// CHECK_EQUAL((int)expected[7], (int)storage[7]); -// CHECK_EQUAL((int)expected[8], (int)storage[8]); -// CHECK_EQUAL((int)expected[9], (int)storage[9]); -// CHECK_EQUAL((int)expected[10], (int)storage[10]); -// CHECK_EQUAL((int)expected[11], (int)storage[11]); -// CHECK_EQUAL((int)expected[12], (int)storage[12]); -// CHECK_EQUAL((int)expected[13], (int)storage[13]); -// CHECK_EQUAL((int)expected[14], (int)storage[14]); -// CHECK_EQUAL((int)expected[15], (int)storage[15]); -// CHECK_EQUAL((int)expected[16], (int)storage[16]); -// CHECK_EQUAL((int)expected[17], (int)storage[17]); -// CHECK_EQUAL((int)expected[18], (int)storage[18]); -// CHECK_EQUAL((int)expected[19], (int)storage[19]); -// CHECK_EQUAL((int)expected[20], (int)storage[20]); -// CHECK_EQUAL((int)expected[21], (int)storage[21]); -// CHECK_EQUAL((int)expected[22], (int)storage[22]); -// CHECK_EQUAL((int)expected[23], (int)storage[23]); -// // 25th to 32nd bytes not used. -// } -// -// //************************************************************************* -// TEST(test_write_uint64_t_47bits) -// { -// std::array storage; -// std::array write_data = { uint64_t(0x0000000000000001LL), uint64_t(0xA55AA55AA55AA55ALL), uint64_t(0x5AA55AA55AA55AA5LL), uint64_t(0xFFFFFFFFFFFFFFFFLL) }; -// std::array expected = { char(0x80), char(0x00), char(0x00), char(0x00), -// char(0x00), char(0x00), char(0xB5), char(0x4A), -// char(0xB5), char(0x4A), char(0xB5), char(0x4A), -// char(0x95), char(0x6A), char(0x95), char(0x6A), -// char(0x95), char(0x6F), char(0xFF), char(0xFF), -// char(0xFF), char(0xFF), char(0xFF), char(0xF0) }; -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// // Insert into the stream -// bit_stream.write(write_data[0], 47); -// CHECK_EQUAL(6, bit_stream.used_data().size()); -// bit_stream.write(write_data[1], 47); -// CHECK_EQUAL(12, bit_stream.used_data().size()); -// bit_stream.write(write_data[2], 47); -// CHECK_EQUAL(18, bit_stream.used_data().size()); -// bit_stream.write(write_data[3], 47); -// CHECK_EQUAL(24, bit_stream.used_data().size()); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// CHECK_EQUAL((int)expected[3], (int)storage[3]); -// CHECK_EQUAL((int)expected[4], (int)storage[4]); -// CHECK_EQUAL((int)expected[5], (int)storage[5]); -// CHECK_EQUAL((int)expected[6], (int)storage[6]); -// CHECK_EQUAL((int)expected[7], (int)storage[7]); -// CHECK_EQUAL((int)expected[8], (int)storage[8]); -// CHECK_EQUAL((int)expected[9], (int)storage[9]); -// CHECK_EQUAL((int)expected[10], (int)storage[10]); -// CHECK_EQUAL((int)expected[11], (int)storage[11]); -// CHECK_EQUAL((int)expected[12], (int)storage[12]); -// CHECK_EQUAL((int)expected[13], (int)storage[13]); -// CHECK_EQUAL((int)expected[14], (int)storage[14]); -// CHECK_EQUAL((int)expected[15], (int)storage[15]); -// CHECK_EQUAL((int)expected[16], (int)storage[16]); -// CHECK_EQUAL((int)expected[17], (int)storage[17]); -// CHECK_EQUAL((int)expected[18], (int)storage[18]); -// CHECK_EQUAL((int)expected[19], (int)storage[19]); -// CHECK_EQUAL((int)expected[20], (int)storage[20]); -// CHECK_EQUAL((int)expected[21], (int)storage[21]); -// CHECK_EQUAL((int)expected[22], (int)storage[22]); -// CHECK_EQUAL((int)expected[23], (int)storage[23]); -// // 25th to 32nd bytes not used. -// } -// -// //************************************************************************* -// TEST(test_write_multiple_full_size) -// { -// char c1 = 90; // 0x5A -// char c2 = -91; // 0xA5 -// unsigned short s1 = 4660; // 0x1234 -// unsigned short s2 = 22136; // 0x5678 -// int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF -// int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 -// -// std::array storage; -// std::array expected = { char(0x5A), -// char(0x2C), char(0x48), -// char(0xF7), char(0xB3), char(0xD5), char(0x91), -// char(0x19), char(0x5D), char(0x3B), char(0x7F), -// char(0x1E), char(0x6A), -// char(0xA5) }; -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// // Insert into the stream. -// bit_stream.write(c1); -// CHECK_EQUAL(1, bit_stream.used_data().size()); -// bit_stream.write(s1); -// CHECK_EQUAL(3, bit_stream.used_data().size()); -// bit_stream.write(i1); -// CHECK_EQUAL(7, bit_stream.used_data().size()); -// bit_stream.write(i2); -// CHECK_EQUAL(11, bit_stream.used_data().size()); -// bit_stream.write(s2); -// CHECK_EQUAL(13, bit_stream.used_data().size()); -// bit_stream.write(c2); -// CHECK_EQUAL(14, bit_stream.used_data().size()); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// CHECK_EQUAL((int)expected[3], (int)storage[3]); -// CHECK_EQUAL((int)expected[4], (int)storage[4]); -// CHECK_EQUAL((int)expected[5], (int)storage[5]); -// CHECK_EQUAL((int)expected[6], (int)storage[6]); -// CHECK_EQUAL((int)expected[7], (int)storage[7]); -// CHECK_EQUAL((int)expected[8], (int)storage[8]); -// CHECK_EQUAL((int)expected[9], (int)storage[9]); -// CHECK_EQUAL((int)expected[10], (int)storage[10]); -// CHECK_EQUAL((int)expected[11], (int)storage[11]); -// CHECK_EQUAL((int)expected[12], (int)storage[12]); -// CHECK_EQUAL((int)expected[13], (int)storage[13]); -// } -// -// //************************************************************************* -// TEST(test_write_multiple_variable_size) -// { -// char c1 = 90; // 0x5A 6 bits -// char c2 = -91; // 0xA5 7 bits -// unsigned short s1 = 4660; // 0x1234 13 bits -// unsigned short s2 = 22136; // 0x5678 11 bits -// int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits -// int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits -// -// std::array storage; -// std::array expected = { char(0x58), char(0xB1), char(0x3E), char(0xF6), -// char(0x7A), char(0x86), char(0x57), char(0x4E), -// char(0xC3), char(0xCE), char(0x90) }; -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// // Insert into the stream. -// bit_stream.write(c1, 6); -// CHECK_EQUAL(1, bit_stream.used_data().size()); -// bit_stream.write(s1, 13); -// CHECK_EQUAL(3, bit_stream.used_data().size()); -// bit_stream.write(i1, 23); -// CHECK_EQUAL(6, bit_stream.used_data().size()); -// bit_stream.write(i2, 25); -// CHECK_EQUAL(9, bit_stream.used_data().size()); -// bit_stream.write(s2, 11); -// CHECK_EQUAL(10, bit_stream.used_data().size()); -// bit_stream.write(c2, 7); -// CHECK_EQUAL(11, bit_stream.used_data().size()); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// CHECK_EQUAL((int)expected[3], (int)storage[3]); -// CHECK_EQUAL((int)expected[4], (int)storage[4]); -// CHECK_EQUAL((int)expected[5], (int)storage[5]); -// CHECK_EQUAL((int)expected[6], (int)storage[6]); -// CHECK_EQUAL((int)expected[7], (int)storage[7]); -// CHECK_EQUAL((int)expected[8], (int)storage[8]); -// CHECK_EQUAL((int)expected[9], (int)storage[9]); -// CHECK_EQUAL((int)expected[10], (int)storage[10]); -// } -// -// //************************************************************************* -// TEST(test_write_multiple_variable_size_with_callback) -// { -// char c1 = 90; // 0x5A 6 bits -// char c2 = -91; // 0xA5 7 bits -// unsigned short s1 = 4660; // 0x1234 13 bits -// unsigned short s2 = 22136; // 0x5678 11 bits -// int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits -// int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits -// -// std::array storage; -// std::array expected = { char(0x58), char(0xB1), char(0x3E), char(0xF6), -// char(0x7A), char(0x86), char(0x57), char(0x4E), -// char(0xC3), char(0xCE), char(0x90) }; -// -// Accumulator accumulator; -// -// auto callback = etl::bit_stream_writer::callback_type::create(accumulator); -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little, callback); -// -// // Insert into the stream. -// bit_stream.write(c1, 6); -// bit_stream.write(s1, 13); -// bit_stream.write(i1, 23); -// bit_stream.write(i2, 25); -// bit_stream.write(s2, 11); -// bit_stream.write(c2, 7); -// bit_stream.flush(); -// -// CHECK_EQUAL(bit_stream.capacity_bytes(), bit_stream.available()); -// -// CHECK_EQUAL(11U, accumulator.GetData().size()); -// -// CHECK_EQUAL((int)expected[0], (int)accumulator.GetData()[0]); -// CHECK_EQUAL((int)expected[1], (int)accumulator.GetData()[1]); -// CHECK_EQUAL((int)expected[2], (int)accumulator.GetData()[2]); -// CHECK_EQUAL((int)expected[3], (int)accumulator.GetData()[3]); -// CHECK_EQUAL((int)expected[4], (int)accumulator.GetData()[4]); -// CHECK_EQUAL((int)expected[5], (int)accumulator.GetData()[5]); -// CHECK_EQUAL((int)expected[6], (int)accumulator.GetData()[6]); -// CHECK_EQUAL((int)expected[7], (int)accumulator.GetData()[7]); -// CHECK_EQUAL((int)expected[8], (int)accumulator.GetData()[8]); -// CHECK_EQUAL((int)expected[9], (int)accumulator.GetData()[9]); -// CHECK_EQUAL((int)expected[10], (int)accumulator.GetData()[10]); -// } -// -// //************************************************************************* -// TEST(test_write_object) -// { -// std::array storage; -// storage.fill(0); -// std::array expected{ char(0x74), char(0xDE), char(0xA2), char(0xCF), -// char(0x6A), char(0xFB), char(0xA3), char(0x5E), -// char(0x5D), char(0x30), char(0x9F), char(0x80) }; -// -// etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); -// -// Object object1 = { -1234, 123456789, 250 }; -// Object object2 = { 5678, -987654321, 126 }; -// -// CHECK(etl::write(bit_stream, object1)); -// CHECK(etl::write(bit_stream, object2)); -// -// CHECK_EQUAL((int)expected[0], (int)storage[0]); -// CHECK_EQUAL((int)expected[1], (int)storage[1]); -// CHECK_EQUAL((int)expected[2], (int)storage[2]); -// CHECK_EQUAL((int)expected[3], (int)storage[3]); -// CHECK_EQUAL((int)expected[4], (int)storage[4]); -// CHECK_EQUAL((int)expected[5], (int)storage[5]); -// CHECK_EQUAL((int)expected[6], (int)storage[6]); -// CHECK_EQUAL((int)expected[7], (int)storage[7]); -// CHECK_EQUAL((int)expected[8], (int)storage[8]); -// CHECK_EQUAL((int)expected[9], (int)storage[9]); -// CHECK_EQUAL((int)expected[10], (int)storage[10]); -// CHECK_EQUAL((int)expected[11], (int)storage[11]); -// } -// }; -//} +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2022 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 "unit_test_framework.h" + +#include "etl/bit_stream.h" + +#include +#include +#include + +namespace +{ + //*********************************** + struct Object + { + int16_t s; + int32_t i; + uint8_t c; + }; + +#include "etl/private/diagnostic_unused_function_push.h" + bool operator ==(const Object& lhs, const Object& rhs) + { + return (lhs.s == rhs.s) && + (lhs.i == rhs.i) && + (lhs.c == rhs.c); + } + + std::ostream& operator << (std::ostream& os, const Object& object) + { + os << object.s << "," << object.i << "," << (int)object.c; + return os; + } +#include "etl/private/diagnostic_pop.h" +} + +namespace etl +{ + //*********************************** + bool write(etl::bit_stream_writer& stream, const Object& object) + { + bool success = true; + + if (!stream.write(object.s, 14)) + { + success = false; + } + + if (!stream.write(object.i, 23)) + { + success = false; + } + + if (!stream.write(object.c)) + { + success = false; + } + + return success; + } +} + +namespace +{ + class Accumulator + { + public: + + void Add(etl::bit_stream_writer::callback_parameter_type s) + { + data.insert(data.end(), s.begin(), s.end()); + } + + void Clear() + { + data.clear(); + } + + const std::vector& GetData() const + { + return data; + } + + private: + + std::vector data; + }; + + SUITE(test_bit_stream_little_endian) + { + //************************************************************************* + TEST(test_bit_stream_writer_construction) + { + std::array storage; + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK_EQUAL(storage.size(), bit_stream.available(CHAR_BIT)); + CHECK_EQUAL(storage.size(), bit_stream.available()); + CHECK_EQUAL(storage.size(), bit_stream.available()); + + CHECK_EQUAL(storage.size() * CHAR_BIT, bit_stream.available_bits()); + + CHECK_EQUAL(0U, bit_stream.size_bits()); + CHECK_EQUAL(0U, bit_stream.size_bytes()); + + CHECK_EQUAL(storage.size(), bit_stream.data().size()); + CHECK_EQUAL(0U, bit_stream.used_data().size()); + } + + //************************************************************************* + TEST(test_write_bool) + { + unsigned char storage = 0; + unsigned char expected = 0x5AU; + + etl::bit_stream_writer bit_stream(&storage, 1U, etl::endian::little); + + CHECK(bit_stream.write(false)); + CHECK_EQUAL(1U, bit_stream.used_data().size()); + CHECK(bit_stream.write(true)); + CHECK_EQUAL(1U, bit_stream.used_data().size()); + CHECK(bit_stream.write(false)); + CHECK_EQUAL(1U, bit_stream.used_data().size()); + CHECK(bit_stream.write(true)); + CHECK_EQUAL(1U, bit_stream.used_data().size()); + CHECK(bit_stream.write(true)); + CHECK_EQUAL(1U, bit_stream.used_data().size()); + CHECK(bit_stream.write(false)); + CHECK_EQUAL(1U, bit_stream.used_data().size()); + CHECK(bit_stream.write(true)); + CHECK_EQUAL(1U, bit_stream.used_data().size()); + CHECK(bit_stream.write(false)); + CHECK_EQUAL(1U, bit_stream.used_data().size()); + + // One too many. + CHECK_FALSE(bit_stream.write(true)); + + CHECK_EQUAL(1U, bit_stream.data().size()); + CHECK_EQUAL(1U, bit_stream.used_data().size()); + + CHECK_EQUAL(int(expected), int(storage)); + } + + //************************************************************************* + TEST(test_write_int8_t) + { + std::array storage; + + std::array expected; + std::iota(expected.begin(), expected.end(), 0); + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + for (size_t i = 0UL; i < 256UL; ++i) + { + CHECK(bit_stream.write(int8_t(i))); + CHECK_EQUAL(i + 1U, bit_stream.used_data().size()); + } + + // One too many. + CHECK_FALSE(bit_stream.write(int8_t(0))); + + CHECK_EQUAL(256U, bit_stream.data().size()); + CHECK_EQUAL(256U, bit_stream.used_data().size()); + + for (size_t i = 0UL; i < storage.size(); ++i) + { + CHECK_EQUAL(int(etl::reverse_bits(expected[i])), int(storage[i])); + } + } + + //************************************************************************* + TEST(test_write_uint8_t) + { + std::array storage; + + std::array expected; + std::iota(expected.begin(), expected.end(), 0); + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + for (size_t i = 0UL; i < 256UL; ++i) + { + CHECK(bit_stream.write(uint8_t(i))); + CHECK_EQUAL(i + 1U, bit_stream.used_data().size()); + } + + // One too many. + CHECK_FALSE(bit_stream.write(int8_t(0))); + + CHECK_EQUAL(256U, bit_stream.data().size()); + CHECK_EQUAL(256U, bit_stream.used_data().size()); + + for (size_t i = 0UL; i < storage.size(); ++i) + { + CHECK_EQUAL(int(etl::reverse_bits(expected[i])), int(storage[i])); + } + } + + //************************************************************************* + TEST(test_write_int16_t) + { + std::array storage; + std::array expected = { char(0x80), char(0x00), + char(0xA5), char(0x5A), + char(0x5A), char(0xA5), + char(0xFF), char(0xFF) }; + + CHECK(expected.size() == storage.size()); + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK(bit_stream.write(int16_t(0x0001))); + CHECK_EQUAL(sizeof(int16_t) * 1, bit_stream.used_data().size()); + CHECK(bit_stream.write(int16_t(0x5AA5))); + CHECK_EQUAL(sizeof(int16_t) * 2, bit_stream.used_data().size()); + CHECK(bit_stream.write(int16_t(0xA55A))); + CHECK_EQUAL(sizeof(int16_t) * 3, bit_stream.used_data().size()); + CHECK(bit_stream.write(int16_t(0xFFFF))); + CHECK_EQUAL(sizeof(int16_t) * 4, bit_stream.used_data().size()); + + // One too many. + CHECK_FALSE(bit_stream.write(int16_t(0))); + + CHECK_EQUAL(sizeof(int16_t) * 4, bit_stream.data().size()); + CHECK_EQUAL(sizeof(int16_t) * 4, bit_stream.used_data().size()); + + for (size_t i = 0UL; i < storage.size(); ++i) + { + CHECK_EQUAL(int(expected[i]), int(storage[i])); + } + } + + //************************************************************************* + TEST(test_write_uint16_t) + { + std::array storage; + std::array expected = { char(0x80), char(0x00), + char(0xA5), char(0x5A), + char(0x5A), char(0xA5), + char(0xFF), char(0xFF) }; + + CHECK(expected.size() == storage.size()); + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK(bit_stream.write(uint16_t(0x0001))); + CHECK_EQUAL(sizeof(uint16_t) * 1, bit_stream.used_data().size()); + CHECK(bit_stream.write(uint16_t(0x5AA5))); + CHECK_EQUAL(sizeof(uint16_t) * 2, bit_stream.used_data().size()); + CHECK(bit_stream.write(uint16_t(0xA55A))); + CHECK_EQUAL(sizeof(uint16_t) * 3, bit_stream.used_data().size()); + CHECK(bit_stream.write(uint16_t(0xFFFF))); + CHECK_EQUAL(sizeof(uint16_t) * 4, bit_stream.used_data().size()); + + // One too many. + CHECK_FALSE(bit_stream.write(uint16_t(0))); + + CHECK_EQUAL(sizeof(uint16_t) * 4, bit_stream.data().size()); + CHECK_EQUAL(sizeof(uint16_t) * 4, bit_stream.used_data().size()); + + for (size_t i = 0UL; i < storage.size(); ++i) + { + CHECK_EQUAL(int(expected[i]), int(storage[i])); + } + } + + //************************************************************************* + TEST(test_write_int32_t) + { + std::array storage; + std::array expected = { char(0x80), char(0x00), char(0x00), char(0x00), + char(0x5A), char(0xA5), char(0xA5), char(0x5A), + char(0xA5), char(0x5A), char(0x5A), char(0xA5), + char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; + + CHECK(expected.size() == storage.size()); + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK(bit_stream.write(int32_t(0x00000001))); + CHECK_EQUAL(sizeof(int32_t) * 1, bit_stream.used_data().size()); + CHECK(bit_stream.write(int32_t(0x5AA5A55A))); + CHECK_EQUAL(sizeof(int32_t) * 2, bit_stream.used_data().size()); + CHECK(bit_stream.write(int32_t(0xA55A5AA5))); + CHECK_EQUAL(sizeof(int32_t) * 3, bit_stream.used_data().size()); + CHECK(bit_stream.write(int32_t(0xFFFFFFFF))); + CHECK_EQUAL(sizeof(int32_t) * 4, bit_stream.used_data().size()); + + // One too many. + CHECK_FALSE(bit_stream.write(int32_t(0))); + + CHECK_EQUAL(sizeof(int32_t) * 4, bit_stream.data().size()); + CHECK_EQUAL(sizeof(int32_t) * 4, bit_stream.used_data().size()); + + for (size_t i = 0UL; i < storage.size(); ++i) + { + CHECK_EQUAL(int(expected[i]), int(storage[i])); + } + } + + //************************************************************************* + TEST(test_write_uint32_t) + { + std::array storage; + std::array expected = { char(0x80), char(0x00), char(0x00), char(0x00), + char(0x5A), char(0xA5), char(0xA5), char(0x5A), + char(0xA5), char(0x5A), char(0x5A), char(0xA5), + char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; + + CHECK(expected.size() == storage.size()); + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK(bit_stream.write(uint32_t(0x00000001))); + CHECK_EQUAL(sizeof(uint32_t) * 1, bit_stream.used_data().size()); + CHECK(bit_stream.write(uint32_t(0x5AA5A55A))); + CHECK_EQUAL(sizeof(uint32_t) * 2, bit_stream.used_data().size()); + CHECK(bit_stream.write(uint32_t(0xA55A5AA5))); + CHECK_EQUAL(sizeof(uint32_t) * 3, bit_stream.used_data().size()); + CHECK(bit_stream.write(uint32_t(0xFFFFFFFF))); + CHECK_EQUAL(sizeof(uint32_t) * 4, bit_stream.used_data().size()); + + // One too many. + CHECK_FALSE(bit_stream.write(uint32_t(0))); + + CHECK_EQUAL(sizeof(uint32_t) * 4, bit_stream.data().size()); + CHECK_EQUAL(sizeof(uint32_t) * 4, bit_stream.used_data().size()); + + for (size_t i = 0UL; i < storage.size(); ++i) + { + CHECK_EQUAL(int(expected[i]), int(storage[i])); + } + } + + //************************************************************************* + TEST(test_write_int64_t) + { + std::array storage; + std::array expected = { char(0x80), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), + char(0xA5), char(0x5A), char(0x5A), char(0xA5), char(0x5A), char(0xA5), char(0xA5), char(0x5A), + char(0x5A), char(0xA5), char(0xA5), char(0x5A), char(0xA5), char(0x5A), char(0x5A), char(0xA5), + char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; + + CHECK(expected.size() == storage.size()); + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK(bit_stream.write(int64_t(0x0000000000000001LL))); + CHECK_EQUAL(sizeof(int64_t) * 1, bit_stream.used_data().size()); + CHECK(bit_stream.write(int64_t(0x5AA5A55AA55A5AA5LL))); + CHECK_EQUAL(sizeof(int64_t) * 2, bit_stream.used_data().size()); + CHECK(bit_stream.write(int64_t(0xA55A5AA55AA5A55ALL))); + CHECK_EQUAL(sizeof(int64_t) * 3, bit_stream.used_data().size()); + CHECK(bit_stream.write(int64_t(0xFFFFFFFFFFFFFFFFLL))); + CHECK_EQUAL(sizeof(int64_t) * 4, bit_stream.used_data().size()); + + // One too many. + CHECK_FALSE(bit_stream.write(int64_t(0))); + + CHECK_EQUAL(sizeof(int64_t) * 4, bit_stream.data().size()); + CHECK_EQUAL(sizeof(int64_t) * 4, bit_stream.used_data().size()); + + for (size_t i = 0UL; i < storage.size(); ++i) + { + CHECK_EQUAL(int(expected[i]), int(storage[i])); + } + } + + //************************************************************************* + TEST(test_write_uint64_t) + { + std::array storage; + std::array expected = { char(0x80), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), char(0x00), + char(0xA5), char(0x5A), char(0x5A), char(0xA5), char(0x5A), char(0xA5), char(0xA5), char(0x5A), + char(0x5A), char(0xA5), char(0xA5), char(0x5A), char(0xA5), char(0x5A), char(0x5A), char(0xA5), + char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF), char(0xFF) }; + + CHECK(expected.size() == storage.size()); + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + CHECK(bit_stream.write(uint64_t(0x0000000000000001LL))); + CHECK_EQUAL(sizeof(uint64_t) * 1, bit_stream.used_data().size()); + CHECK(bit_stream.write(uint64_t(0x5AA5A55AA55A5AA5LL))); + CHECK_EQUAL(sizeof(uint64_t) * 2, bit_stream.used_data().size()); + CHECK(bit_stream.write(uint64_t(0xA55A5AA55AA5A55ALL))); + CHECK_EQUAL(sizeof(uint64_t) * 3, bit_stream.used_data().size()); + CHECK(bit_stream.write(uint64_t(0xFFFFFFFFFFFFFFFFLL))); + CHECK_EQUAL(sizeof(uint64_t) * 4, bit_stream.used_data().size()); + + // One too many. + CHECK_FALSE(bit_stream.write(uint64_t(0))); + + CHECK_EQUAL(sizeof(uint64_t) * 4, bit_stream.data().size()); + CHECK_EQUAL(sizeof(uint64_t) * 4, bit_stream.used_data().size()); + + for (size_t i = 0UL; i < storage.size(); ++i) + { + CHECK_EQUAL(int(expected[i]), int(storage[i])); + } + } + + //************************************************************************* + TEST(test_write_int8_t_5bits) + { + std::array storage; + std::array write_data = { int8_t(0x01), int8_t(0xF5), int8_t(0x05), int8_t(0xFF) }; // 1, -11, 10, -1 + std::array expected = { char(0x85), char(0x69), char(0xF0), char(0x00) }; // 1, -11, 10, -1 + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + // Insert into the stream + CHECK(bit_stream.write(write_data[0], 5)); + CHECK_EQUAL(1, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[1], 5)); + CHECK_EQUAL(2, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[2], 5)); + CHECK_EQUAL(2, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[3], 5)); + CHECK_EQUAL(3, bit_stream.used_data().size()); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + // 4th byte not used. + } + + //************************************************************************* + TEST(test_write_uint8_t_5bits) + { + std::array storage; + std::array write_data = { uint8_t(0x01), uint8_t(0xF5), uint8_t(0x05), uint8_t(0xFF) }; // 1, -11, 10, -1 + std::array expected = { char(0x85), char(0x69), char(0xF0), char(0x00) }; // 1, -11, 10, -1 + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + // Insert into the stream + CHECK(bit_stream.write(write_data[0], 5)); + CHECK_EQUAL(1, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[1], 5)); + CHECK_EQUAL(2, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[2], 5)); + CHECK_EQUAL(2, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[3], 5)); + CHECK_EQUAL(3, bit_stream.used_data().size()); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + // 4th byte not used. + } + + //************************************************************************* + TEST(test_write_int16_t_10bits) + { + std::array storage; + std::array write_data = { int16_t(0x0001), int16_t(0xA55A), int16_t(0x5AA5), int16_t(0xFFFF) }; + std::array expected = { char(0x80), char(0x16), char(0xAA), char(0x57), + char(0xFF), char(0x00), char(0x00), char(0x00) }; + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + // Insert into the stream + CHECK(bit_stream.write(write_data[0], 10)); + CHECK_EQUAL(2, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[1], 10)); + CHECK_EQUAL(3, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[2], 10)); + CHECK_EQUAL(4, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[3], 10)); + CHECK_EQUAL(5, bit_stream.used_data().size()); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + CHECK_EQUAL((int)expected[3], (int)storage[3]); + CHECK_EQUAL((int)expected[4], (int)storage[4]); + // 6th to 8th bytes not used. + } + + //************************************************************************* + TEST(test_write_uint16_t_10bits) + { + std::array storage; + std::array write_data = { uint16_t(0x0001), uint16_t(0xA55A), uint16_t(0x5AA5), uint16_t(0xFFFF) }; + std::array expected = { char(0x80), char(0x16), char(0xAA), char(0x57), + char(0xFF), char(0x00), char(0x00), char(0x00) }; + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + // Insert into the stream + CHECK(bit_stream.write(write_data[0], 10)); + CHECK_EQUAL(2, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[1], 10)); + CHECK_EQUAL(3, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[2], 10)); + CHECK_EQUAL(4, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[3], 10)); + CHECK_EQUAL(5, bit_stream.used_data().size()); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + CHECK_EQUAL((int)expected[3], (int)storage[3]); + CHECK_EQUAL((int)expected[4], (int)storage[4]); + // 6th to 8th bytes not used. + } + + //************************************************************************* + TEST(test_write_int32_t_22bits) + { + std::array storage; + std::array write_data = { int32_t(0x00000001UL), int32_t(0xA55AA55AUL), int32_t(0x5AA55AA5UL), int32_t(0xFFFFFFFFUL) }; + std::array expected = { char(0x80), char(0x00), char(0x01), char(0x6A), + char(0x95), char(0x6A), char(0x55), char(0xAA), + char(0x7F), char(0xFF), char(0xFF), char(0x00), + char(0x00), char(0x00), char(0x00), char(0x00) }; + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + // Insert into the stream + CHECK(bit_stream.write(write_data[0], 22)); + CHECK_EQUAL(3, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[1], 22)); + CHECK_EQUAL(6, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[2], 22)); + CHECK_EQUAL(9, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[3], 22)); + CHECK_EQUAL(11, bit_stream.used_data().size()); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + CHECK_EQUAL((int)expected[3], (int)storage[3]); + CHECK_EQUAL((int)expected[4], (int)storage[4]); + CHECK_EQUAL((int)expected[5], (int)storage[5]); + CHECK_EQUAL((int)expected[6], (int)storage[6]); + CHECK_EQUAL((int)expected[7], (int)storage[7]); + CHECK_EQUAL((int)expected[8], (int)storage[8]); + CHECK_EQUAL((int)expected[9], (int)storage[9]); + CHECK_EQUAL((int)expected[10], (int)storage[10]); + // 12th to 16th to bytes not used. + } + + //************************************************************************* + TEST(test_write_uint32_t_22bits) + { + std::array storage; + std::array write_data = { uint32_t(0x00000001UL), uint32_t(0xA55AA55AUL), uint32_t(0x5AA55AA5UL), uint32_t(0xFFFFFFFFUL) }; + std::array expected = { char(0x80), char(0x00), char(0x01), char(0x6A), + char(0x95), char(0x6A), char(0x55), char(0xAA), + char(0x7F), char(0xFF), char(0xFF), char(0x00), + char(0x00), char(0x00), char(0x00), char(0x00) }; + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + // Insert into the stream + CHECK(bit_stream.write(write_data[0], 22)); + CHECK_EQUAL(3, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[1], 22)); + CHECK_EQUAL(6, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[2], 22)); + CHECK_EQUAL(9, bit_stream.used_data().size()); + CHECK(bit_stream.write(write_data[3], 22)); + CHECK_EQUAL(11, bit_stream.used_data().size()); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + CHECK_EQUAL((int)expected[3], (int)storage[3]); + CHECK_EQUAL((int)expected[4], (int)storage[4]); + CHECK_EQUAL((int)expected[5], (int)storage[5]); + CHECK_EQUAL((int)expected[6], (int)storage[6]); + CHECK_EQUAL((int)expected[7], (int)storage[7]); + CHECK_EQUAL((int)expected[8], (int)storage[8]); + CHECK_EQUAL((int)expected[9], (int)storage[9]); + CHECK_EQUAL((int)expected[10], (int)storage[10]); + // 12th to 16th to bytes not used. + } + + //************************************************************************* + TEST(test_write_int64_t_47bits) + { + std::array storage; + std::array write_data = { int64_t(0x0000000000000001LL), int64_t(0xA55AA55AA55AA55ALL), int64_t(0x5AA55AA55AA55AA5LL), int64_t(0xFFFFFFFFFFFFFFFFLL) }; + std::array expected = { char(0x80), char(0x00), char(0x00), char(0x00), + char(0x00), char(0x00), char(0xB5), char(0x4A), + char(0xB5), char(0x4A), char(0xB5), char(0x4A), + char(0x95), char(0x6A), char(0x95), char(0x6A), + char(0x95), char(0x6F), char(0xFF), char(0xFF), + char(0xFF), char(0xFF), char(0xFF), char(0xF0) }; + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + // Insert into the stream + bit_stream.write(write_data[0], 47); + CHECK_EQUAL(6, bit_stream.used_data().size()); + bit_stream.write(write_data[1], 47); + CHECK_EQUAL(12, bit_stream.used_data().size()); + bit_stream.write(write_data[2], 47); + CHECK_EQUAL(18, bit_stream.used_data().size()); + bit_stream.write(write_data[3], 47); + CHECK_EQUAL(24, bit_stream.used_data().size()); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + CHECK_EQUAL((int)expected[3], (int)storage[3]); + CHECK_EQUAL((int)expected[4], (int)storage[4]); + CHECK_EQUAL((int)expected[5], (int)storage[5]); + CHECK_EQUAL((int)expected[6], (int)storage[6]); + CHECK_EQUAL((int)expected[7], (int)storage[7]); + CHECK_EQUAL((int)expected[8], (int)storage[8]); + CHECK_EQUAL((int)expected[9], (int)storage[9]); + CHECK_EQUAL((int)expected[10], (int)storage[10]); + CHECK_EQUAL((int)expected[11], (int)storage[11]); + CHECK_EQUAL((int)expected[12], (int)storage[12]); + CHECK_EQUAL((int)expected[13], (int)storage[13]); + CHECK_EQUAL((int)expected[14], (int)storage[14]); + CHECK_EQUAL((int)expected[15], (int)storage[15]); + CHECK_EQUAL((int)expected[16], (int)storage[16]); + CHECK_EQUAL((int)expected[17], (int)storage[17]); + CHECK_EQUAL((int)expected[18], (int)storage[18]); + CHECK_EQUAL((int)expected[19], (int)storage[19]); + CHECK_EQUAL((int)expected[20], (int)storage[20]); + CHECK_EQUAL((int)expected[21], (int)storage[21]); + CHECK_EQUAL((int)expected[22], (int)storage[22]); + CHECK_EQUAL((int)expected[23], (int)storage[23]); + // 25th to 32nd bytes not used. + } + + //************************************************************************* + TEST(test_write_uint64_t_47bits) + { + std::array storage; + std::array write_data = { uint64_t(0x0000000000000001LL), uint64_t(0xA55AA55AA55AA55ALL), uint64_t(0x5AA55AA55AA55AA5LL), uint64_t(0xFFFFFFFFFFFFFFFFLL) }; + std::array expected = { char(0x80), char(0x00), char(0x00), char(0x00), + char(0x00), char(0x00), char(0xB5), char(0x4A), + char(0xB5), char(0x4A), char(0xB5), char(0x4A), + char(0x95), char(0x6A), char(0x95), char(0x6A), + char(0x95), char(0x6F), char(0xFF), char(0xFF), + char(0xFF), char(0xFF), char(0xFF), char(0xF0) }; + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + // Insert into the stream + bit_stream.write(write_data[0], 47); + CHECK_EQUAL(6, bit_stream.used_data().size()); + bit_stream.write(write_data[1], 47); + CHECK_EQUAL(12, bit_stream.used_data().size()); + bit_stream.write(write_data[2], 47); + CHECK_EQUAL(18, bit_stream.used_data().size()); + bit_stream.write(write_data[3], 47); + CHECK_EQUAL(24, bit_stream.used_data().size()); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + CHECK_EQUAL((int)expected[3], (int)storage[3]); + CHECK_EQUAL((int)expected[4], (int)storage[4]); + CHECK_EQUAL((int)expected[5], (int)storage[5]); + CHECK_EQUAL((int)expected[6], (int)storage[6]); + CHECK_EQUAL((int)expected[7], (int)storage[7]); + CHECK_EQUAL((int)expected[8], (int)storage[8]); + CHECK_EQUAL((int)expected[9], (int)storage[9]); + CHECK_EQUAL((int)expected[10], (int)storage[10]); + CHECK_EQUAL((int)expected[11], (int)storage[11]); + CHECK_EQUAL((int)expected[12], (int)storage[12]); + CHECK_EQUAL((int)expected[13], (int)storage[13]); + CHECK_EQUAL((int)expected[14], (int)storage[14]); + CHECK_EQUAL((int)expected[15], (int)storage[15]); + CHECK_EQUAL((int)expected[16], (int)storage[16]); + CHECK_EQUAL((int)expected[17], (int)storage[17]); + CHECK_EQUAL((int)expected[18], (int)storage[18]); + CHECK_EQUAL((int)expected[19], (int)storage[19]); + CHECK_EQUAL((int)expected[20], (int)storage[20]); + CHECK_EQUAL((int)expected[21], (int)storage[21]); + CHECK_EQUAL((int)expected[22], (int)storage[22]); + CHECK_EQUAL((int)expected[23], (int)storage[23]); + // 25th to 32nd bytes not used. + } + + //************************************************************************* + TEST(test_write_multiple_full_size) + { + char c1 = 90; // 0x5A + char c2 = -91; // 0xA5 + unsigned short s1 = 4660; // 0x1234 + unsigned short s2 = 22136; // 0x5678 + int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF + int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 + + std::array storage; + std::array expected = { char(0x5A), + char(0x2C), char(0x48), + char(0xF7), char(0xB3), char(0xD5), char(0x91), + char(0x19), char(0x5D), char(0x3B), char(0x7F), + char(0x1E), char(0x6A), + char(0xA5) }; + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + // Insert into the stream. + bit_stream.write(c1); + CHECK_EQUAL(1, bit_stream.used_data().size()); + bit_stream.write(s1); + CHECK_EQUAL(3, bit_stream.used_data().size()); + bit_stream.write(i1); + CHECK_EQUAL(7, bit_stream.used_data().size()); + bit_stream.write(i2); + CHECK_EQUAL(11, bit_stream.used_data().size()); + bit_stream.write(s2); + CHECK_EQUAL(13, bit_stream.used_data().size()); + bit_stream.write(c2); + CHECK_EQUAL(14, bit_stream.used_data().size()); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + CHECK_EQUAL((int)expected[3], (int)storage[3]); + CHECK_EQUAL((int)expected[4], (int)storage[4]); + CHECK_EQUAL((int)expected[5], (int)storage[5]); + CHECK_EQUAL((int)expected[6], (int)storage[6]); + CHECK_EQUAL((int)expected[7], (int)storage[7]); + CHECK_EQUAL((int)expected[8], (int)storage[8]); + CHECK_EQUAL((int)expected[9], (int)storage[9]); + CHECK_EQUAL((int)expected[10], (int)storage[10]); + CHECK_EQUAL((int)expected[11], (int)storage[11]); + CHECK_EQUAL((int)expected[12], (int)storage[12]); + CHECK_EQUAL((int)expected[13], (int)storage[13]); + } + + //************************************************************************* + TEST(test_write_multiple_variable_size) + { + char c1 = 90; // 0x5A 6 bits + char c2 = -91; // 0xA5 7 bits + unsigned short s1 = 4660; // 0x1234 13 bits + unsigned short s2 = 22136; // 0x5678 11 bits + int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits + int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits + + std::array storage; + std::array expected = { char(0x58), char(0xB1), char(0x3E), char(0xF6), + char(0x7A), char(0x86), char(0x57), char(0x4E), + char(0xC3), char(0xCE), char(0x90) }; + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + // Insert into the stream. + bit_stream.write(c1, 6); + CHECK_EQUAL(1, bit_stream.used_data().size()); + bit_stream.write(s1, 13); + CHECK_EQUAL(3, bit_stream.used_data().size()); + bit_stream.write(i1, 23); + CHECK_EQUAL(6, bit_stream.used_data().size()); + bit_stream.write(i2, 25); + CHECK_EQUAL(9, bit_stream.used_data().size()); + bit_stream.write(s2, 11); + CHECK_EQUAL(10, bit_stream.used_data().size()); + bit_stream.write(c2, 7); + CHECK_EQUAL(11, bit_stream.used_data().size()); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + CHECK_EQUAL((int)expected[3], (int)storage[3]); + CHECK_EQUAL((int)expected[4], (int)storage[4]); + CHECK_EQUAL((int)expected[5], (int)storage[5]); + CHECK_EQUAL((int)expected[6], (int)storage[6]); + CHECK_EQUAL((int)expected[7], (int)storage[7]); + CHECK_EQUAL((int)expected[8], (int)storage[8]); + CHECK_EQUAL((int)expected[9], (int)storage[9]); + CHECK_EQUAL((int)expected[10], (int)storage[10]); + } + + //************************************************************************* + TEST(test_write_multiple_variable_size_with_callback) + { + char c1 = 90; // 0x5A 6 bits + char c2 = -91; // 0xA5 7 bits + unsigned short s1 = 4660; // 0x1234 13 bits + unsigned short s2 = 22136; // 0x5678 11 bits + int32_t i1 = 0x89ABCDEF; // 0x89ABCDEF 23 bits + int32_t i2 = 0xFEDCBA98; // 0xFEDCBA98 25 bits + + std::array storage; + std::array expected = { char(0x58), char(0xB1), char(0x3E), char(0xF6), + char(0x7A), char(0x86), char(0x57), char(0x4E), + char(0xC3), char(0xCE), char(0x90) }; + + Accumulator accumulator; + + auto callback = etl::bit_stream_writer::callback_type::create(accumulator); + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little, callback); + + // Insert into the stream. + bit_stream.write(c1, 6); + bit_stream.write(s1, 13); + bit_stream.write(i1, 23); + bit_stream.write(i2, 25); + bit_stream.write(s2, 11); + bit_stream.write(c2, 7); + bit_stream.flush(); + + CHECK_EQUAL(bit_stream.capacity_bytes(), bit_stream.available()); + + CHECK_EQUAL(11U, accumulator.GetData().size()); + + CHECK_EQUAL((int)expected[0], (int)accumulator.GetData()[0]); + CHECK_EQUAL((int)expected[1], (int)accumulator.GetData()[1]); + CHECK_EQUAL((int)expected[2], (int)accumulator.GetData()[2]); + CHECK_EQUAL((int)expected[3], (int)accumulator.GetData()[3]); + CHECK_EQUAL((int)expected[4], (int)accumulator.GetData()[4]); + CHECK_EQUAL((int)expected[5], (int)accumulator.GetData()[5]); + CHECK_EQUAL((int)expected[6], (int)accumulator.GetData()[6]); + CHECK_EQUAL((int)expected[7], (int)accumulator.GetData()[7]); + CHECK_EQUAL((int)expected[8], (int)accumulator.GetData()[8]); + CHECK_EQUAL((int)expected[9], (int)accumulator.GetData()[9]); + CHECK_EQUAL((int)expected[10], (int)accumulator.GetData()[10]); + } + + //************************************************************************* + TEST(test_write_object) + { + std::array storage; + storage.fill(0); + std::array expected{ char(0x74), char(0xDE), char(0xA2), char(0xCF), + char(0x6A), char(0xFB), char(0xA3), char(0x5E), + char(0x5D), char(0x30), char(0x9F), char(0x80) }; + + etl::bit_stream_writer bit_stream(storage.data(), storage.size(), etl::endian::little); + + Object object1 = { -1234, 123456789, 250 }; + Object object2 = { 5678, -987654321, 126 }; + + CHECK(etl::write(bit_stream, object1)); + CHECK(etl::write(bit_stream, object2)); + + CHECK_EQUAL((int)expected[0], (int)storage[0]); + CHECK_EQUAL((int)expected[1], (int)storage[1]); + CHECK_EQUAL((int)expected[2], (int)storage[2]); + CHECK_EQUAL((int)expected[3], (int)storage[3]); + CHECK_EQUAL((int)expected[4], (int)storage[4]); + CHECK_EQUAL((int)expected[5], (int)storage[5]); + CHECK_EQUAL((int)expected[6], (int)storage[6]); + CHECK_EQUAL((int)expected[7], (int)storage[7]); + CHECK_EQUAL((int)expected[8], (int)storage[8]); + CHECK_EQUAL((int)expected[9], (int)storage[9]); + CHECK_EQUAL((int)expected[10], (int)storage[10]); + CHECK_EQUAL((int)expected[11], (int)storage[11]); + } + }; +} diff --git a/test/test_byte_stream.cpp b/test/test_byte_stream.cpp index 2587719ce..10a3fceb7 100644 --- a/test/test_byte_stream.cpp +++ b/test/test_byte_stream.cpp @@ -31,6 +31,7 @@ SOFTWARE. #include "etl/byte_stream.h" #include "etl/optional.h" #include "etl/span.h" +#include "etl/array.h" #include #include diff --git a/test/test_callback_timer.cpp b/test/test_callback_timer.cpp index d2ba623b8..1057fc087 100644 --- a/test/test_callback_timer.cpp +++ b/test/test_callback_timer.cpp @@ -114,16 +114,16 @@ namespace { etl::callback_timer<2> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::Single_Shot); CHECK(id1 != etl::timer::id::NO_TIMER); CHECK(id2 != etl::timer::id::NO_TIMER); CHECK(id3 == etl::timer::id::NO_TIMER); timer_controller.clear(); - id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::SINGLE_SHOT); + id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::Single_Shot); CHECK(id3 != etl::timer::id::NO_TIMER); } @@ -132,9 +132,9 @@ namespace { etl::callback_timer<4> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::Single_Shot); test.tick_list.clear(); free_tick_list1.clear(); @@ -174,7 +174,7 @@ namespace { etl::callback_timer<1> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Single_Shot); test.tick_list.clear(); timer_controller.start(id1); @@ -220,9 +220,9 @@ namespace { etl::callback_timer<3> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -262,9 +262,9 @@ namespace { etl::callback_timer<3> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -308,9 +308,9 @@ namespace { etl::callback_timer<3> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -361,9 +361,9 @@ namespace { etl::callback_timer<3> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback2, 100, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(member_callback, 10, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(member_callback, 22, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback2, 100, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(member_callback, 10, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(member_callback, 22, etl::timer::mode::Single_Shot); (void)id2; (void)id3; @@ -398,9 +398,9 @@ namespace { etl::callback_timer<3> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback2, 100, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(member_callback, 10, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(member_callback, 22, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback2, 100, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(member_callback, 10, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(member_callback, 22, etl::timer::mode::Single_Shot); (void)id2; (void)id3; @@ -436,8 +436,8 @@ namespace etl::callback_timer<3> timer_controller; etl::timer::id::type id1; - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -458,7 +458,7 @@ namespace { timer_controller.unregister_timer(id2); - id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); + id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); timer_controller.start(id1); } @@ -484,9 +484,9 @@ namespace { etl::callback_timer<3> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -532,9 +532,9 @@ namespace { etl::callback_timer<3> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -545,9 +545,9 @@ namespace ticks = 5; timer_controller.tick(uint32_t(ticks)); - timer_controller.start(id1, etl::timer::start::IMMEDIATE); - timer_controller.start(id2, etl::timer::start::IMMEDIATE); - timer_controller.start(id3, etl::timer::start::DELAYED); + timer_controller.start(id1, etl::timer::start::Immediate); + timer_controller.start(id2, etl::timer::start::Immediate); + timer_controller.start(id3, etl::timer::start::Delayed); const uint32_t step = 1U; @@ -575,8 +575,8 @@ namespace { etl::callback_timer<3> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(free_callback1, 15, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(free_callback2, 5, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(free_callback1, 15, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(free_callback2, 5, etl::timer::mode::Repeating); free_tick_list1.clear(); free_tick_list2.clear(); @@ -611,7 +611,7 @@ namespace { etl::callback_timer<3> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(free_callback1, 5, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(free_callback1, 5, etl::timer::mode::Single_Shot); free_tick_list1.clear(); @@ -646,6 +646,54 @@ namespace CHECK_ARRAY_EQUAL(compare1.data(), free_tick_list1.data(), compare1.size()); } + //************************************************************************* + TEST(message_timer_time_to_next) + { + etl::callback_timer<3> timer_controller; + + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_callback2, 11, etl::timer::mode::Repeating); + + timer_controller.start(id1); + timer_controller.start(id3); + timer_controller.start(id2); + + timer_controller.enable(true); + + CHECK_EQUAL(11, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(4, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(8, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(1, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(5, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(2, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(2, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(6, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(10, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(3, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(4, timer_controller.time_to_next()); + } + //************************************************************************* class test_object { @@ -669,7 +717,7 @@ namespace timer_controller.enable(true); - etl::timer::id::type id = timer_controller.register_timer(delegate_callback, 5, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id = timer_controller.register_timer(delegate_callback, 5, etl::timer::mode::Single_Shot); timer_controller.start(id); timer_controller.tick(4); @@ -722,9 +770,9 @@ namespace { FIX_PROCESSOR_AFFINITY; - etl::timer::id::type id1 = controller.register_timer(member_callback, 400, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = controller.register_timer(free_function_callback, 100, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = controller.register_timer(free_callback2, 10, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = controller.register_timer(member_callback, 400, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = controller.register_timer(free_function_callback, 100, etl::timer::mode::Repeating); + etl::timer::id::type id3 = controller.register_timer(free_callback2, 10, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); diff --git a/test/test_callback_timer_atomic.cpp b/test/test_callback_timer_atomic.cpp index 90c36d2a1..34980b6b8 100644 --- a/test/test_callback_timer_atomic.cpp +++ b/test/test_callback_timer_atomic.cpp @@ -121,16 +121,16 @@ namespace { etl::callback_timer_atomic<2, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback1, 23, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback1, 23, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Single_Shot); CHECK(id1 != etl::timer::id::NO_TIMER); CHECK(id2 != etl::timer::id::NO_TIMER); CHECK(id3 == etl::timer::id::NO_TIMER); timer_controller.clear(); - id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::SINGLE_SHOT); + id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Single_Shot); CHECK(id3 != etl::timer::id::NO_TIMER); } @@ -139,9 +139,9 @@ namespace { etl::callback_timer_atomic<4, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback1, 23, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback1, 23, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Single_Shot); test.tick_list.clear(); free_tick_list1.clear(); @@ -181,7 +181,7 @@ namespace { etl::callback_timer_atomic<1, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::Single_Shot); test.tick_list.clear(); timer_controller.start(id1); @@ -227,9 +227,9 @@ namespace { etl::callback_timer_atomic<3, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -269,9 +269,9 @@ namespace { etl::callback_timer_atomic<3, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -315,9 +315,9 @@ namespace { etl::callback_timer_atomic<3, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -368,9 +368,9 @@ namespace { etl::callback_timer_atomic<3, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback2, 100, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(member_callback1, 10, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(member_callback1, 22, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback2, 100, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(member_callback1, 10, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(member_callback1, 22, etl::timer::mode::Single_Shot); (void)id2; (void)id3; @@ -405,9 +405,9 @@ namespace { etl::callback_timer_atomic<3, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback2, 100, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(member_callback1, 10, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(member_callback1, 22, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback2, 100, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(member_callback1, 10, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(member_callback1, 22, etl::timer::mode::Single_Shot); (void)id2; (void)id3; @@ -443,8 +443,8 @@ namespace etl::callback_timer_atomic<3, std::atomic_uint32_t> timer_controller; etl::timer::id::type id1; - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -465,7 +465,7 @@ namespace { timer_controller.unregister_timer(id2); - id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::REPEATING); + id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::Repeating); timer_controller.start(id1); } @@ -491,9 +491,9 @@ namespace { etl::callback_timer_atomic<3, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -539,9 +539,9 @@ namespace { etl::callback_timer_atomic<3, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -552,9 +552,9 @@ namespace ticks = 5; timer_controller.tick(uint32_t(ticks)); - timer_controller.start(id1, etl::timer::start::IMMEDIATE); - timer_controller.start(id2, etl::timer::start::IMMEDIATE); - timer_controller.start(id3, etl::timer::start::DELAYED); + timer_controller.start(id1, etl::timer::start::Immediate); + timer_controller.start(id2, etl::timer::start::Immediate); + timer_controller.start(id3, etl::timer::start::Delayed); const uint32_t step = 1U; @@ -582,8 +582,8 @@ namespace { etl::callback_timer_atomic<3, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(free_function_callback1, 15, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback2, 5, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(free_function_callback1, 15, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback2, 5, etl::timer::mode::Repeating); free_tick_list1.clear(); free_tick_list2.clear(); @@ -618,7 +618,7 @@ namespace { etl::callback_timer_atomic<3, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(free_function_callback1, 5, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(free_function_callback1, 5, etl::timer::mode::Single_Shot); free_tick_list1.clear(); @@ -653,6 +653,54 @@ namespace CHECK_ARRAY_EQUAL(compare1.data(), free_tick_list1.data(), compare1.size()); } + //************************************************************************* + TEST(message_timer_time_to_next) + { + etl::callback_timer_atomic<3, std::atomic_uint32_t> timer_controller; + + etl::timer::id::type id1 = timer_controller.register_timer(member_callback1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); + + timer_controller.start(id1); + timer_controller.start(id3); + timer_controller.start(id2); + + timer_controller.enable(true); + + CHECK_EQUAL(11, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(4, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(8, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(1, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(5, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(2, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(2, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(6, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(10, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(3, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(4, timer_controller.time_to_next()); + } + //************************************************************************* class test_object { @@ -674,7 +722,7 @@ namespace timer_controller.enable(true); - etl::timer::id::type id = timer_controller.register_timer(delegate_callback, 5, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id = timer_controller.register_timer(delegate_callback, 5, etl::timer::mode::Single_Shot); timer_controller.start(id); timer_controller.tick(4); @@ -728,9 +776,9 @@ namespace { FIX_PROCESSOR_AFFINITY; - etl::timer::id::type id1 = controller.register_timer(member_callback1, 400, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = controller.register_timer(free_function_callback1, 100, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = controller.register_timer(free_function_callback2, 10, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = controller.register_timer(member_callback1, 400, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = controller.register_timer(free_function_callback1, 100, etl::timer::mode::Repeating); + etl::timer::id::type id3 = controller.register_timer(free_function_callback2, 10, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); diff --git a/test/test_callback_timer_interrupt.cpp b/test/test_callback_timer_interrupt.cpp index 70fc6f72d..cbc7d5dd3 100644 --- a/test/test_callback_timer_interrupt.cpp +++ b/test/test_callback_timer_interrupt.cpp @@ -134,16 +134,16 @@ namespace { etl::callback_timer_interrupt<2, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Single_Shot); CHECK(id1 != etl::timer::id::NO_TIMER); CHECK(id2 != etl::timer::id::NO_TIMER); CHECK(id3 == etl::timer::id::NO_TIMER); timer_controller.clear(); - id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::SINGLE_SHOT); + id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Single_Shot); CHECK(id3 != etl::timer::id::NO_TIMER); CHECK_EQUAL(0U, ScopedGuard::guard_count); @@ -154,9 +154,9 @@ namespace { etl::callback_timer_interrupt<4, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Single_Shot); test.tick_list.clear(); free_tick_list1.clear(); @@ -198,7 +198,7 @@ namespace { etl::callback_timer_interrupt<1, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Single_Shot); test.tick_list.clear(); timer_controller.start(id1); @@ -246,9 +246,9 @@ namespace { etl::callback_timer_interrupt<3, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -290,9 +290,9 @@ namespace { etl::callback_timer_interrupt<3, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -338,9 +338,9 @@ namespace { etl::callback_timer_interrupt<3, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -393,9 +393,9 @@ namespace { etl::callback_timer_interrupt<3, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback2, 100, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(member_callback, 10, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(member_callback, 22, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback2, 100, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(member_callback, 10, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(member_callback, 22, etl::timer::mode::Single_Shot); (void)id2; (void)id3; @@ -432,9 +432,9 @@ namespace { etl::callback_timer_interrupt<3, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback2, 100, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(member_callback, 10, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(member_callback, 22, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback2, 100, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(member_callback, 10, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(member_callback, 22, etl::timer::mode::Single_Shot); (void)id2; (void)id3; @@ -472,8 +472,8 @@ namespace etl::callback_timer_interrupt<3, ScopedGuard> timer_controller; etl::timer::id::type id1; - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -494,7 +494,7 @@ namespace { timer_controller.unregister_timer(id2); - id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); + id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); timer_controller.start(id1); } @@ -522,9 +522,9 @@ namespace { etl::callback_timer_interrupt<3, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -572,9 +572,9 @@ namespace { etl::callback_timer_interrupt<3, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -585,9 +585,9 @@ namespace ticks = 5; timer_controller.tick(uint32_t(ticks)); - timer_controller.start(id1, etl::timer::start::IMMEDIATE); - timer_controller.start(id2, etl::timer::start::IMMEDIATE); - timer_controller.start(id3, etl::timer::start::DELAYED); + timer_controller.start(id1, etl::timer::start::Immediate); + timer_controller.start(id2, etl::timer::start::Immediate); + timer_controller.start(id3, etl::timer::start::Delayed); const uint32_t step = 1U; @@ -617,8 +617,8 @@ namespace { etl::callback_timer_interrupt<3, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(free_function_callback, 15, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback2, 5, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(free_function_callback, 15, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback2, 5, etl::timer::mode::Repeating); free_tick_list1.clear(); free_tick_list2.clear(); @@ -655,7 +655,7 @@ namespace { etl::callback_timer_interrupt<3, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(free_function_callback, 5, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(free_function_callback, 5, etl::timer::mode::Single_Shot); free_tick_list1.clear(); @@ -692,6 +692,54 @@ namespace CHECK_EQUAL(0U, ScopedGuard::guard_count); } + //************************************************************************* + TEST(message_timer_time_to_next) + { + etl::callback_timer_interrupt<3, ScopedGuard> timer_controller; + + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); + + timer_controller.start(id1); + timer_controller.start(id3); + timer_controller.start(id2); + + timer_controller.enable(true); + + CHECK_EQUAL(11, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(4, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(8, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(1, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(5, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(2, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(2, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(6, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(10, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(3, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(4, timer_controller.time_to_next()); + } + //************************************************************************* class test_object { @@ -714,7 +762,7 @@ namespace timer_controller.enable(true); - etl::timer::id::type id = timer_controller.register_timer(delegate_callback, 5, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id = timer_controller.register_timer(delegate_callback, 5, etl::timer::mode::Single_Shot); timer_controller.start(id); timer_controller.tick(4); @@ -772,10 +820,10 @@ namespace constexpr uint32_t T3 = 5U; // Register the timers. - etl::timer::id::type id0 = timer_controller.register_timer(delegate_callback0, T0, etl::timer::mode::REPEATING); - etl::timer::id::type id1 = timer_controller.register_timer(delegate_callback1, T1, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(delegate_callback2, T2, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(delegate_callback3, T3, etl::timer::mode::REPEATING); + etl::timer::id::type id0 = timer_controller.register_timer(delegate_callback0, T0, etl::timer::mode::Repeating); + etl::timer::id::type id1 = timer_controller.register_timer(delegate_callback1, T1, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(delegate_callback2, T2, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(delegate_callback3, T3, etl::timer::mode::Repeating); // Start the repeating timers. timer_controller.start(id0); diff --git a/test/test_callback_timer_locked.cpp b/test/test_callback_timer_locked.cpp index ad4bce956..4ca6c3a95 100644 --- a/test/test_callback_timer_locked.cpp +++ b/test/test_callback_timer_locked.cpp @@ -161,16 +161,16 @@ namespace etl::callback_timer_locked<2> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Single_Shot); CHECK(id1 != etl::timer::id::NO_TIMER); CHECK(id2 != etl::timer::id::NO_TIMER); CHECK(id3 == etl::timer::id::NO_TIMER); timer_controller.clear(); - id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::SINGLE_SHOT); + id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Single_Shot); CHECK(id3 != etl::timer::id::NO_TIMER); CHECK_EQUAL(0U, locks.lock_count); @@ -186,9 +186,9 @@ namespace etl::callback_timer_locked<4> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Single_Shot); test.tick_list.clear(); free_tick_list1.clear(); @@ -235,7 +235,7 @@ namespace etl::callback_timer_locked<1> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Single_Shot); test.tick_list.clear(); timer_controller.start(id1); @@ -288,9 +288,9 @@ namespace etl::callback_timer_locked<3> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -337,9 +337,9 @@ namespace etl::callback_timer_locked<3> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -390,9 +390,9 @@ namespace etl::callback_timer_locked<3> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -450,9 +450,9 @@ namespace etl::callback_timer_locked<3> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(member_callback2, 100, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(member_callback, 10, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(member_callback, 22, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback2, 100, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(member_callback, 10, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(member_callback, 22, etl::timer::mode::Single_Shot); (void)id2; (void)id3; @@ -494,9 +494,9 @@ namespace etl::callback_timer_locked<3> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(member_callback2, 100, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(member_callback, 10, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(member_callback, 22, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback2, 100, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(member_callback, 10, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(member_callback, 22, etl::timer::mode::Single_Shot); (void)id2; (void)id3; @@ -539,8 +539,8 @@ namespace etl::callback_timer_locked<3> timer_controller(try_lock, lock, unlock); etl::timer::id::type id1; - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -561,7 +561,7 @@ namespace { timer_controller.unregister_timer(id2); - id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); + id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); timer_controller.start(id1); } @@ -594,9 +594,9 @@ namespace etl::callback_timer_locked<3> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -649,9 +649,9 @@ namespace etl::callback_timer_locked<3> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); @@ -662,9 +662,9 @@ namespace ticks = 5; timer_controller.tick(uint32_t(ticks)); - timer_controller.start(id1, etl::timer::start::IMMEDIATE); - timer_controller.start(id2, etl::timer::start::IMMEDIATE); - timer_controller.start(id3, etl::timer::start::DELAYED); + timer_controller.start(id1, etl::timer::start::Immediate); + timer_controller.start(id2, etl::timer::start::Immediate); + timer_controller.start(id3, etl::timer::start::Delayed); const uint32_t step = 1U; @@ -699,8 +699,8 @@ namespace etl::callback_timer_locked<3> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(free_function_callback, 15, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback2, 5, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(free_function_callback, 15, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback2, 5, etl::timer::mode::Repeating); free_tick_list1.clear(); free_tick_list2.clear(); @@ -742,7 +742,7 @@ namespace etl::callback_timer_locked<3> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(free_function_callback, 5, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(free_function_callback, 5, etl::timer::mode::Single_Shot); free_tick_list1.clear(); @@ -806,7 +806,7 @@ namespace timer_controller.enable(true); - etl::timer::id::type id = timer_controller.register_timer(delegate_callback, 5, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id = timer_controller.register_timer(delegate_callback, 5, etl::timer::mode::Single_Shot); timer_controller.start(id); timer_controller.tick(4); @@ -818,6 +818,59 @@ namespace CHECK_EQUAL(0U, locks.lock_count); } + //************************************************************************* + TEST(message_timer_time_to_next) + { + locks.clear(); + try_lock_type try_lock = try_lock_type::create(); + lock_type lock = lock_type::create(); + unlock_type unlock = unlock_type::create(); + + etl::callback_timer_locked<3> timer_controller(try_lock, lock, unlock); + + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(free_function_callback, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(free_function_callback2, 11, etl::timer::mode::Repeating); + + timer_controller.start(id1); + timer_controller.start(id3); + timer_controller.start(id2); + + timer_controller.enable(true); + + CHECK_EQUAL(11, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(4, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(8, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(1, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(5, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(2, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(2, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(6, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(10, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(3, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(4, timer_controller.time_to_next()); + } + //************************************************************************* #if REALTIME_TEST @@ -900,9 +953,9 @@ namespace { FIX_PROCESSOR_AFFINITY; - etl::timer::id::type id1 = controller.register_timer(member_callback, 400, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = controller.register_timer(free_function_callback, 100, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = controller.register_timer(free_function_callback2, 10, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = controller.register_timer(member_callback, 400, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = controller.register_timer(free_function_callback, 100, etl::timer::mode::Repeating); + etl::timer::id::type id3 = controller.register_timer(free_function_callback2, 10, etl::timer::mode::Repeating); test.tick_list.clear(); free_tick_list1.clear(); diff --git a/test/test_char_traits.cpp b/test/test_char_traits.cpp index 483faa568..5f1401015 100644 --- a/test/test_char_traits.cpp +++ b/test/test_char_traits.cpp @@ -64,6 +64,443 @@ namespace CHECK_EQUAL(6U, sizeof(data4)); } + //************************************************************************* + TEST(test_strcmp_char) + { + const char s1[] = "ABCDEF"; + const char s2[] = "ABCDEF"; + const char s3[] = "ABDDEF"; + const char s4[] = "ABCDE"; + + CHECK_TRUE(etl::strcmp(s1, s2) == 0); + CHECK_TRUE(etl::strcmp(s2, s1) == 0); + CHECK_TRUE(etl::strcmp(s1, s3) < 0); + CHECK_TRUE(etl::strcmp(s3, s1) > 0 ); + CHECK_TRUE(etl::strcmp(s1, s4) > 0); + CHECK_TRUE(etl::strcmp(s4, s1) < 0); + } + +#if ETL_HAS_CHAR8_T + //************************************************************************* + TEST(test_strcmp_char8_t) + { + const char8_t s1[] = u8"ABCDEF"; + const char8_t s2[] = u8"ABCDEF"; + const char8_t s3[] = u8"ABDDEF"; + const char8_t s4[] = u8"ABCDE"; + + CHECK_TRUE(etl::strcmp(s1, s2) == 0); + CHECK_TRUE(etl::strcmp(s2, s1) == 0); + CHECK_TRUE(etl::strcmp(s1, s3) < 0); + CHECK_TRUE(etl::strcmp(s3, s1) > 0); + CHECK_TRUE(etl::strcmp(s1, s4) > 0); + CHECK_TRUE(etl::strcmp(s4, s1) < 0); + } +#endif + + //************************************************************************* + TEST(test_strcmp_wchar_t) + { + const wchar_t s1[] = L"ABCDEF"; + const wchar_t s2[] = L"ABCDEF"; + const wchar_t s3[] = L"ABDDEF"; + const wchar_t s4[] = L"ABCDE"; + + CHECK_TRUE(etl::strcmp(s1, s2) == 0); + CHECK_TRUE(etl::strcmp(s2, s1) == 0); + CHECK_TRUE(etl::strcmp(s1, s3) < 0); + CHECK_TRUE(etl::strcmp(s3, s1) > 0); + CHECK_TRUE(etl::strcmp(s1, s4) > 0); + CHECK_TRUE(etl::strcmp(s4, s1) < 0); + } + + //************************************************************************* + TEST(test_strcmp_char16_t) + { + const char16_t s1[] = u"ABCDEF"; + const char16_t s2[] = u"ABCDEF"; + const char16_t s3[] = u"ABDDEF"; + const char16_t s4[] = u"ABCDE"; + + CHECK_TRUE(etl::strcmp(s1, s2) == 0); + CHECK_TRUE(etl::strcmp(s2, s1) == 0); + CHECK_TRUE(etl::strcmp(s1, s3) < 0); + CHECK_TRUE(etl::strcmp(s3, s1) > 0); + CHECK_TRUE(etl::strcmp(s1, s4) > 0); + CHECK_TRUE(etl::strcmp(s4, s1) < 0); + } + + //************************************************************************* + TEST(test_strcmp_char32_t) + { + const char32_t s1[] = U"ABCDEF"; + const char32_t s2[] = U"ABCDEF"; + const char32_t s3[] = U"ABDDEF"; + const char32_t s4[] = U"ABCDE"; + + CHECK_TRUE(etl::strcmp(s1, s2) == 0); + CHECK_TRUE(etl::strcmp(s1, s3) < 0); + CHECK_TRUE(etl::strcmp(s3, s1) > 0); + CHECK_TRUE(etl::strcmp(s1, s4) > 0); + CHECK_TRUE(etl::strcmp(s4, s1) < 0); + } + + //************************************************************************* + TEST(test_strncmp_char) + { + const char s1[] = "ABCDEF"; + const char s2[] = "ABCDEF"; + const char s3[] = "ABDDEF"; + const char s4[] = "ABCDE"; + + CHECK_TRUE(etl::strncmp(s1, s2, 0) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 1) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 2) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 3) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 4) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 5) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 6) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 0) == 0); + CHECK_TRUE(etl::strncmp(s3, s1, 0) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 1) == 0); + CHECK_TRUE(etl::strncmp(s3, s1, 1) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 2) == 0); + CHECK_TRUE(etl::strncmp(s3, s1, 2) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 3) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 3) > 0); + CHECK_TRUE(etl::strncmp(s1, s3, 4) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 4) > 0); + CHECK_TRUE(etl::strncmp(s1, s3, 5) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 5) > 0); + CHECK_TRUE(etl::strncmp(s1, s3, 6) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 6) > 0); + CHECK_TRUE(etl::strncmp(s1, s4, 0) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 0) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 1) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 1) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 2) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 2) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 3) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 3) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 4) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 4) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 5) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 5) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 6) > 0); + CHECK_TRUE(etl::strncmp(s4, s1, 6) < 0); + } + +#if ETL_HAS_CHAR8_T + //************************************************************************* + TEST(test_strncmp_char8_t) + { + const char8_t s1[] = u8"ABCDEF"; + const char8_t s2[] = u8"ABCDEF"; + const char8_t s3[] = u8"ABDDEF"; + const char8_t s4[] = u8"ABCDE"; + + CHECK_TRUE(etl::strncmp(s1, s2, 0) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 1) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 2) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 3) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 4) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 5) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 6) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 0) == 0); + CHECK_TRUE(etl::strncmp(s3, s1, 0) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 1) == 0); + CHECK_TRUE(etl::strncmp(s3, s1, 1) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 2) == 0); + CHECK_TRUE(etl::strncmp(s3, s1, 2) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 3) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 3) > 0); + CHECK_TRUE(etl::strncmp(s1, s3, 4) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 4) > 0); + CHECK_TRUE(etl::strncmp(s1, s3, 5) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 5) > 0); + CHECK_TRUE(etl::strncmp(s1, s3, 6) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 6) > 0); + CHECK_TRUE(etl::strncmp(s1, s4, 0) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 0) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 1) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 1) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 2) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 2) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 3) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 3) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 4) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 4) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 5) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 5) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 6) > 0); + CHECK_TRUE(etl::strncmp(s4, s1, 6) < 0); + } +#endif + + //************************************************************************* + TEST(test_strncmp_wchar_t) + { + const wchar_t s1[] = L"ABCDEF"; + const wchar_t s2[] = L"ABCDEF"; + const wchar_t s3[] = L"ABDDEF"; + const wchar_t s4[] = L"ABCDE"; + + CHECK_TRUE(etl::strncmp(s1, s2, 0) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 1) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 2) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 3) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 4) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 5) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 6) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 0) == 0); + CHECK_TRUE(etl::strncmp(s3, s1, 0) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 1) == 0); + CHECK_TRUE(etl::strncmp(s3, s1, 1) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 2) == 0); + CHECK_TRUE(etl::strncmp(s3, s1, 2) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 3) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 3) > 0); + CHECK_TRUE(etl::strncmp(s1, s3, 4) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 4) > 0); + CHECK_TRUE(etl::strncmp(s1, s3, 5) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 5) > 0); + CHECK_TRUE(etl::strncmp(s1, s3, 6) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 6) > 0); + CHECK_TRUE(etl::strncmp(s1, s4, 0) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 0) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 1) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 1) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 2) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 2) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 3) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 3) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 4) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 4) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 5) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 5) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 6) > 0); + CHECK_TRUE(etl::strncmp(s4, s1, 6) < 0); + } + + //************************************************************************* + TEST(test_strncmp_char16_t) + { + const char16_t s1[] = u"ABCDEF"; + const char16_t s2[] = u"ABCDEF"; + const char16_t s3[] = u"ABDDEF"; + const char16_t s4[] = u"ABCDE"; + + CHECK_TRUE(etl::strncmp(s1, s2, 0) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 1) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 2) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 3) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 4) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 5) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 6) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 0) == 0); + CHECK_TRUE(etl::strncmp(s3, s1, 0) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 1) == 0); + CHECK_TRUE(etl::strncmp(s3, s1, 1) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 2) == 0); + CHECK_TRUE(etl::strncmp(s3, s1, 2) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 3) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 3) > 0); + CHECK_TRUE(etl::strncmp(s1, s3, 4) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 4) > 0); + CHECK_TRUE(etl::strncmp(s1, s3, 5) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 5) > 0); + CHECK_TRUE(etl::strncmp(s1, s3, 6) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 6) > 0); + CHECK_TRUE(etl::strncmp(s1, s4, 0) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 0) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 1) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 1) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 2) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 2) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 3) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 3) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 4) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 4) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 5) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 5) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 6) > 0); + CHECK_TRUE(etl::strncmp(s4, s1, 6) < 0); + } + + //************************************************************************* + TEST(test_strncmp_char32_t) + { + const char32_t s1[] = U"ABCDEF"; + const char32_t s2[] = U"ABCDEF"; + const char32_t s3[] = U"ABDDEF"; + const char32_t s4[] = U"ABCDE"; + + CHECK_TRUE(etl::strncmp(s1, s2, 0) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 1) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 2) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 3) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 4) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 5) == 0); + CHECK_TRUE(etl::strncmp(s1, s2, 6) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 0) == 0); + CHECK_TRUE(etl::strncmp(s3, s1, 0) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 1) == 0); + CHECK_TRUE(etl::strncmp(s3, s1, 1) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 2) == 0); + CHECK_TRUE(etl::strncmp(s3, s1, 2) == 0); + CHECK_TRUE(etl::strncmp(s1, s3, 3) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 3) > 0); + CHECK_TRUE(etl::strncmp(s1, s3, 4) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 4) > 0); + CHECK_TRUE(etl::strncmp(s1, s3, 5) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 5) > 0); + CHECK_TRUE(etl::strncmp(s1, s3, 6) < 0); + CHECK_TRUE(etl::strncmp(s3, s1, 6) > 0); + CHECK_TRUE(etl::strncmp(s1, s4, 0) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 0) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 1) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 1) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 2) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 2) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 3) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 3) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 4) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 4) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 5) == 0); + CHECK_TRUE(etl::strncmp(s4, s1, 5) == 0); + CHECK_TRUE(etl::strncmp(s1, s4, 6) > 0); + CHECK_TRUE(etl::strncmp(s4, s1, 6) < 0); + } + + //************************************************************************* + TEST(test_strcpy_char) + { + const char src[] = "ABCDEF"; + char dst[7U]; + + auto result = etl::strcpy(dst, src); + + CHECK_TRUE(etl::strcmp(src, dst) == 0); + CHECK_TRUE(etl::strcmp(dst, result) == 0); + } + +#if ETL_HAS_CHAR8_T + //************************************************************************* + TEST(test_strcpy_char8_t) + { + const char8_t src[] = u8"ABCDEF"; + char8_t dst[7U]; + + auto result = etl::strcpy(dst, src); + + CHECK_TRUE(etl::strcmp(src, dst) == 0); + CHECK_TRUE(etl::strcmp(dst, result) == 0); + } +#endif + + //************************************************************************* + TEST(test_strcpy_wchar_t) + { + const wchar_t src[] = L"ABCDEF"; + wchar_t dst[7U]; + + auto result = etl::strcpy(dst, src); + + CHECK_TRUE(etl::strcmp(src, dst) == 0); + CHECK_TRUE(etl::strcmp(dst, result) == 0); + } + + //************************************************************************* + TEST(test_strcpy_char16_t) + { + const char16_t src[] = u"ABCDEF"; + char16_t dst[7U]; + + auto result = etl::strcpy(dst, src); + + CHECK_TRUE(etl::strcmp(src, dst) == 0); + CHECK_TRUE(etl::strcmp(dst, result) == 0); + } + + //************************************************************************* + TEST(test_strcpy_char32_t) + { + const char32_t src[] = U"ABCDEF"; + char32_t dst[7U]; + + auto result = etl::strcpy(dst, src); + + CHECK_TRUE(etl::strcmp(src, dst) == 0); + CHECK_TRUE(etl::strcmp(dst, result) == 0); + } + + //************************************************************************* + TEST(test_strncpy_char) + { + const char src[] = "ABCDEF"; + const char expected[] = "ABCDE"; + char dst[7U]; + + auto result = etl::strncpy(dst, src, 5); + + CHECK_TRUE(etl::strcmp(expected, dst) == 0); + CHECK_TRUE(etl::strcmp(dst, result) == 0); + } + +#if ETL_HAS_CHAR8_T + //************************************************************************* + TEST(test_strncpy_char8_t) + { + const char8_t src[] = u8"ABCDEF"; + const char8_t expected[] = u8"ABCDE"; + char8_t dst[7U]; + + auto result = etl::strncpy(dst, src, 5); + + CHECK_TRUE(etl::strcmp(expected, dst) == 0); + CHECK_TRUE(etl::strcmp(dst, result) == 0); + } +#endif + + //************************************************************************* + TEST(test_strncpy_wchar_t) + { + const wchar_t src[] = L"ABCDEF"; + const wchar_t expected[] = L"ABCDE"; + wchar_t dst[7U]; + + auto result = etl::strncpy(dst, src, 5); + + CHECK_TRUE(etl::strcmp(expected, dst) == 0); + CHECK_TRUE(etl::strcmp(dst, result) == 0); + } + + //************************************************************************* + TEST(test_strncpy_char16_t) + { + const char16_t src[] = u"ABCDEF"; + const char16_t expected[] = u"ABCDE"; + char16_t dst[7U]; + + auto result = etl::strncpy(dst, src, 5); + + CHECK_TRUE(etl::strcmp(expected, dst) == 0); + CHECK_TRUE(etl::strcmp(dst, result) == 0); + } + + //************************************************************************* + TEST(test_strncpy_char32_t) + { + const char32_t src[] = U"ABCDEF"; + const char32_t expected[] = U"ABCDE"; + char32_t dst[7U]; + + auto result = etl::strncpy(dst, src, 5); + + CHECK_TRUE(etl::strcmp(expected, dst) == 0); + CHECK_TRUE(etl::strcmp(dst, result) == 0); + } + //************************************************************************* TEST(test_char_traits_char_template) { diff --git a/test/test_deque.cpp b/test/test_deque.cpp index 7d58f9fd2..159a60109 100644 --- a/test/test_deque.cpp +++ b/test/test_deque.cpp @@ -254,6 +254,7 @@ namespace std::unique_ptr p2(new uint32_t(2U)); std::unique_ptr p3(new uint32_t(3U)); std::unique_ptr p4(new uint32_t(4U)); + std::unique_ptr p5(new uint32_t(5U)); Data deque1; deque1.push_back(std::move(p1)); @@ -262,6 +263,7 @@ namespace deque1.push_back(std::move(p4)); Data deque2; + deque2.push_back(std::move(p5)); deque2 = std::move(deque1); CHECK_EQUAL(4U, deque2.size()); @@ -298,6 +300,7 @@ namespace std::unique_ptr p2(new uint32_t(2U)); std::unique_ptr p3(new uint32_t(3U)); std::unique_ptr p4(new uint32_t(4U)); + std::unique_ptr p5(new uint32_t(5U)); Data deque1; deque1.push_back(std::move(p1)); @@ -306,6 +309,7 @@ namespace deque1.push_back(std::move(p4)); Data deque2; + deque2.push_back(std::move(p5)); IData& ideque1 = deque1; IData& ideque2 = deque2; @@ -934,7 +938,7 @@ namespace DataNDC data(compare_data.begin(), compare_data.end()); Compare_Data::iterator cposition = compare_data.insert(compare_data.cbegin() + 3, N14); - DataNDC::iterator position = data.insert(data.cbegin() + 3, N14); + DataNDC::iterator position = data.insert(data.cbegin() + 3, N14); CHECK_EQUAL(compare_data.size(), std::distance(data.begin(), data.end())); CHECK_EQUAL(compare_data.size(), data.size()); @@ -960,7 +964,7 @@ namespace DataNDC data(compare_data.begin(), compare_data.end()); Compare_Data::iterator cposition = compare_data.emplace(compare_data.begin() + 3, N14.value); - DataNDC::iterator position = data.emplace(data.begin() + 3, N14.value); + DataNDC::iterator position = data.emplace(data.begin() + 3, N14.value); CHECK_EQUAL(compare_data.size(), std::distance(data.begin(), data.end())); CHECK_EQUAL(compare_data.size(), data.size()); @@ -979,6 +983,138 @@ namespace CHECK_EQUAL(std::distance(compare_data.begin(), cposition), std::distance(data.begin(), position)); } + //************************************************************************* + TEST(test_emplace_default) + { + const int Initial = 1; + const int Default = 2; + + struct S + { + S() + : value(Default) + { + } + + S(int v) + : value(v) + { + } + + bool operator ==(const S& rhs) const + { + return value == rhs.value; + } + + int value; + }; + + // First fill with Initial values. + etl::deque data; + data.resize(SIZE, S(Initial)); + data.clear(); + + // Then emplace Default values. + for (size_t i = 0; i < SIZE; ++i) + { + data.emplace(data.end()); + } + + // Compare with an array of default values. + std::array compare_data; + compare_data.fill(S()); + + CHECK_TRUE(std::equal(compare_data.begin(), compare_data.end(), data.begin())); + } + + //************************************************************************* + TEST(test_emplace_front_default) + { + const int Initial = 1; + const int Default = 2; + + struct S + { + S() + : value(Default) + { + } + + S(int v) + : value(v) + { + } + + bool operator ==(const S& rhs) const + { + return value == rhs.value; + } + + int value; + }; + + // First fill with Initial values. + etl::deque data; + data.resize(SIZE, S(Initial)); + data.clear(); + + // Then emplace Default values. + for (size_t i = 0; i < SIZE; ++i) + { + data.emplace_front(); + } + + // Compare with an array of default values. + std::array compare_data; + compare_data.fill(S()); + + CHECK_TRUE(std::equal(compare_data.begin(), compare_data.end(), data.begin())); + } + + //************************************************************************* + TEST(test_emplace_back_default) + { + const int Initial = 1; + const int Default = 2; + + struct S + { + S() + : value(Default) + { + } + + S(int v) + : value(v) + { + } + + bool operator ==(const S& rhs) const + { + return value == rhs.value; + } + + int value; + }; + + // First fill with Initial values. + etl::deque data; + data.resize(SIZE, S(Initial)); + data.clear(); + + // Then emplace Default values. + for (size_t i = 0; i < SIZE; ++i) + { + data.emplace_back(); + } + + // Compare with an array of default values. + std::array compare_data; + compare_data.fill(S()); + + CHECK_TRUE(std::equal(compare_data.begin(), compare_data.end(), data.begin())); + } + //************************************************************************* TEST(test_insert_n_value_position) { diff --git a/test/test_etl_traits.cpp b/test/test_etl_traits.cpp index b8bfc248b..a071960e4 100644 --- a/test/test_etl_traits.cpp +++ b/test/test_etl_traits.cpp @@ -59,6 +59,7 @@ namespace CHECK_EQUAL((ETL_USING_INTEL_COMPILER == 1), etl::traits::using_intel_compiler); CHECK_EQUAL((ETL_USING_TEXAS_INSTRUMENTS_COMPILER == 1), etl::traits::using_texas_instruments_compiler); CHECK_EQUAL((ETL_USING_GENERIC_COMPILER == 1), etl::traits::using_generic_compiler); + CHECK_EQUAL((ETL_USING_8BIT_TYPES == 1), etl::traits::has_8bit_types); CHECK_EQUAL((ETL_USING_64BIT_TYPES == 1), etl::traits::has_64bit_types); CHECK_EQUAL((ETL_HAS_ATOMIC == 1), etl::traits::has_atomic); @@ -74,7 +75,9 @@ namespace CHECK_EQUAL((ETL_HAS_ISTRING_REPAIR == 1), etl::traits::has_istring_repair); CHECK_EQUAL((ETL_HAS_IVECTOR_REPAIR == 1), etl::traits::has_ivector_repair); CHECK_EQUAL((ETL_HAS_IDEQUE_REPAIR == 1), etl::traits::has_ideque_repair); - CHECK_EQUAL((ETL_HAS_MUTABLE_ARRAY_VIEW == 1), etl::traits::has_mutable_array_view); + CHECK_EQUAL((ETL_HAS_MUTABLE_ARRAY_VIEW == 1), etl::traits::has_mutable_array_view); + CHECK_EQUAL((ETL_HAS_VIRTUAL_MESSAGES == 1), etl::traits::has_virtual_messages); + CHECK_EQUAL((ETL_IS_DEBUG_BUILD == 1), etl::traits::is_debug_build); CHECK_EQUAL(__cplusplus, etl::traits::cplusplus); CHECK_EQUAL(ETL_VERSION_MAJOR, etl::traits::version_major); diff --git a/test/test_flat_multiset.cpp b/test/test_flat_multiset.cpp index fbeba5c10..03e284afe 100644 --- a/test/test_flat_multiset.cpp +++ b/test/test_flat_multiset.cpp @@ -62,6 +62,11 @@ namespace struct D1 { + D1() + : a("a") + { + } + D1(const std::string& a_) : a(a_) { @@ -72,9 +77,15 @@ namespace struct D2 { + D2() + : a("a") + , b("b") + { + } + D2(const std::string& a_, const std::string& b_) - : a(a_), - b(b_) + : a(a_) + , b(b_) { } @@ -84,10 +95,17 @@ namespace struct D3 { + D3() + : a("a") + , b("b") + , c("c") + { + } + D3(const std::string& a_, const std::string& b_, const std::string& c_) - : a(a_), - b(b_), - c(c_) + : a(a_) + , b(b_) + , c(c_) { } @@ -98,11 +116,19 @@ namespace struct D4 { + D4() + : a("a") + , b("b") + , c("c") + , d("d") + { + } + D4(const std::string& a_, const std::string& b_, const std::string& c_, const std::string& d_) - : a(a_), - b(b_), - c(c_), - d(d_) + : a(a_) + , b(b_) + , c(c_) + , d(d_) { } @@ -582,6 +608,37 @@ namespace CHECK(std::is_sorted(data.begin(), data.end())); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_emplace_default_value) + { + Compare1 compare; + Data1 data; + + data.emplace(); + compare.emplace(); + + data.emplace(); + compare.emplace(); + + data.emplace(); + compare.emplace(); + + // Do it again. + data.emplace(); + compare.emplace(); + + data.emplace(); + compare.emplace(); + + data.emplace(); + compare.emplace(); + + CHECK_EQUAL(compare.size(), data.size()); + + bool isEqual = std::equal(data.begin(), data.end(), compare.begin()); + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_emplace_value1) { @@ -609,10 +666,7 @@ namespace CHECK_EQUAL(compare.size(), data.size()); - bool isEqual = std::equal(data.begin(), - data.end(), - compare.begin()); - + bool isEqual = std::equal(data.begin(), data.end(), compare.begin()); CHECK(isEqual); } @@ -643,10 +697,7 @@ namespace CHECK_EQUAL(compare.size(), data.size()); - bool isEqual = std::equal(data.begin(), - data.end(), - compare.begin()); - + bool isEqual = std::equal(data.begin(), data.end(), compare.begin()); CHECK(isEqual); } @@ -677,10 +728,7 @@ namespace CHECK_EQUAL(compare.size(), data.size()); - bool isEqual = std::equal(data.begin(), - data.end(), - compare.begin()); - + bool isEqual = std::equal(data.begin(), data.end(), compare.begin()); CHECK(isEqual); } @@ -711,10 +759,7 @@ namespace CHECK_EQUAL(compare.size(), data.size()); - bool isEqual = std::equal(data.begin(), - data.end(), - compare.begin()); - + bool isEqual = std::equal(data.begin(), data.end(), compare.begin()); CHECK(isEqual); } diff --git a/test/test_flat_set.cpp b/test/test_flat_set.cpp index 931972e27..19e6d0398 100644 --- a/test/test_flat_set.cpp +++ b/test/test_flat_set.cpp @@ -94,6 +94,11 @@ namespace struct D1 { + D1() + : a("a") + { + } + D1(const std::string& a_) : a(a_) { @@ -104,9 +109,15 @@ namespace struct D2 { + D2() + : a("a") + , b("b") + { + } + D2(const std::string& a_, const std::string& b_) - : a(a_), - b(b_) + : a(a_) + , b(b_) { } @@ -116,10 +127,17 @@ namespace struct D3 { + D3() + : a("a") + , b("b") + , c("c") + { + } + D3(const std::string& a_, const std::string& b_, const std::string& c_) - : a(a_), - b(b_), - c(c_) + : a(a_) + , b(b_) + , c(c_) { } @@ -130,11 +148,19 @@ namespace struct D4 { + D4() + : a("a") + , b("b") + , c("c") + , d("d") + { + } + D4(const std::string& a_, const std::string& b_, const std::string& c_, const std::string& d_) - : a(a_), - b(b_), - c(c_), - d(d_) + : a(a_) + , b(b_) + , c(c_) + , d(d_) { } @@ -587,6 +613,34 @@ namespace CHECK(std::is_sorted(data.begin(), data.end())); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_emplace_default_value) + { + Compare1 compare; + Data1 data; + + data.emplace(); + compare.emplace(); + + data.emplace(); + compare.emplace(); + + data.emplace(); + compare.emplace(); + + // Do it again. + data.emplace(); + compare.emplace(); + + data.emplace(); + compare.emplace(); + + data.emplace(); + compare.emplace(); + + CHECK_EQUAL(compare.size(), data.size()); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_emplace_value1) { diff --git a/test/test_forward_list.cpp b/test/test_forward_list.cpp index 8d9f85a3a..56be536d6 100644 --- a/test/test_forward_list.cpp +++ b/test/test_forward_list.cpp @@ -241,6 +241,7 @@ namespace data1.push_front(std::move(p4)); DataM data2; + data2.push_front(ItemM(5U)); data2 = std::move(data1); CHECK_EQUAL(0U, data1.size()); @@ -269,6 +270,7 @@ namespace data1.push_front(std::move(p4)); DataM data2; + data2.push_front(ItemM(5U)); IDataM& idata1 = data1; IDataM& idata2 = data2; diff --git a/test/test_fsm.cpp b/test/test_fsm.cpp index 848d9632c..e092f1d28 100644 --- a/test/test_fsm.cpp +++ b/test/test_fsm.cpp @@ -35,11 +35,11 @@ SOFTWARE. #include "etl/queue.h" #include - +#include namespace { - const etl::message_router_id_t MOTOR_CONTROL = 0; + const etl::message_router_id_t Motor_Control = 0; //*************************************************************************** @@ -48,31 +48,33 @@ namespace { enum enum_type { - START, - STOP, - STOPPED, - SET_SPEED, - RECURSIVE, - UNSUPPORTED + Start, + Stop, + Stopped, + Set_Speed, + Recursive, + Self_Transition, + Unsupported }; ETL_DECLARE_ENUM_TYPE(EventId, etl::message_id_t) - ETL_ENUM_TYPE(START, "Start") - ETL_ENUM_TYPE(STOP, "Stop") - ETL_ENUM_TYPE(STOPPED, "Stopped") - ETL_ENUM_TYPE(SET_SPEED, "Set Speed") - ETL_ENUM_TYPE(RECURSIVE, "Recursive") - ETL_ENUM_TYPE(UNSUPPORTED, "Unsupported") + ETL_ENUM_TYPE(Start, "Start") + ETL_ENUM_TYPE(Stop, "Stop") + ETL_ENUM_TYPE(Stopped, "Stopped") + ETL_ENUM_TYPE(Set_Speed, "Set Speed") + ETL_ENUM_TYPE(Recursive, "Recursive") + ETL_ENUM_TYPE(Self_Transition, "Self Transition") + ETL_ENUM_TYPE(Unsupported, "Unsupported") ETL_END_ENUM_TYPE }; //*********************************** - class Start : public etl::message + class Start : public etl::message { }; //*********************************** - class Stop : public etl::message + class Stop : public etl::message { public: @@ -83,7 +85,7 @@ namespace }; //*********************************** - class SetSpeed : public etl::message + class SetSpeed : public etl::message { public: @@ -93,17 +95,22 @@ namespace }; //*********************************** - class Stopped : public etl::message + class Stopped : public etl::message + { + }; + + //*********************************** + class Recursive : public etl::message { }; //*********************************** - class Recursive : public etl::message + class SelfTransition : public etl::message { }; //*********************************** - class Unsupported : public etl::message + class Unsupported : public etl::message { }; @@ -113,18 +120,18 @@ namespace { enum enum_type { - IDLE, - RUNNING, - WINDING_DOWN, - LOCKED, - NUMBER_OF_STATES + Idle, + Running, + Winding_Down, + Locked, + Number_Of_States }; ETL_DECLARE_ENUM_TYPE(StateId, etl::fsm_state_id_t) - ETL_ENUM_TYPE(IDLE, "Idle") - ETL_ENUM_TYPE(RUNNING, "Running") - ETL_ENUM_TYPE(WINDING_DOWN, "Winding Down") - ETL_ENUM_TYPE(LOCKED, "Locked") + ETL_ENUM_TYPE(Idle, "Idle") + ETL_ENUM_TYPE(Running, "Running") + ETL_ENUM_TYPE(Winding_Down, "Winding Down") + ETL_ENUM_TYPE(Locked, "Locked") ETL_END_ENUM_TYPE }; @@ -136,7 +143,7 @@ namespace public: MotorControl() - : fsm(MOTOR_CONTROL) + : fsm(Motor_Control) { } @@ -150,13 +157,18 @@ namespace //*********************************** void ClearStatistics() { - startCount = 0; - stopCount = 0; + startCount = 0; + stopCount = 0; setSpeedCount = 0; - unknownCount = 0; - stoppedCount = 0; - isLampOn = false; - speed = 0; + unknownCount = 0; + stoppedCount = 0; + exited_state = false; + entered_state = false; + isLampOn = false; + speed = 0; + + last_event_id = std::numeric_limits::max(); + last_returned_state_id = std::numeric_limits::max(); } //*********************************** @@ -184,25 +196,29 @@ namespace messageQueue.emplace(message); } - typedef etl::largest Largest_t; + typedef etl::largest Largest_t; typedef etl::packet Packet_t; etl::queue messageQueue; - int startCount; - int stopCount; - int setSpeedCount; - int unknownCount; - int stoppedCount; + int startCount; + int stopCount; + int setSpeedCount; + int unknownCount; + int stoppedCount; + bool exited_state; + bool entered_state; bool isLampOn; - int speed; + int speed; + etl::message_id_t last_event_id; + etl::fsm_state_id_t last_returned_state_id; }; //*********************************** // The idle state. //*********************************** - class Idle : public etl::fsm_state + class Idle : public etl::fsm_state { public: @@ -210,35 +226,50 @@ namespace etl::fsm_state_id_t on_event(const Start&) { ++get_fsm_context().startCount; - return StateId::RUNNING; + return StateId::Running; } //*********************************** etl::fsm_state_id_t on_event(const Recursive&) { get_fsm_context().queue_recursive_message(Start()); - return StateId::IDLE; + return StateId::Idle; + } + + //*********************************** + etl::fsm_state_id_t on_event(const SelfTransition&) + { + get_fsm_context().last_event_id = SelfTransition::ID; + get_fsm_context().last_returned_state_id = etl::ifsm_state::Self_Transition; + return etl::ifsm_state::Self_Transition; } //*********************************** etl::fsm_state_id_t on_event_unknown(const etl::imessage&) { ++get_fsm_context().unknownCount; - return StateId::IDLE; //No_State_Change; + return StateId::Idle; //No_State_Change; } //*********************************** etl::fsm_state_id_t on_enter_state() { get_fsm_context().TurnRunningLampOff(); - return StateId::LOCKED; + get_fsm_context().entered_state = true; + return StateId::Locked; + } + + //*********************************** + void on_exit_state() + { + get_fsm_context().exited_state = true; } }; //*********************************** // The running state. //*********************************** - class Running : public etl::fsm_state + class Running : public etl::fsm_state { public: @@ -249,11 +280,11 @@ namespace if (event.isEmergencyStop) { - return StateId::IDLE; + return StateId::Idle; } else { - return StateId::WINDING_DOWN; + return StateId::Winding_Down; } } @@ -284,7 +315,7 @@ namespace //*********************************** // The winding down state. //*********************************** - class WindingDown : public etl::fsm_state + class WindingDown : public etl::fsm_state { public: @@ -292,7 +323,7 @@ namespace etl::fsm_state_id_t on_event(const Stopped&) { ++get_fsm_context().stoppedCount; - return StateId::IDLE; + return StateId::Idle; } //*********************************** @@ -306,7 +337,7 @@ namespace //*********************************** // The locked state. //*********************************** - class Locked : public etl::fsm_state + class Locked : public etl::fsm_state { public: @@ -324,7 +355,7 @@ namespace WindingDown windingDown; Locked locked; - etl::ifsm_state* stateList[StateId::NUMBER_OF_STATES] = + etl::ifsm_state* stateList[StateId::Number_Of_States] = { &idle, &running, &windingDown, &locked }; @@ -353,8 +384,8 @@ namespace // Now in Idle state. - CHECK_EQUAL(StateId::IDLE, int(motorControl.get_state_id())); - CHECK_EQUAL(StateId::IDLE, int(motorControl.get_state().get_state_id())); + CHECK_EQUAL(StateId::Idle, int(motorControl.get_state_id())); + CHECK_EQUAL(StateId::Idle, int(motorControl.get_state().get_state_id())); CHECK_EQUAL(false, motorControl.isLampOn); CHECK_EQUAL(0, motorControl.setSpeedCount); @@ -369,8 +400,8 @@ namespace motorControl.receive(Stopped()); motorControl.receive(SetSpeed(10)); - CHECK_EQUAL(StateId::IDLE, motorControl.get_state_id()); - CHECK_EQUAL(StateId::IDLE, motorControl.get_state().get_state_id()); + CHECK_EQUAL(StateId::Idle, motorControl.get_state_id()); + CHECK_EQUAL(StateId::Idle, motorControl.get_state().get_state_id()); CHECK_EQUAL(false, motorControl.isLampOn); CHECK_EQUAL(0, motorControl.setSpeedCount); @@ -385,8 +416,8 @@ namespace // Now in Running state. - CHECK_EQUAL(StateId::RUNNING, int(motorControl.get_state_id())); - CHECK_EQUAL(StateId::RUNNING, int(motorControl.get_state().get_state_id())); + CHECK_EQUAL(StateId::Running, int(motorControl.get_state_id())); + CHECK_EQUAL(StateId::Running, int(motorControl.get_state().get_state_id())); CHECK_EQUAL(true, motorControl.isLampOn); CHECK_EQUAL(0, motorControl.setSpeedCount); @@ -400,8 +431,8 @@ namespace motorControl.receive(Start()); motorControl.receive(Stopped()); - CHECK_EQUAL(StateId::RUNNING, int(motorControl.get_state_id())); - CHECK_EQUAL(StateId::RUNNING, int(motorControl.get_state().get_state_id())); + CHECK_EQUAL(StateId::Running, int(motorControl.get_state_id())); + CHECK_EQUAL(StateId::Running, int(motorControl.get_state().get_state_id())); CHECK_EQUAL(true, motorControl.isLampOn); CHECK_EQUAL(0, motorControl.setSpeedCount); @@ -416,8 +447,8 @@ namespace // Still in Running state. - CHECK_EQUAL(StateId::RUNNING, int(motorControl.get_state_id())); - CHECK_EQUAL(StateId::RUNNING, int(motorControl.get_state().get_state_id())); + CHECK_EQUAL(StateId::Running, int(motorControl.get_state_id())); + CHECK_EQUAL(StateId::Running, int(motorControl.get_state().get_state_id())); CHECK_EQUAL(true, motorControl.isLampOn); CHECK_EQUAL(1, motorControl.setSpeedCount); @@ -432,8 +463,8 @@ namespace // Now in WindingDown state. - CHECK_EQUAL(StateId::WINDING_DOWN, int(motorControl.get_state_id())); - CHECK_EQUAL(StateId::WINDING_DOWN, int(motorControl.get_state().get_state_id())); + CHECK_EQUAL(StateId::Winding_Down, int(motorControl.get_state_id())); + CHECK_EQUAL(StateId::Winding_Down, int(motorControl.get_state().get_state_id())); CHECK_EQUAL(true, motorControl.isLampOn); CHECK_EQUAL(1, motorControl.setSpeedCount); @@ -448,8 +479,8 @@ namespace motorControl.receive(Stop()); motorControl.receive(SetSpeed(100)); - CHECK_EQUAL(StateId::WINDING_DOWN, int(motorControl.get_state_id())); - CHECK_EQUAL(StateId::WINDING_DOWN, int(motorControl.get_state().get_state_id())); + CHECK_EQUAL(StateId::Winding_Down, int(motorControl.get_state_id())); + CHECK_EQUAL(StateId::Winding_Down, int(motorControl.get_state().get_state_id())); CHECK_EQUAL(true, motorControl.isLampOn); CHECK_EQUAL(1, motorControl.setSpeedCount); @@ -463,8 +494,8 @@ namespace motorControl.receive(Stopped()); // Now in Locked state via Idle state. - CHECK_EQUAL(StateId::LOCKED, int(motorControl.get_state_id())); - CHECK_EQUAL(StateId::LOCKED, int(motorControl.get_state().get_state_id())); + CHECK_EQUAL(StateId::Locked, int(motorControl.get_state_id())); + CHECK_EQUAL(StateId::Locked, int(motorControl.get_state().get_state_id())); CHECK_EQUAL(false, motorControl.isLampOn); CHECK_EQUAL(1, motorControl.setSpeedCount); @@ -497,8 +528,8 @@ namespace // Now in Running state. - CHECK_EQUAL(StateId::RUNNING, int(motorControl.get_state_id())); - CHECK_EQUAL(StateId::RUNNING, int(motorControl.get_state().get_state_id())); + CHECK_EQUAL(StateId::Running, int(motorControl.get_state_id())); + CHECK_EQUAL(StateId::Running, int(motorControl.get_state().get_state_id())); CHECK_EQUAL(true, motorControl.isLampOn); CHECK_EQUAL(0, motorControl.setSpeedCount); @@ -512,8 +543,8 @@ namespace motorControl.receive(Stop(true)); // Now in Locked state via Idle state. - CHECK_EQUAL(StateId::LOCKED, int(motorControl.get_state_id())); - CHECK_EQUAL(StateId::LOCKED, int(motorControl.get_state().get_state_id())); + CHECK_EQUAL(StateId::Locked, int(motorControl.get_state_id())); + CHECK_EQUAL(StateId::Locked, int(motorControl.get_state().get_state_id())); CHECK_EQUAL(false, motorControl.isLampOn); CHECK_EQUAL(0, motorControl.setSpeedCount); @@ -550,8 +581,8 @@ namespace // Now in Running state. - CHECK_EQUAL(StateId::RUNNING, int(motorControl.get_state_id())); - CHECK_EQUAL(StateId::RUNNING, int(motorControl.get_state().get_state_id())); + CHECK_EQUAL(StateId::Running, int(motorControl.get_state_id())); + CHECK_EQUAL(StateId::Running, int(motorControl.get_state().get_state_id())); CHECK_EQUAL(true, motorControl.isLampOn); CHECK_EQUAL(0, motorControl.setSpeedCount); @@ -565,11 +596,11 @@ namespace //************************************************************************* TEST(test_fsm_supported) { - CHECK(motorControl.accepts(EventId::SET_SPEED)); - CHECK(motorControl.accepts(EventId::START)); - CHECK(motorControl.accepts(EventId::STOP)); - CHECK(motorControl.accepts(EventId::STOPPED)); - CHECK(motorControl.accepts(EventId::UNSUPPORTED)); + CHECK(motorControl.accepts(EventId::Set_Speed)); + CHECK(motorControl.accepts(EventId::Start)); + CHECK(motorControl.accepts(EventId::Stop)); + CHECK(motorControl.accepts(EventId::Stopped)); + CHECK(motorControl.accepts(EventId::Unsupported)); CHECK(motorControl.accepts(SetSpeed(0))); CHECK(motorControl.accepts(Start())); @@ -595,12 +626,12 @@ namespace MotorControl mc; // Null state. - etl::ifsm_state* stateList[StateId::NUMBER_OF_STATES] = + etl::ifsm_state* stateList[StateId::Number_Of_States] = { &idle, &running,& windingDown, nullptr }; - CHECK_THROW(mc.set_states(stateList, StateId::NUMBER_OF_STATES), etl::fsm_null_state_exception); + CHECK_THROW(mc.set_states(stateList, StateId::Number_Of_States), etl::fsm_null_state_exception); } //************************************************************************* @@ -609,12 +640,37 @@ namespace MotorControl mc; // Incorrect order. - etl::ifsm_state* stateList[StateId::NUMBER_OF_STATES] = + etl::ifsm_state* stateList[StateId::Number_Of_States] = { &idle, &windingDown, &running, &locked }; - CHECK_THROW(mc.set_states(stateList, StateId::NUMBER_OF_STATES), etl::fsm_state_list_order_exception); + CHECK_THROW(mc.set_states(stateList, StateId::Number_Of_States), etl::fsm_state_list_order_exception); + } + + //************************************************************************* + TEST(test_fsm_self_transition) + { + MotorControl motorControl; + + motorControl.Initialise(stateList, ETL_OR_STD17::size(stateList)); + motorControl.reset(); + motorControl.ClearStatistics(); + + // Start the FSM. + motorControl.start(false); + + CHECK_FALSE(motorControl.exited_state); + CHECK_FALSE(motorControl.entered_state); + + // Execute self transition. + motorControl.receive(SelfTransition()); + + CHECK_EQUAL(size_t(SelfTransition::ID), size_t(motorControl.last_event_id)); + CHECK_EQUAL(size_t(etl::ifsm_state::Self_Transition), size_t(motorControl.last_returned_state_id)); + + CHECK_TRUE(motorControl.exited_state); + CHECK_TRUE(motorControl.entered_state); } }; } diff --git a/test/test_indirect_vector.cpp b/test/test_indirect_vector.cpp index 97dc944f0..597d81b50 100644 --- a/test/test_indirect_vector.cpp +++ b/test/test_indirect_vector.cpp @@ -312,6 +312,7 @@ namespace std::unique_ptr p2(new uint32_t(2U)); std::unique_ptr p3(new uint32_t(3U)); std::unique_ptr p4(new uint32_t(4U)); + std::unique_ptr p5(new uint32_t(5U)); Data data1; data1.push_back(std::move(p1)); @@ -325,6 +326,7 @@ namespace CHECK(!bool(p4)); Data data2; + data2.push_back(std::move(p5)); data2 = std::move(data1); CHECK_EQUAL(0U, data1.size()); @@ -495,6 +497,15 @@ namespace CHECK_EQUAL(data.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_reserve) + { + DataNDC data; + + CHECK_NO_THROW(data.reserve(data.max_size())); + CHECK_THROW(data.reserve(data.max_size() + 1), etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty) { @@ -692,6 +703,27 @@ namespace CHECK_THROW(data.push_back(NDC("Z")), etl::vector_full); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_emplace_back_default_value) + { + CompareDataDC compare_data; + DataDC data; + + for (size_t i = 0UL; i < SIZE; ++i) + { + compare_data.emplace_back(); + data.emplace_back(); + } + + CHECK_EQUAL(compare_data.size(), data.size()); + + bool is_equal = std::equal(data.begin(), + data.end(), + compare_data.begin()); + + CHECK(is_equal); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_emplace_back) { @@ -802,7 +834,6 @@ namespace } //************************************************************************* - // To test the CPP03 versions then ETL_TEST_VECTOR_CPP11 must be set to 0 in vector.h TEST_FIXTURE(SetupFixture, test_emplace_back_multiple) { class Data @@ -965,6 +996,31 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_emplace_position_default_value) + { + const size_t INITIAL_SIZE = 5UL; + + for (size_t offset = 0UL; offset <= INITIAL_SIZE; ++offset) + { + CompareDataDC compare_data; + DataDC data; + + DC initial[] = { DC("0"), DC("1"), DC("2"), DC("3"), DC("4"), DC("4"), DC("4"), DC("5"), DC("6"), DC("7"), DC("8"), DC("9") }; + + data.assign(std::begin(initial), std::begin(initial) + INITIAL_SIZE); + compare_data.assign(std::begin(initial), std::begin(initial) + INITIAL_SIZE); + + data.emplace(data.begin() + offset); + compare_data.emplace(compare_data.begin() + offset); + + CHECK_EQUAL(compare_data.size(), data.size()); + + bool is_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + CHECK(is_equal); + } + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_emplace_position_value) { diff --git a/test/test_indirect_vector_external_buffer.cpp b/test/test_indirect_vector_external_buffer.cpp index 57a296635..1172434b6 100644 --- a/test/test_indirect_vector_external_buffer.cpp +++ b/test/test_indirect_vector_external_buffer.cpp @@ -364,6 +364,7 @@ namespace std::unique_ptr p2(new uint32_t(2U)); std::unique_ptr p3(new uint32_t(3U)); std::unique_ptr p4(new uint32_t(4U)); + std::unique_ptr p5(new uint32_t(5U)); Data data1(lookup1, pool1); data1.push_back(std::move(p1)); @@ -377,6 +378,7 @@ namespace CHECK(!bool(p4)); Data data2(lookup2, pool2); + data2.push_back(std::move(p5)); data2 = std::move(data1); CHECK_EQUAL(0U, data1.size()); @@ -428,6 +430,7 @@ namespace std::unique_ptr p2(new uint32_t(2U)); std::unique_ptr p3(new uint32_t(3U)); std::unique_ptr p4(new uint32_t(4U)); + std::unique_ptr p5(new uint32_t(5U)); Data data1(lookup1, pool1); data1.push_back(std::move(p1)); @@ -436,6 +439,7 @@ namespace data1.push_back(std::move(p4)); Data data2(lookup2, pool2); + data2.push_back(std::move(p5)); IData& idata1 = data1; IData& idata2 = data2; @@ -592,6 +596,17 @@ namespace CHECK_EQUAL(data.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_reserve) + { + LookupNDC lookup; + PoolNDC pool; + DataNDC data(lookup, pool); + + CHECK_NO_THROW(data.reserve(data.max_size())); + CHECK_THROW(data.reserve(data.max_size() + 1), etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty) { diff --git a/test/test_list.cpp b/test/test_list.cpp index a24ac7357..ac01fb429 100644 --- a/test/test_list.cpp +++ b/test/test_list.cpp @@ -561,47 +561,96 @@ namespace CompareData compare_data(INITIAL_SIZE, VALUE); DataNDC data(INITIAL_SIZE, VALUE); - size_t offset = 2UL; + //size_t offset = 2UL; DataNDC::iterator i_data = data.begin(); - std::advance(i_data, offset); + //std::advance(i_data, offset); - CompareData::iterator i_compare_data = compare_data.begin(); - std::advance(i_compare_data, offset); + //CompareData::iterator i_compare_data = compare_data.begin(); + //std::advance(i_compare_data, offset); data.emplace(i_data, INSERT_VALUE); - compare_data.emplace(i_compare_data, INSERT_VALUE); + //compare_data.emplace(i_compare_data, INSERT_VALUE); - CHECK_EQUAL(compare_data.size(), data.size()); + //CHECK_EQUAL(compare_data.size(), data.size()); - are_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + //are_equal = std::equal(data.begin(), data.end(), compare_data.begin()); - CHECK(are_equal); + //CHECK(are_equal); - offset = 0; + //offset = 0; - i_data = data.begin(); - std::advance(i_data, offset); + //i_data = data.begin(); + //std::advance(i_data, offset); - i_compare_data = compare_data.begin(); - std::advance(i_compare_data, offset); + //i_compare_data = compare_data.begin(); + //std::advance(i_compare_data, offset); - data.emplace(i_data, INSERT_VALUE); - compare_data.emplace(i_compare_data, INSERT_VALUE); + //data.emplace(i_data, INSERT_VALUE); + //compare_data.emplace(i_compare_data, INSERT_VALUE); - are_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + //are_equal = std::equal(data.begin(), data.end(), compare_data.begin()); - CHECK(are_equal); + //CHECK(are_equal); - i_data = data.end(); - i_compare_data = compare_data.end(); + //i_data = data.end(); + //i_compare_data = compare_data.end(); - data.emplace(i_data, VALUE); - compare_data.emplace(i_compare_data, VALUE); + //data.emplace(i_data, VALUE); + //compare_data.emplace(i_compare_data, VALUE); - are_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + //are_equal = std::equal(data.begin(), data.end(), compare_data.begin()); - CHECK(are_equal); + //CHECK(are_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_emplace_position_default_constructor) + { + //std::list compare_data; + //DataDC data; + + //size_t offset = 2UL; + + //DataDC::iterator i_data = data.begin(); + //std::advance(i_data, offset); + + //std::list::iterator i_compare_data = compare_data.begin(); + //std::advance(i_compare_data, offset); + + //data.emplace(i_data); + //compare_data.emplace(i_compare_data); + + //CHECK_EQUAL(compare_data.size(), data.size()); + + //are_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + + //CHECK(are_equal); + + //offset = 0; + + //i_data = data.begin(); + //std::advance(i_data, offset); + + //i_compare_data = compare_data.begin(); + //std::advance(i_compare_data, offset); + + //data.emplace(i_data); + //compare_data.emplace(i_compare_data); + + //are_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + + //CHECK(are_equal); + + //i_data = data.end(); + //i_compare_data = compare_data.end(); + + //data.emplace(i_data); + //compare_data.emplace(i_compare_data); + + //are_equal = std::equal(data.begin(), data.end(), compare_data.begin()); + + //CHECK(are_equal); } //************************************************************************* @@ -708,9 +757,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_emplace_front) { - CompareData compare_data; - DataNDC data; + std::list compare_data; + etl::list data; + compare_data.emplace_front(); compare_data.emplace_front("1"); compare_data.emplace_front("2"); compare_data.emplace_front("3"); @@ -718,6 +768,7 @@ namespace compare_data.emplace_front("5"); compare_data.emplace_front("6"); + CHECK_NO_THROW(data.emplace_front()); CHECK_NO_THROW(data.emplace_front("1")); CHECK_NO_THROW(data.emplace_front("2")); CHECK_NO_THROW(data.emplace_front("3")); @@ -874,9 +925,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_emplace_back) { - CompareData compare_data; - DataNDC data; + std::list compare_data; + etl::list data; + compare_data.emplace_back(); compare_data.emplace_back("1"); compare_data.emplace_back("2"); compare_data.emplace_back("3"); @@ -884,6 +936,7 @@ namespace compare_data.emplace_back("5"); compare_data.emplace_back("6"); + CHECK_NO_THROW(data.emplace_back()); CHECK_NO_THROW(data.emplace_back("1")); CHECK_NO_THROW(data.emplace_back("2")); CHECK_NO_THROW(data.emplace_back("3")); @@ -1175,6 +1228,7 @@ namespace data1.push_back(std::move(p4)); DataM data2; + data2.push_back(ItemM(5U)); data2 = std::move(data1); CHECK_EQUAL(0U, data1.size()); @@ -1222,6 +1276,7 @@ namespace data1.push_back(std::move(p4)); DataM data2; + data2.push_back(ItemM(5U)); IDataM& idata1 = data1; IDataM& idata2 = data2; diff --git a/test/test_macros.cpp b/test/test_macros.cpp new file mode 100644 index 000000000..cf8be527c --- /dev/null +++ b/test/test_macros.cpp @@ -0,0 +1,61 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Documentation: + +Copyright(c) 2022 John Wellbelove + +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 "unit_test_framework.h" + +#include "etl/platform.h" +#include "etl/macros.h" +#include "etl/char_traits.h" + +#include + +namespace +{ + SUITE(test_macros) + { + template + bool CheckEqualStrings(const T * expected, const T * actual) + { + return (etl::strlen(expected) == etl::strlen(actual)) && + std::equal(expected, expected + etl::strlen(expected), actual); + } + + TEST(test_macros) + { + CHECK_TRUE(CheckEqualStrings("A, B, C, D, E, F", ETL_STRINGIFY(A, B, C, D, E, F))); + + CHECK_ARRAY_EQUAL( "ABCDEF", ETL_STRING(ABCDEF), etl::strlen("ABCDEF")); + CHECK_ARRAY_EQUAL(L"ABCDEF", ETL_WIDE_STRING(ABCDEF), etl::strlen(L"ABCDEF")); + CHECK_ARRAY_EQUAL(u8"ABCDEF", ETL_U8_STRING(ABCDEF), etl::strlen(u8"ABCDEF")); + CHECK_ARRAY_EQUAL(u"ABCDEF", ETL_U16_STRING(ABCDEF), etl::strlen(u"ABCDEF")); + CHECK_ARRAY_EQUAL(U"ABCDEF", ETL_U32_STRING(ABCDEF), etl::strlen(U"ABCDEF")); + } + }; +} diff --git a/test/test_map.cpp b/test/test_map.cpp index 4845e52b8..a105cee2f 100644 --- a/test/test_map.cpp +++ b/test/test_map.cpp @@ -389,6 +389,7 @@ namespace data1.insert(DataM::value_type(std::string("3"), etl::move(d3))); data1.insert(DataM::value_type(std::string("4"), ItemM(4))); + data2.insert(DataM::value_type(std::string("5"), ItemM(5))); data2 = std::move(data1); CHECK(1 == data2.at("1").value); diff --git a/test/test_message_packet.cpp b/test/test_message_packet.cpp index 7925e8bc1..6c7bda230 100644 --- a/test/test_message_packet.cpp +++ b/test/test_message_packet.cpp @@ -28,6 +28,10 @@ SOFTWARE. #include "unit_test_framework.h" +#include "etl/platform.h" + +#if ETL_HAS_VIRTUAL_MESSAGES + #include "etl/message_packet.h" #include @@ -450,3 +454,5 @@ namespace } }; } + +#endif diff --git a/test/test_message_router.cpp b/test/test_message_router.cpp index d63cc97df..b5936d629 100644 --- a/test/test_message_router.cpp +++ b/test/test_message_router.cpp @@ -68,24 +68,13 @@ namespace //}; //*********************************** - struct Interface : public etl::imessage - { - virtual int VirtualFunction() const = 0; - }; - - //*********************************** - struct Message1 : public etl::message + struct Message1 : public etl::message { Message1(etl::imessage_router& callback_) : callback(callback_) { } - int VirtualFunction() const override - { - return 1; - } - etl::imessage_router& callback; }; @@ -153,7 +142,7 @@ namespace { ++message1_count; etl::send_message(msg.callback, message5); - CHECK_EQUAL(1, msg.VirtualFunction()); + //CHECK_EQUAL(1, msg.VirtualFunction()); } void on_receive(const Message2& msg) @@ -228,7 +217,7 @@ namespace ++message1_count; sender_id = msg.callback.get_message_router_id(); etl::send_message(msg.callback, message5); - CHECK_EQUAL(1, msg.VirtualFunction()); + //CHECK_EQUAL(1, msg.VirtualFunction()); } void on_receive(const Message2& msg) @@ -516,6 +505,7 @@ namespace CHECK(r2.accepts(message5.get_message_id())); } +#if ETL_HAS_VIRTUAL_MESSAGES //************************************************************************* TEST(message_router_queue) { @@ -588,6 +578,7 @@ namespace CHECK_EQUAL(4, r1.callback_count); queue.pop(); } +#endif //************************************************************************* TEST(message_router_successor) diff --git a/test/test_message_timer.cpp b/test/test_message_timer.cpp index d348dc562..3f27e81ec 100644 --- a/test/test_message_timer.cpp +++ b/test/test_message_timer.cpp @@ -141,16 +141,16 @@ namespace { etl::message_timer<2> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Single_Shot); CHECK(id1 != etl::timer::id::NO_TIMER); CHECK(id2 != etl::timer::id::NO_TIMER); CHECK(id3 == etl::timer::id::NO_TIMER); timer_controller.clear(); - id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::SINGLE_SHOT); + id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Single_Shot); CHECK(id3 != etl::timer::id::NO_TIMER); } @@ -159,9 +159,9 @@ namespace { etl::message_timer<3> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Single_Shot); router1.clear(); @@ -195,7 +195,7 @@ namespace { etl::message_timer<1> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Single_Shot); router1.clear(); timer_controller.start(id1); @@ -241,9 +241,9 @@ namespace { etl::message_timer<3> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -277,9 +277,9 @@ namespace { etl::message_timer<3> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -317,9 +317,9 @@ namespace { etl::message_timer<3> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -365,8 +365,8 @@ namespace etl::message_timer<3> timer_controller; etl::timer::id::type id1; - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -385,7 +385,7 @@ namespace { timer_controller.unregister_timer(id2); - id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); + id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); timer_controller.start(id1); } @@ -407,9 +407,9 @@ namespace { etl::message_timer<3> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -449,9 +449,9 @@ namespace { etl::message_timer<3> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, bus1, 37, etl::timer::mode::SINGLE_SHOT, ROUTER1); - etl::timer::id::type id2 = timer_controller.register_timer(message2, bus1, 23, etl::timer::mode::SINGLE_SHOT, ROUTER1); - etl::timer::id::type id3 = timer_controller.register_timer(message3, bus1, 11, etl::timer::mode::SINGLE_SHOT, etl::imessage_router::ALL_MESSAGE_ROUTERS); + etl::timer::id::type id1 = timer_controller.register_timer(message1, bus1, 37, etl::timer::mode::Single_Shot, ROUTER1); + etl::timer::id::type id2 = timer_controller.register_timer(message2, bus1, 23, etl::timer::mode::Single_Shot, ROUTER1); + etl::timer::id::type id3 = timer_controller.register_timer(message3, bus1, 11, etl::timer::mode::Single_Shot, etl::imessage_router::ALL_MESSAGE_ROUTERS); bus1.subscribe(router1); @@ -487,9 +487,9 @@ namespace { etl::message_timer<3> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -502,9 +502,9 @@ namespace ticks = 5; timer_controller.tick(uint32_t(ticks)); - timer_controller.start(id1, etl::timer::start::IMMEDIATE); - timer_controller.start(id2, etl::timer::start::IMMEDIATE); - timer_controller.start(id3, etl::timer::start::DELAYED); + timer_controller.start(id1, etl::timer::start::Immediate); + timer_controller.start(id2, etl::timer::start::Immediate); + timer_controller.start(id3, etl::timer::start::Delayed); const uint32_t step = 1UL; @@ -528,8 +528,8 @@ namespace { etl::message_timer<3> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 15, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 5, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 15, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 5, etl::timer::mode::Repeating); router1.clear(); @@ -560,7 +560,7 @@ namespace { etl::message_timer<3> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 5, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 5, etl::timer::mode::Single_Shot); router1.clear(); @@ -593,6 +593,56 @@ namespace CHECK_ARRAY_EQUAL(compare1.data(), router1.message1.data(), compare1.size()); } + //************************************************************************* + TEST(message_timer_time_to_next) + { + etl::message_timer<3> timer_controller; + + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); + + router1.clear(); + + timer_controller.start(id1); + timer_controller.start(id3); + timer_controller.start(id2); + + timer_controller.enable(true); + + CHECK_EQUAL(11, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(4, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(8, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(1, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(5, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(2, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(2, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(6, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(10, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(3, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(4, timer_controller.time_to_next()); + } + //************************************************************************* #if REALTIME_TEST @@ -636,9 +686,9 @@ namespace { FIX_PROCESSOR_AFFINITY; - etl::timer::id::type id1 = controller.register_timer(message1, router1, 400, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = controller.register_timer(message2, router1, 100, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = controller.register_timer(message3, router1, 10, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = controller.register_timer(message1, router1, 400, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = controller.register_timer(message2, router1, 100, etl::timer::mode::Repeating); + etl::timer::id::type id3 = controller.register_timer(message3, router1, 10, etl::timer::mode::Repeating); router1.clear(); diff --git a/test/test_message_timer_atomic.cpp b/test/test_message_timer_atomic.cpp index 6d5c8316e..f8683f50a 100644 --- a/test/test_message_timer_atomic.cpp +++ b/test/test_message_timer_atomic.cpp @@ -141,16 +141,16 @@ namespace { etl::message_timer_atomic<2, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Single_Shot); CHECK(id1 != etl::timer::id::NO_TIMER); CHECK(id2 != etl::timer::id::NO_TIMER); CHECK(id3 == etl::timer::id::NO_TIMER); timer_controller.clear(); - id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::SINGLE_SHOT); + id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Single_Shot); CHECK(id3 != etl::timer::id::NO_TIMER); } @@ -159,9 +159,9 @@ namespace { etl::message_timer_atomic<3, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Single_Shot); router1.clear(); @@ -195,7 +195,7 @@ namespace { etl::message_timer_atomic<1, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Single_Shot); router1.clear(); timer_controller.start(id1); @@ -241,9 +241,9 @@ namespace { etl::message_timer_atomic<3, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -277,9 +277,9 @@ namespace { etl::message_timer_atomic<3, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -317,9 +317,9 @@ namespace { etl::message_timer_atomic<3, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -365,8 +365,8 @@ namespace etl::message_timer_atomic<3, std::atomic_uint32_t> timer_controller; etl::timer::id::type id1; - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -385,7 +385,7 @@ namespace { timer_controller.unregister_timer(id2); - id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); + id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); timer_controller.start(id1); } @@ -407,9 +407,9 @@ namespace { etl::message_timer_atomic<3, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -449,9 +449,9 @@ namespace { etl::message_timer_atomic<3, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, bus1, 37, etl::timer::mode::SINGLE_SHOT, ROUTER1); - etl::timer::id::type id2 = timer_controller.register_timer(message2, bus1, 23, etl::timer::mode::SINGLE_SHOT, ROUTER1); - etl::timer::id::type id3 = timer_controller.register_timer(message3, bus1, 11, etl::timer::mode::SINGLE_SHOT, etl::imessage_router::ALL_MESSAGE_ROUTERS); + etl::timer::id::type id1 = timer_controller.register_timer(message1, bus1, 37, etl::timer::mode::Single_Shot, ROUTER1); + etl::timer::id::type id2 = timer_controller.register_timer(message2, bus1, 23, etl::timer::mode::Single_Shot, ROUTER1); + etl::timer::id::type id3 = timer_controller.register_timer(message3, bus1, 11, etl::timer::mode::Single_Shot, etl::imessage_router::ALL_MESSAGE_ROUTERS); bus1.subscribe(router1); @@ -487,9 +487,9 @@ namespace { etl::message_timer_atomic<3, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -502,9 +502,9 @@ namespace ticks = 5; timer_controller.tick(uint32_t(ticks)); - timer_controller.start(id1, etl::timer::start::IMMEDIATE); - timer_controller.start(id2, etl::timer::start::IMMEDIATE); - timer_controller.start(id3, etl::timer::start::DELAYED); + timer_controller.start(id1, etl::timer::start::Immediate); + timer_controller.start(id2, etl::timer::start::Immediate); + timer_controller.start(id3, etl::timer::start::Delayed); const uint32_t step = 1UL; @@ -528,8 +528,8 @@ namespace { etl::message_timer_atomic<3, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 15, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 5, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 15, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 5, etl::timer::mode::Repeating); router1.clear(); @@ -560,7 +560,7 @@ namespace { etl::message_timer_atomic<3, std::atomic_uint32_t> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 5, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 5, etl::timer::mode::Single_Shot); router1.clear(); @@ -593,6 +593,56 @@ namespace CHECK_ARRAY_EQUAL(compare1.data(), router1.message1.data(), compare1.size()); } + //************************************************************************* + TEST(message_timer_time_to_next) + { + etl::message_timer_atomic<3, std::atomic_uint32_t> timer_controller; + + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); + + router1.clear(); + + timer_controller.start(id1); + timer_controller.start(id3); + timer_controller.start(id2); + + timer_controller.enable(true); + + CHECK_EQUAL(11, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(4, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(8, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(1, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(5, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(2, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(2, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(6, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(10, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(3, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(4, timer_controller.time_to_next()); + } + //************************************************************************* #if REALTIME_TEST @@ -636,9 +686,9 @@ namespace { FIX_PROCESSOR_AFFINITY; - etl::timer::id::type id1 = controller.register_timer(message1, router1, 400, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = controller.register_timer(message2, router1, 100, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = controller.register_timer(message3, router1, 10, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = controller.register_timer(message1, router1, 400, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = controller.register_timer(message2, router1, 100, etl::timer::mode::Repeating); + etl::timer::id::type id3 = controller.register_timer(message3, router1, 10, etl::timer::mode::Repeating); router1.clear(); diff --git a/test/test_message_timer_interrupt.cpp b/test/test_message_timer_interrupt.cpp index 1d8fe5d5b..d1601bdb2 100644 --- a/test/test_message_timer_interrupt.cpp +++ b/test/test_message_timer_interrupt.cpp @@ -164,16 +164,16 @@ namespace { etl::message_timer_interrupt<2, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Single_Shot); CHECK(id1 != etl::timer::id::NO_TIMER); CHECK(id2 != etl::timer::id::NO_TIMER); CHECK(id3 == etl::timer::id::NO_TIMER); timer_controller.clear(); - id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::SINGLE_SHOT); + id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Single_Shot); CHECK(id3 != etl::timer::id::NO_TIMER); CHECK_EQUAL(0U, ScopedGuard::guard_count); @@ -184,9 +184,9 @@ namespace { etl::message_timer_interrupt<3, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Single_Shot); router1.clear(); @@ -222,7 +222,7 @@ namespace { etl::message_timer_interrupt<1, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Single_Shot); router1.clear(); timer_controller.start(id1); @@ -270,9 +270,9 @@ namespace { etl::message_timer_interrupt<3, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -308,9 +308,9 @@ namespace { etl::message_timer_interrupt<3, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -350,9 +350,9 @@ namespace { etl::message_timer_interrupt<3, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -400,8 +400,8 @@ namespace etl::message_timer_interrupt<3, ScopedGuard> timer_controller; etl::timer::id::type id1; - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -420,7 +420,7 @@ namespace { timer_controller.unregister_timer(id2); - id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); + id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); timer_controller.start(id1); } @@ -444,9 +444,9 @@ namespace { etl::message_timer_interrupt<3, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -488,9 +488,9 @@ namespace { etl::message_timer_interrupt<3, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, bus1, 37, etl::timer::mode::SINGLE_SHOT, ROUTER1); - etl::timer::id::type id2 = timer_controller.register_timer(message2, bus1, 23, etl::timer::mode::SINGLE_SHOT, ROUTER1); - etl::timer::id::type id3 = timer_controller.register_timer(message3, bus1, 11, etl::timer::mode::SINGLE_SHOT, etl::imessage_router::ALL_MESSAGE_ROUTERS); + etl::timer::id::type id1 = timer_controller.register_timer(message1, bus1, 37, etl::timer::mode::Single_Shot, ROUTER1); + etl::timer::id::type id2 = timer_controller.register_timer(message2, bus1, 23, etl::timer::mode::Single_Shot, ROUTER1); + etl::timer::id::type id3 = timer_controller.register_timer(message3, bus1, 11, etl::timer::mode::Single_Shot, etl::imessage_router::ALL_MESSAGE_ROUTERS); bus1.subscribe(router1); @@ -528,9 +528,9 @@ namespace { etl::message_timer_interrupt<3, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -543,9 +543,9 @@ namespace ticks = 5; timer_controller.tick(uint32_t(ticks)); - timer_controller.start(id1, etl::timer::start::IMMEDIATE); - timer_controller.start(id2, etl::timer::start::IMMEDIATE); - timer_controller.start(id3, etl::timer::start::DELAYED); + timer_controller.start(id1, etl::timer::start::Immediate); + timer_controller.start(id2, etl::timer::start::Immediate); + timer_controller.start(id3, etl::timer::start::Delayed); const uint32_t step = 1UL; @@ -571,8 +571,8 @@ namespace { etl::message_timer_interrupt<3, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 15, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 5, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 15, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 5, etl::timer::mode::Repeating); router1.clear(); @@ -605,7 +605,7 @@ namespace { etl::message_timer_interrupt<3, ScopedGuard> timer_controller; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 5, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 5, etl::timer::mode::Single_Shot); router1.clear(); @@ -641,9 +641,56 @@ namespace } //************************************************************************* - - + TEST(message_timer_time_to_next) + { + etl::message_timer_interrupt<3, ScopedGuard> timer_controller; + + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); + + router1.clear(); + + timer_controller.start(id1); + timer_controller.start(id3); + timer_controller.start(id2); + + timer_controller.enable(true); + + CHECK_EQUAL(11, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(4, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(8, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(1, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(5, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(2, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(2, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(6, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(10, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(3, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(4, timer_controller.time_to_next()); + } + //************************************************************************* class RouterLog : public etl::message_router { public: @@ -709,10 +756,10 @@ namespace constexpr uint32_t T4 = 5U; // Register the timers. - etl::timer::id::type id1 = timer_controller.register_timer(message1, router, T1, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router, T2, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router, T3, etl::timer::mode::REPEATING); - etl::timer::id::type id4 = timer_controller.register_timer(message4, router, T4, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router, T1, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router, T2, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router, T3, etl::timer::mode::Repeating); + etl::timer::id::type id4 = timer_controller.register_timer(message4, router, T4, etl::timer::mode::Repeating); // Start the repeating timers. timer_controller.start(id1); diff --git a/test/test_message_timer_locked.cpp b/test/test_message_timer_locked.cpp index 00dfb93a9..0e866be6e 100644 --- a/test/test_message_timer_locked.cpp +++ b/test/test_message_timer_locked.cpp @@ -184,16 +184,16 @@ namespace etl::message_timer_locked<2> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Single_Shot); CHECK(id1 != etl::timer::id::NO_TIMER); CHECK(id2 != etl::timer::id::NO_TIMER); CHECK(id3 == etl::timer::id::NO_TIMER); timer_controller.clear(); - id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::SINGLE_SHOT); + id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Single_Shot); CHECK(id3 != etl::timer::id::NO_TIMER); CHECK_EQUAL(0U, locks.lock_count); @@ -209,9 +209,9 @@ namespace etl::message_timer_locked<3> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Single_Shot); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Single_Shot); router1.clear(); @@ -252,7 +252,7 @@ namespace etl::message_timer_locked<1> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Single_Shot); router1.clear(); timer_controller.start(id1); @@ -305,9 +305,9 @@ namespace etl::message_timer_locked<3> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -348,9 +348,9 @@ namespace etl::message_timer_locked<3> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -395,9 +395,9 @@ namespace etl::message_timer_locked<3> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -450,8 +450,8 @@ namespace etl::message_timer_locked<3> timer_controller(try_lock, lock, unlock); etl::timer::id::type id1; - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -470,7 +470,7 @@ namespace { timer_controller.unregister_timer(id2); - id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); + id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); timer_controller.start(id1); } @@ -499,9 +499,9 @@ namespace etl::message_timer_locked<3> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -548,9 +548,9 @@ namespace etl::message_timer_locked<3> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(message1, bus1, 37, etl::timer::mode::SINGLE_SHOT, ROUTER1); - etl::timer::id::type id2 = timer_controller.register_timer(message2, bus1, 23, etl::timer::mode::SINGLE_SHOT, ROUTER1); - etl::timer::id::type id3 = timer_controller.register_timer(message3, bus1, 11, etl::timer::mode::SINGLE_SHOT, etl::imessage_router::ALL_MESSAGE_ROUTERS); + etl::timer::id::type id1 = timer_controller.register_timer(message1, bus1, 37, etl::timer::mode::Single_Shot, ROUTER1); + etl::timer::id::type id2 = timer_controller.register_timer(message2, bus1, 23, etl::timer::mode::Single_Shot, ROUTER1); + etl::timer::id::type id3 = timer_controller.register_timer(message3, bus1, 11, etl::timer::mode::Single_Shot, etl::imessage_router::ALL_MESSAGE_ROUTERS); bus1.subscribe(router1); @@ -593,9 +593,9 @@ namespace etl::message_timer_locked<3> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::REPEATING); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); router1.clear(); @@ -608,9 +608,9 @@ namespace ticks = 5; timer_controller.tick(uint32_t(ticks)); - timer_controller.start(id1, etl::timer::start::IMMEDIATE); - timer_controller.start(id2, etl::timer::start::IMMEDIATE); - timer_controller.start(id3, etl::timer::start::DELAYED); + timer_controller.start(id1, etl::timer::start::Immediate); + timer_controller.start(id2, etl::timer::start::Immediate); + timer_controller.start(id3, etl::timer::start::Delayed); const uint32_t step = 1UL; @@ -641,8 +641,8 @@ namespace etl::message_timer_locked<3> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 15, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 5, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 15, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 5, etl::timer::mode::Repeating); router1.clear(); @@ -680,7 +680,7 @@ namespace etl::message_timer_locked<3> timer_controller(try_lock, lock, unlock); - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 5, etl::timer::mode::SINGLE_SHOT); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 5, etl::timer::mode::Single_Shot); router1.clear(); @@ -715,6 +715,61 @@ namespace CHECK_EQUAL(0U, locks.lock_count); } + //************************************************************************* + TEST(message_timer_time_to_next) + { + locks.clear(); + try_lock_type try_lock = try_lock_type::create(); + lock_type lock = lock_type::create(); + unlock_type unlock = unlock_type::create(); + + etl::message_timer_locked<3> timer_controller(try_lock, lock, unlock); + + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::Repeating); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 23, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 11, etl::timer::mode::Repeating); + + router1.clear(); + + timer_controller.start(id1); + timer_controller.start(id3); + timer_controller.start(id2); + + timer_controller.enable(true); + + CHECK_EQUAL(11, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(4, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(8, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(1, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(5, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(2, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(2, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(6, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(10, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(3, timer_controller.time_to_next()); + + timer_controller.tick(7); + CHECK_EQUAL(4, timer_controller.time_to_next()); + } + //************************************************************************* #if REALTIME_TEST @@ -763,9 +818,9 @@ namespace { FIX_PROCESSOR_AFFINITY; - etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 400, etl::timer::mode::SINGLE_SHOT); - etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 100, etl::timer::mode::REPEATING); - etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 10, etl::timer::mode::REPEATING); + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 400, etl::timer::mode::Single_Shot); + etl::timer::id::type id2 = timer_controller.register_timer(message2, router1, 100, etl::timer::mode::Repeating); + etl::timer::id::type id3 = timer_controller.register_timer(message3, router1, 10, etl::timer::mode::Repeating); router1.clear(); diff --git a/test/test_multi_span.cpp b/test/test_multi_span.cpp index a327ff861..d59c8d758 100644 --- a/test/test_multi_span.cpp +++ b/test/test_multi_span.cpp @@ -33,6 +33,7 @@ SOFTWARE. #include #include +#include namespace { @@ -46,6 +47,14 @@ namespace int data7[1]; int data8[2]; + struct Data + { + int i; + }; + + Data struct_data1[] = {Data{1}, Data{2}, Data{3}}; + Data struct_data2[] = {Data{4}, Data{5}, Data{6}}; + SUITE(test_multi_span) { //************************************************************************* @@ -140,5 +149,30 @@ namespace std::copy(expected.begin(), expected.end(), ms_int.begin()); CHECK(std::equal(expected.begin(), expected.end(), ms_int.begin())); } + + //************************************************************************* + TEST(test_member_pointer_operator) + { + std::vector> span_list = + { + etl::span(struct_data1), + etl::span(struct_data2) + }; + + etl::multi_span ms_data(etl::multi_span::span_list_type(std::begin(span_list), std::end(span_list))); + + etl::multi_span::iterator itr = ms_data.begin(); + CHECK_EQUAL(struct_data1[0].i, itr->i); + ++itr; + CHECK_EQUAL(struct_data1[1].i, itr->i); + ++itr; + CHECK_EQUAL(struct_data1[2].i, itr->i); + ++itr; + CHECK_EQUAL(struct_data2[0].i, itr->i); + ++itr; + CHECK_EQUAL(struct_data2[1].i, itr->i); + ++itr; + CHECK_EQUAL(struct_data2[2].i, itr->i); + } }; } diff --git a/test/test_multi_vector.cpp b/test/test_multi_vector.cpp index 560bf3e27..05efd8d4c 100644 --- a/test/test_multi_vector.cpp +++ b/test/test_multi_vector.cpp @@ -64,7 +64,7 @@ namespace Compare_Data compare_data = { { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 }, { 9, 10, 11 } } }; - SUITE(test_vector) + SUITE(test_multi_vector_external_buffer) { //************************************************************************* TEST(test_constructor) diff --git a/test/test_multimap.cpp b/test/test_multimap.cpp index c44ffb1c8..9e91d2e49 100644 --- a/test/test_multimap.cpp +++ b/test/test_multimap.cpp @@ -388,6 +388,7 @@ namespace data1.insert(DataM::value_type(std::string("3"), etl::move(d3))); data1.insert(DataM::value_type(std::string("4"), ItemM(4))); + data2.insert(DataM::value_type(std::string("5"), ItemM(5))); data2 = std::move(data1); CHECK(1 == data2.find("1")->second.value); diff --git a/test/test_multiset.cpp b/test/test_multiset.cpp index 7d197cdeb..f966a696d 100644 --- a/test/test_multiset.cpp +++ b/test/test_multiset.cpp @@ -391,6 +391,7 @@ namespace data1.insert(ItemM(4)); DataM data2; + data2.insert(ItemM(5)); data2 = std::move(data1); diff --git a/test/test_optional.cpp b/test/test_optional.cpp index 6f2382297..71f15915a 100644 --- a/test/test_optional.cpp +++ b/test/test_optional.cpp @@ -125,6 +125,16 @@ namespace CHECK_EQUAL(1, DataM::get_instance_count()); } + //************************************************************************* + TEST(test_emplace_zero_parameters) + { + etl::optional result = 1; + result.emplace(); + + CHECK_TRUE(result.has_value()); + CHECK_EQUAL(int(0), int(result.value())); + } + //************************************************************************* TEST(test_moveable) { @@ -503,6 +513,7 @@ namespace return result; } + //************************************************************************* TEST(test_bug_634) { etl::optional result; @@ -587,6 +598,37 @@ namespace CHECK_EQUAL(42, opt->value); } + +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_optional_cannot_be_constexpr_765_pod) + { + constexpr etl::optional opt(42); + + CHECK_EQUAL(42, *opt); + } +#endif + +#if ETL_USING_CPP20 && ETL_USING_STL + //************************************************************************* + TEST(test_optional_cannot_be_constexpr_765_non_pod) + { + struct NonPod + { + constexpr NonPod(int v_) + : v(v_) + { + } + + int v; + }; + + constexpr NonPod data(42); + constexpr etl::optional opt = data; + + CHECK_EQUAL(42, (*opt).v); + } +#endif }; } diff --git a/test/test_overload.cpp b/test/test_overload.cpp index baef8b9fd..68da87dbe 100644 --- a/test/test_overload.cpp +++ b/test/test_overload.cpp @@ -30,7 +30,7 @@ SOFTWARE. #include "etl/overload.h" -#if ETL_USING_CPP17 +#if ETL_USING_CPP11 #include @@ -100,6 +100,7 @@ namespace CHECK(result.bs == true); } +#if ETL_USING_CPP_17 //************************************************************************* TEST(test_overload_lambdas_initializer_list) { @@ -136,6 +137,7 @@ namespace CHECK(result.bd == false); CHECK(result.bs == true); } +#endif //************************************************************************* TEST(test_visitor_overload) diff --git a/test/test_pool.cpp b/test/test_pool.cpp index 4f3750767..10fd4cbd3 100644 --- a/test/test_pool.cpp +++ b/test/test_pool.cpp @@ -199,6 +199,9 @@ namespace CHECK_EQUAL(4U, pool.available()); + CHECK_THROW(pool.release(p4), etl::pool_no_allocation); + CHECK_EQUAL(4U, pool.available()); + Test_Data not_in_pool; CHECK_THROW(pool.release(¬_in_pool), etl::pool_object_not_in_pool); diff --git a/test/test_pool_external_buffer.cpp b/test/test_pool_external_buffer.cpp index 70a5f0cbf..9723abe3f 100644 --- a/test/test_pool_external_buffer.cpp +++ b/test/test_pool_external_buffer.cpp @@ -205,6 +205,9 @@ namespace CHECK_EQUAL(4U, pool.available()); + CHECK_THROW(pool.release(p4), etl::pool_no_allocation); + CHECK_EQUAL(4U, pool.available()); + Test_Data not_in_pool; CHECK_THROW(pool.release(¬_in_pool), etl::pool_object_not_in_pool); diff --git a/test/test_priority_queue.cpp b/test/test_priority_queue.cpp index 997b99f69..8cc2c3171 100644 --- a/test/test_priority_queue.cpp +++ b/test/test_priority_queue.cpp @@ -42,10 +42,17 @@ namespace struct Item { + Item() + : c('a') + , i(1) + , d(1.2) + { + } + Item(char c_, int i_, double d_) - : c(c_), - i(i_), - d(d_) + : c(c_) + , i(i_) + , d(d_) { } @@ -344,9 +351,12 @@ namespace //************************************************************************* TEST(test_emplace) { - etl::priority_queue priority_queue; + etl::priority_queue priority_queue; std::priority_queue compare_priority_queue; + priority_queue.emplace(); + compare_priority_queue.emplace(); + priority_queue.emplace('d', 4, 7.8); compare_priority_queue.emplace('d', 4, 7.8); @@ -517,6 +527,7 @@ namespace priority_queue.push(std::move(b)); etl::priority_queue priority_queue2; + priority_queue2.push(ItemM("E")); priority_queue2 = std::move(priority_queue); diff --git a/test/test_queue.cpp b/test/test_queue.cpp index cf1c40985..a4f12913a 100644 --- a/test/test_queue.cpp +++ b/test/test_queue.cpp @@ -37,10 +37,17 @@ namespace { struct Item { + Item() + : c('a') + , i(1) + , d(1.2) + { + } + Item(char c_, int i_, double d_) - : c(c_), - i(i_), - d(d_) + : c(c_) + , i(i_) + , d(d_) { } @@ -357,20 +364,23 @@ namespace //************************************************************************* TEST(test_multiple_emplace) { - etl::queue queue; + etl::queue queue; - queue.emplace('a', 1, 1.2); - queue.emplace('b', 2, 3.4); - queue.emplace('c', 3, 5.6); - queue.emplace('d', 4, 7.8); + queue.emplace(); + queue.emplace('b', 2, 2.3); + queue.emplace('c', 3, 3.4); + queue.emplace('d', 4, 4.5); + queue.emplace('e', 5, 5.6); CHECK(queue.front() == Item('a', 1, 1.2)); queue.pop(); - CHECK(queue.front() == Item('b', 2, 3.4)); + CHECK(queue.front() == Item('b', 2, 2.3)); + queue.pop(); + CHECK(queue.front() == Item('c', 3, 3.4)); queue.pop(); - CHECK(queue.front() == Item('c', 3, 5.6)); + CHECK(queue.front() == Item('d', 4, 4.5)); queue.pop(); - CHECK(queue.front() == Item('d', 4, 7.8)); + CHECK(queue.front() == Item('e', 5, 5.6)); queue.pop(); } diff --git a/test/test_queue_lockable.cpp b/test/test_queue_lockable.cpp index 41036c1a3..2bebeb096 100644 --- a/test/test_queue_lockable.cpp +++ b/test/test_queue_lockable.cpp @@ -552,10 +552,10 @@ namespace { QueueData queue; + queue.emplace(); queue.emplace(1); queue.emplace(1, 2); queue.emplace(1, 2, 3); - queue.emplace(1, 2, 3, 4); CHECK(queue.called_lock); CHECK(queue.called_unlock); @@ -564,7 +564,7 @@ namespace Data popped; queue.pop(popped); - CHECK(popped == Data(1, 2, 3, 4)); + CHECK(popped == Data(0, 0, 0, 0)); queue.pop(popped); CHECK(popped == Data(1, 2, 3, 4)); queue.pop(popped); diff --git a/test/test_queue_lockable_small.cpp b/test/test_queue_lockable_small.cpp index eed329d77..c1bf69b22 100644 --- a/test/test_queue_lockable_small.cpp +++ b/test/test_queue_lockable_small.cpp @@ -108,7 +108,7 @@ namespace }; //*********************************** - class QueueData : public etl::queue_lockable + class QueueData : public etl::queue_lockable { public: @@ -552,15 +552,20 @@ namespace { QueueData queue; + queue.emplace(); queue.emplace(1); queue.emplace(1, 2); queue.emplace(1, 2, 3); queue.emplace(1, 2, 3, 4); - CHECK_EQUAL(4U, queue.size()); + CHECK(queue.called_lock); + CHECK(queue.called_unlock); + CHECK_EQUAL(5U, queue.size()); Data popped; + queue.pop(popped); + CHECK(popped == Data(0, 0, 0, 0)); queue.pop(popped); CHECK(popped == Data(1, 2, 3, 4)); queue.pop(popped); diff --git a/test/test_queue_memory_model_small.cpp b/test/test_queue_memory_model_small.cpp index 0613d129c..274312c5b 100644 --- a/test/test_queue_memory_model_small.cpp +++ b/test/test_queue_memory_model_small.cpp @@ -36,6 +36,13 @@ namespace { struct Item { + Item() + : c('a') + , i(1) + , d(1.2) + { + } + Item(char c_, int i_, double d_) : c(c_), i(i_), @@ -342,22 +349,23 @@ namespace //************************************************************************* TEST(test_multiple_emplace) { - etl::queue queue; + etl::queue queue; - queue.emplace('a', 1, 1.2); - queue.emplace('b', 2, 3.4); - queue.emplace('c', 3, 5.6); - queue.emplace('d', 4, 7.8); - - CHECK_EQUAL(4U, queue.size()); + queue.emplace(); + queue.emplace('b', 2, 2.3); + queue.emplace('c', 3, 3.4); + queue.emplace('d', 4, 4.5); + queue.emplace('e', 5, 5.6); CHECK(queue.front() == Item('a', 1, 1.2)); queue.pop(); - CHECK(queue.front() == Item('b', 2, 3.4)); + CHECK(queue.front() == Item('b', 2, 2.3)); + queue.pop(); + CHECK(queue.front() == Item('c', 3, 3.4)); queue.pop(); - CHECK(queue.front() == Item('c', 3, 5.6)); + CHECK(queue.front() == Item('d', 4, 4.5)); queue.pop(); - CHECK(queue.front() == Item('d', 4, 7.8)); + CHECK(queue.front() == Item('e', 5, 5.6)); queue.pop(); } diff --git a/test/test_queue_mpmc_mutex.cpp b/test/test_queue_mpmc_mutex.cpp index 3eec5d974..cdb6e6c1b 100644 --- a/test/test_queue_mpmc_mutex.cpp +++ b/test/test_queue_mpmc_mutex.cpp @@ -193,17 +193,20 @@ namespace //************************************************************************* TEST(test_multiple_emplace) { - etl::queue_mpmc_mutex queue; + etl::queue_mpmc_mutex queue; + queue.emplace(); queue.emplace(1); queue.emplace(1, 2); queue.emplace(1, 2, 3); queue.emplace(1, 2, 3, 4); - CHECK_EQUAL(4U, queue.size()); + CHECK_EQUAL(5U, queue.size()); Data popped; + queue.pop(popped); + CHECK(popped == Data(0, 0, 0, 0)); queue.pop(popped); CHECK(popped == Data(1, 2, 3, 4)); queue.pop(popped); diff --git a/test/test_queue_mpmc_mutex_small.cpp b/test/test_queue_mpmc_mutex_small.cpp index 19c6300c5..7abf00fcf 100644 --- a/test/test_queue_mpmc_mutex_small.cpp +++ b/test/test_queue_mpmc_mutex_small.cpp @@ -205,17 +205,20 @@ namespace //************************************************************************* TEST(test_multiple_emplace) { - etl::queue_mpmc_mutex queue; + etl::queue_mpmc_mutex queue; + queue.emplace(); queue.emplace(1); queue.emplace(1, 2); queue.emplace(1, 2, 3); queue.emplace(1, 2, 3, 4); - Data popped; + CHECK_EQUAL(5U, queue.size()); - CHECK_EQUAL(4U, queue.size()); + Data popped; + queue.pop(popped); + CHECK(popped == Data(0, 0, 0, 0)); queue.pop(popped); CHECK(popped == Data(1, 2, 3, 4)); queue.pop(popped); diff --git a/test/test_queue_spsc_atomic.cpp b/test/test_queue_spsc_atomic.cpp index 6b53cabfb..232249e1a 100644 --- a/test/test_queue_spsc_atomic.cpp +++ b/test/test_queue_spsc_atomic.cpp @@ -312,17 +312,20 @@ namespace //************************************************************************* TEST(test_multiple_emplace) { - etl::queue_spsc_atomic queue; + etl::queue_spsc_atomic queue; + queue.emplace(); queue.emplace(1); queue.emplace(1, 2); queue.emplace(1, 2, 3); queue.emplace(1, 2, 3, 4); - CHECK_EQUAL(4U, queue.size()); + CHECK_EQUAL(5U, queue.size()); Data popped; + queue.pop(popped); + CHECK(popped == Data(0, 0, 0, 0)); queue.pop(popped); CHECK(popped == Data(1, 2, 3, 4)); queue.pop(popped); diff --git a/test/test_queue_spsc_atomic_small.cpp b/test/test_queue_spsc_atomic_small.cpp index ddbcf0cb8..f1ed6fbca 100644 --- a/test/test_queue_spsc_atomic_small.cpp +++ b/test/test_queue_spsc_atomic_small.cpp @@ -330,17 +330,20 @@ namespace //************************************************************************* TEST(test_multiple_emplace) { - etl::queue_spsc_atomic queue; + etl::queue_spsc_atomic queue; + queue.emplace(); queue.emplace(1); queue.emplace(1, 2); queue.emplace(1, 2, 3); queue.emplace(1, 2, 3, 4); - CHECK_EQUAL(4U, queue.size()); + CHECK_EQUAL(5U, queue.size()); Data popped; + queue.pop(popped); + CHECK(popped == Data(0, 0, 0, 0)); queue.pop(popped); CHECK(popped == Data(1, 2, 3, 4)); queue.pop(popped); diff --git a/test/test_queue_spsc_isr.cpp b/test/test_queue_spsc_isr.cpp index 5b79df4ec..2d80f4db5 100644 --- a/test/test_queue_spsc_isr.cpp +++ b/test/test_queue_spsc_isr.cpp @@ -74,18 +74,18 @@ namespace struct Data { Data(int a_, int b_ = 2, int c_ = 3, int d_ = 4) - : a(a_), - b(b_), - c(c_), - d(d_) + : a(a_) + , b(b_) + , c(c_) + , d(d_) { } Data() - : a(0), - b(0), - c(0), - d(0) + : a(0) + , b(0) + , c(0) + , d(0) { } @@ -496,17 +496,20 @@ namespace //************************************************************************* TEST(test_multiple_emplace) { - etl::queue_spsc_isr queue; + etl::queue_spsc_isr queue; + queue.emplace(); queue.emplace(1); queue.emplace(1, 2); queue.emplace(1, 2, 3); queue.emplace(1, 2, 3, 4); - CHECK_EQUAL(4U, queue.size()); + CHECK_EQUAL(5U, queue.size()); Data popped; + queue.pop(popped); + CHECK(popped == Data(0, 0, 0, 0)); queue.pop(popped); CHECK(popped == Data(1, 2, 3, 4)); queue.pop(popped); diff --git a/test/test_queue_spsc_isr_small.cpp b/test/test_queue_spsc_isr_small.cpp index d3b501099..b55f3cd55 100644 --- a/test/test_queue_spsc_isr_small.cpp +++ b/test/test_queue_spsc_isr_small.cpp @@ -74,18 +74,18 @@ namespace struct Data { Data(int a_, int b_ = 2, int c_ = 3, int d_ = 4) - : a(a_), - b(b_), - c(c_), - d(d_) + : a(a_) + , b(b_) + , c(c_) + , d(d_) { } Data() - : a(0), - b(0), - c(0), - d(0) + : a(0) + , b(0) + , c(0) + , d(0) { } @@ -514,17 +514,20 @@ namespace //************************************************************************* TEST(test_multiple_emplace) { - etl::queue_spsc_isr queue; + etl::queue_spsc_isr queue; + queue.emplace(); queue.emplace(1); queue.emplace(1, 2); queue.emplace(1, 2, 3); queue.emplace(1, 2, 3, 4); - CHECK_EQUAL(4U, queue.size()); + CHECK_EQUAL(5U, queue.size()); Data popped; + queue.pop(popped); + CHECK(popped == Data(0, 0, 0, 0)); queue.pop(popped); CHECK(popped == Data(1, 2, 3, 4)); queue.pop(popped); diff --git a/test/test_queue_spsc_locked.cpp b/test/test_queue_spsc_locked.cpp index b5f079449..993e5e786 100644 --- a/test/test_queue_spsc_locked.cpp +++ b/test/test_queue_spsc_locked.cpp @@ -77,18 +77,18 @@ namespace struct Data { Data(int a_, int b_ = 2, int c_ = 3, int d_ = 4) - : a(a_), - b(b_), - c(c_), - d(d_) + : a(a_) + , b(b_) + , c(c_) + , d(d_) { } Data() - : a(0), - b(0), - c(0), - d(0) + : a(0) + , b(0) + , c(0) + , d(0) { } @@ -501,17 +501,20 @@ namespace //************************************************************************* TEST(test_multiple_emplace) { - etl::queue_spsc_locked queue(lock, unlock); + etl::queue_spsc_locked queue(lock, unlock); + queue.emplace(); queue.emplace(1); queue.emplace(1, 2); queue.emplace(1, 2, 3); queue.emplace(1, 2, 3, 4); - CHECK_EQUAL(4U, queue.size()); + CHECK_EQUAL(5U, queue.size()); Data popped; + queue.pop(popped); + CHECK(popped == Data(0, 0, 0, 0)); queue.pop(popped); CHECK(popped == Data(1, 2, 3, 4)); queue.pop(popped); diff --git a/test/test_queue_spsc_locked_small.cpp b/test/test_queue_spsc_locked_small.cpp index 7d1a32bff..644f0a81a 100644 --- a/test/test_queue_spsc_locked_small.cpp +++ b/test/test_queue_spsc_locked_small.cpp @@ -518,17 +518,20 @@ namespace //************************************************************************* TEST(test_multiple_emplace) { - etl::queue_spsc_locked queue(lock, unlock); + etl::queue_spsc_locked queue(lock, unlock); + queue.emplace(); queue.emplace(1); queue.emplace(1, 2); queue.emplace(1, 2, 3); queue.emplace(1, 2, 3, 4); - CHECK_EQUAL(4U, queue.size()); + CHECK_EQUAL(5U, queue.size()); Data popped; + queue.pop(popped); + CHECK(popped == Data(0, 0, 0, 0)); queue.pop(popped); CHECK(popped == Data(1, 2, 3, 4)); queue.pop(popped); diff --git a/test/test_set.cpp b/test/test_set.cpp index 752d6e13e..aa25fc2a6 100644 --- a/test/test_set.cpp +++ b/test/test_set.cpp @@ -356,6 +356,7 @@ namespace data1.insert(ItemM(4)); DataM data2; + data2.insert(ItemM(5)); data2 = std::move(data1); diff --git a/test/test_span_dynamic_extent.cpp b/test/test_span_dynamic_extent.cpp index fae9b9621..d9bce00b7 100644 --- a/test/test_span_dynamic_extent.cpp +++ b/test/test_span_dynamic_extent.cpp @@ -35,6 +35,9 @@ SOFTWARE. #include #include #include +#if ETL_USING_CPP20 + #include +#endif namespace { @@ -49,6 +52,10 @@ namespace using View = etl::span; using CView = etl::span; +#if ETL_USING_CPP20 + using StdView = std::span; +#endif + EtlData etldata = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; StlData stldata = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; StlVData stlvdata = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; @@ -78,6 +85,21 @@ namespace CHECK(view.empty()); } +#if ETL_USING_CPP20 + //************************************************************************* + TEST(test_construct_from_std_span) + { + StdView stdview(stldata); + View view(stdview); + + CHECK_EQUAL(stdview.size(), view.size()); + CHECK_EQUAL(stdview.size(), view.size()); + + bool isEqual = std::equal(view.begin(), view.end(), stdview.begin()); + CHECK(isEqual); + } +#endif + //************************************************************************* TEST(test_constructor_etl_array_1) { diff --git a/test/test_span_fixed_extent.cpp b/test/test_span_fixed_extent.cpp index a4307e69d..001086bb2 100644 --- a/test/test_span_fixed_extent.cpp +++ b/test/test_span_fixed_extent.cpp @@ -35,6 +35,9 @@ SOFTWARE. #include #include #include +#if ETL_USING_CPP20 + #include +#endif namespace { @@ -50,6 +53,10 @@ namespace typedef etl::span SView; typedef etl::span CView; +#if ETL_USING_CPP20 + using StdView = std::span; +#endif + EtlData etldata = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; StlData stldata = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; StlVData stlvdata = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; @@ -79,6 +86,21 @@ namespace CHECK(!view.empty()); } +#if ETL_USING_CPP20 + //************************************************************************* + TEST(test_construct_from_std_span) + { + StdView stdview(stldata); + View view(stdview); + + CHECK_EQUAL(stdview.size(), view.size()); + CHECK_EQUAL(stdview.size(), view.size()); + + bool isEqual = std::equal(view.begin(), view.end(), stdview.begin()); + CHECK(isEqual); + } +#endif + //************************************************************************* TEST(test_constructor_etl_array_1) { diff --git a/test/test_stack.cpp b/test/test_stack.cpp index 6fa704cc0..3468b680c 100644 --- a/test/test_stack.cpp +++ b/test/test_stack.cpp @@ -38,10 +38,17 @@ namespace { struct Item { + Item() + : c('a') + , i(1) + , d(1.2) + { + } + Item(char c_, int i_, double d_) - : c(c_), - i(i_), - d(d_) + : c(c_) + , i(i_) + , d(d_) { } @@ -219,25 +226,30 @@ namespace //************************************************************************* TEST(test_emplace) { - etl::stack stack; + etl::stack stack; - stack.emplace('a', 1, 1.2); + stack.emplace(); CHECK_EQUAL(1U, stack.size()); - stack.emplace('b', 2, 3.4); + stack.emplace('b', 2, 2.3); CHECK_EQUAL(2U, stack.size()); - stack.emplace('c', 3, 5.6); + stack.emplace('c', 3, 3.4); CHECK_EQUAL(3U, stack.size()); - stack.emplace('d', 4, 7.8); + stack.emplace('d', 4, 4.5); CHECK_EQUAL(4U, stack.size()); - CHECK(stack.top() == Item('d', 4, 7.8)); + stack.emplace('e', 5, 5.6); + CHECK_EQUAL(5U, stack.size()); + + CHECK(stack.top() == Item('e', 5, 5.6)); + stack.pop(); + CHECK(stack.top() == Item('d', 4, 4.5)); stack.pop(); - CHECK(stack.top() == Item('c', 3, 5.6)); + CHECK(stack.top() == Item('c', 3, 3.4)); stack.pop(); - CHECK(stack.top() == Item('b', 2, 3.4)); + CHECK(stack.top() == Item('b', 2, 2.3)); stack.pop(); CHECK(stack.top() == Item('a', 1, 1.2)); } diff --git a/test/test_static_assert.cpp b/test/test_static_assert.cpp new file mode 100644 index 000000000..8e4d7d75c --- /dev/null +++ b/test/test_static_assert.cpp @@ -0,0 +1,21 @@ +#include "unit_test_framework.h" + +#include "etl/static_assert.h" + +namespace +{ + SUITE(test_static_assert) + { + //************************************************************************* + TEST(test_static_assert_2arguments) + { + ETL_STATIC_ASSERT(true, "condition must be true"); + } + + //************************************************************************* + TEST(test_static_assert_1argument) + { + ETL_STATIC_ASSERT(true); + } + } +} diff --git a/test/test_string_char.cpp b/test/test_string_char.cpp index 7cb2c4748..fd7b2f163 100644 --- a/test/test_string_char.cpp +++ b/test/test_string_char.cpp @@ -753,6 +753,22 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_fill) + { + Text text(SIZE, STR('A')); + Text expected(SIZE, STR('B')); + + text.fill(STR('B')); + + bool is_equal = Equal(expected, text); + CHECK(is_equal); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty_full) { diff --git a/test/test_string_u16.cpp b/test/test_string_u16.cpp index 6b229c35c..6a848b187 100644 --- a/test/test_string_u16.cpp +++ b/test/test_string_u16.cpp @@ -768,6 +768,22 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_fill) + { + Text text(SIZE, STR('A')); + Text expected(SIZE, STR('B')); + + text.fill(STR('B')); + + bool is_equal = Equal(expected, text); + CHECK(is_equal); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty_full) { diff --git a/test/test_string_u16_external_buffer.cpp b/test/test_string_u16_external_buffer.cpp index eb813b4b2..a23724303 100644 --- a/test/test_string_u16_external_buffer.cpp +++ b/test/test_string_u16_external_buffer.cpp @@ -40,14 +40,14 @@ SOFTWARE. namespace { - //bool compares_agree(int result1, int result2) - //{ - // return ((result1 < 0) && (result2 < 0)) || - // ((result1 == 0) && (result2 == 0)) || - // ((result1 > 0) && (result2 > 0)); - //} + bool compares_agree(int result1, int result2) + { + return ((result1 < 0) && (result2 < 0)) || + ((result1 == 0) && (result2 == 0)) || + ((result1 > 0) && (result2 > 0)); + } - //*********************************** + ////*********************************** //std::ostream& operator << (std::ostream& os, const etl::iu16string::value_type& c) //{ // os << uint16_t(c); @@ -55,7 +55,7 @@ namespace // return os; //} - //*********************************** + ////*********************************** //std::ostream& operator << (std::ostream& os, const etl::iu16string::value_type* c) //{ // os << (void*)c; @@ -90,7 +90,7 @@ namespace const value_t* pinitial_text = STR("Hello World"); value_t array_text[12]; - //value_t* p_text = array_text; + value_t* p_text = array_text; //************************************************************************* template @@ -117,4720 +117,4738 @@ namespace } }; -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_default_constructor) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// -// CHECK_EQUAL(text.size(), size_t(0)); -// CHECK(text.empty()); -// CHECK_EQUAL(SIZE, text.capacity()); -// CHECK_EQUAL(SIZE, text.max_size()); -// CHECK(text.begin() == text.end()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_default_constructor_use_buffer_and_size) -// { -// size_t length = etl::strlen(p_text); -// Text text(p_text, length + 1); -// -// CHECK_EQUAL(0U, text.size()); -// CHECK(text.empty()); -// CHECK_EQUAL(length, text.capacity()); -// CHECK_EQUAL(length, text.max_size()); -// CHECK(text.begin() == text.end()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_default_constructor_use_buffer_text_and_size) -// { -// Text text(p_text, p_text, etl::strlen(p_text) + 1); -// -// CHECK_EQUAL(text.size(), etl::strlen(p_text)); -// CHECK(!text.empty()); -// CHECK_EQUAL(etl::strlen(p_text), text.capacity()); -// CHECK_EQUAL(etl::strlen(p_text), text.max_size()); -// CHECK(text.begin() != text.end()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_default_constructor_use_array_buffer) -// { -// Text text(array_text, ETL_OR_STD17::size(array_text)); -// -// CHECK_EQUAL(0U, text.size()); -// CHECK(text.empty()); -// CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.capacity()); -// CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.max_size()); -// CHECK(text.begin() == text.end()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_default_constructor_use_array_buffer_text) -// { -// Text text(array_text, array_text, ETL_OR_STD17::size(array_text)); -// -// CHECK_EQUAL(text.size(), etl::strlen(array_text)); -// CHECK(!text.empty()); -// CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.capacity()); -// CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.max_size()); -// CHECK(text.begin() != text.end()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST(test_iterator_comparison_empty) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// -// CHECK(text.begin() == text.end()); -// CHECK(text.cbegin() == text.cend()); -// CHECK(text.rbegin() == text.rend()); -// CHECK(text.crbegin() == text.crend()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_constructor_size_value) -// { -// const size_t INITIAL_SIZE = 5; -// const value_t INITIAL_VALUE = STR('A'); -// TextBuffer buffer{0}; -// -// Compare_Text compare_text(INITIAL_SIZE, INITIAL_VALUE); -// Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size()); -// -// CHECK(text.size() == INITIAL_SIZE); -// CHECK(!text.empty()); -// -// bool is_equal = Equal(compare_text, text); -// -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_constructor_size_excess) -// { -// TextBuffer buffer{0}; -// Text text(buffer.size() + 1, STR('A'), buffer.data(), buffer.size()); -// -// CHECK_EQUAL(buffer.size() - 1, text.size()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_constructor_char_pointer) -// { -// TextBuffer buffer{0}; -// Compare_Text compare_text(initial_text.c_str()); -// -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// CHECK(!text.empty()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_excess) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(longer_text.c_str(), buffer.data(), buffer.size()); -// -// CHECK(!text.empty()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size) -// { -// Compare_Text compare_text(SIZE, STR('A')); -// -// TextBuffer buffer{0}; -// Text text(SIZE, STR('A'), buffer.data(), buffer.size()); -// -// CHECK(!text.empty()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size_excess) -// { -// Compare_Text compare_text(SIZE, STR('A')); -// -// TextBuffer buffer{0}; -// Text text(SIZE + 1, STR('A'), buffer.data(), buffer.size()); -// -// CHECK(!text.empty()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_constructor_size_char) -// { -// Compare_Text compare_text(initial_text.c_str(), initial_text.size() / 2); -// -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), initial_text.size() / 2, buffer.data(), buffer.size()); -// -// CHECK(!text.empty()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_constructor_size_char_excess) -// { -// Compare_Text compare_text(initial_text.c_str(), initial_text.size()); -// -// TextBuffer buffer{0}; -// Text text(longer_text.c_str(), longer_text.size(), buffer.data(), buffer.size()); -// -// CHECK(!text.empty()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_constructor_range) -// { -// Compare_Text compare_text(initial_text.begin(), initial_text.end()); -// -// TextBuffer buffer{0}; -// Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); -// -// CHECK(text.size() == SIZE); -// CHECK(!text.empty()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_constructor_range_excess) -// { -// TextBuffer buffer{0}; -// Text text(longer_text.begin(), longer_text.end(), buffer.data(), buffer.size()); -// -// bool is_equal = Equal(initial_text, text); -// CHECK(is_equal); -// CHECK(text.size() == SIZE); -// CHECK(!text.empty()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_constructor_from_literal) -// { -// TextBuffer buffer{0}; -// Text text(STR("Hello World"), buffer.data(), buffer.size()); -// -// bool is_equal = Equal(initial_text, text); -// CHECK(is_equal); -// CHECK(text.size() == SIZE); -// CHECK(!text.empty()); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_constructor_from_string_view) -// { -// etl::u16string_view view(initial_text.data(), initial_text.size()); -// -// TextBuffer buffer{0}; -// Text text(view, buffer.data(), buffer.size()); -// -// bool is_equal = Equal(initial_text, text); -// CHECK(is_equal); -// CHECK(text.size() == SIZE); -// CHECK(!text.empty()); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_copy_constructor) -// { -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// Text text2(text, buffer2.data(), buffer2.size()); -// CHECK(text2 == text); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text2.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_copy_constructor_i) -// { -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// IText& itext = text; -// -// TextBuffer buffer2{0}; -// Text text2(itext, buffer2.data(), buffer2.size()); -// CHECK(text2 == text); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text2.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_copy_constructor_excess) -// { -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// TextBufferL bufferl{0}; -// Text textl(longer_text.c_str(), bufferl.data(), bufferl.size()); -// -// TextBuffer buffer2{0}; -// Text text2(textl, buffer2.data(), buffer2.size()); -// CHECK(text2 == text); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text2.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_copy_constructor_from_truncated) -// { -// TextBuffer buffer{0}; -// Text text(longer_text.c_str(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// Text text2(text, buffer2.data(), buffer2.size()); -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text2.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_construct_position_length) -// { -// Compare_Text compare_text(initial_text.c_str()); -// Compare_Text compare_text2(compare_text, 2, 4); -// -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// Text text2(text, buffer2.data(), buffer2.size(), 2, 4); -// -// bool is_equal = Equal(compare_text2, text2); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text2.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_construct_position_length_excess) -// { -// Compare_Text compare_text(longer_text.c_str()); -// Compare_Text compare_text2(compare_text, 2, 11); -// -// TextBufferL bufferl{0}; -// Text textl(longer_text.c_str(), bufferl.data(), bufferl.size()); -// -// TextBuffer buffer{0}; -// Text text2(textl, buffer.data(), buffer.size(), 2, 12); -// -// bool is_equal = Equal(compare_text2, text2); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text2.is_truncated()); -//#endif -// } -// -//#if ETL_HAS_INITIALIZER_LIST -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_construct_initializer_list) -// { -// Compare_Text compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; -// -// std::initializer_list il = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; -// TextBuffer buffer{0}; -// Text text(il, buffer.data(), buffer.size()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_construct_initializer_list_excess) -// { -// Compare_Text compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), -// STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; -// -// std::initializer_list il = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), -// STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), -// STR('T'), STR('h'), STR('e'), STR('r'), STR('e') }; -// TextBuffer buffer{0}; -// Text text(il, buffer.data(), buffer.size()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -//#endif -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_assignment) -// { -// TextBuffer buffer{0}; -// Text text(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// Text other_text(buffer2.data(), buffer2.size()); -// -// other_text = text; -// -// bool is_equal = Equal(text, other_text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -// CHECK(!other_text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_assignment_excess) -// { -// TextBuffer buffer{0}; -// Text text(longer_text.begin(), longer_text.end(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// Text other_text(buffer2.data(), buffer2.size()); -// -// other_text = text; -// -// bool is_equal = Equal(text, other_text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -// CHECK(other_text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_assignment_iterface) -// { -// TextBuffer buffer{0}; -// Text text1(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// Text text2(buffer2.data(), buffer2.size()); -// -// IText& itext1 = text1; -// IText& itext2 = text2; -// -// itext2 = itext1; -// -// bool is_equal = Equal(text1, text2); -// -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text1.is_truncated()); -// CHECK(!text2.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_assignment_iterface_excess) -// { -// TextBuffer buffer{0}; -// Text text1(longer_text.begin(), longer_text.end(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// Text text2(buffer2.data(), buffer2.size()); -// -// IText& itext1 = text1; -// IText& itext2 = text2; -// -// itext2 = itext1; -// -// bool is_equal = Equal(text1, text2); -// -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text1.is_truncated()); -// CHECK(text2.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_self_assignment) -// { -// TextBuffer buffer{0}; -// Text text(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// Text other_text(text, buffer2.data(), buffer2.size()); -// -//#include "etl/private/diagnostic_self_assign_overloaded_push.h" -// other_text = other_text; -//#include "etl/private/diagnostic_pop.h" -// -// bool is_equal = Equal(text, other_text); -// -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -// CHECK(!other_text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_self_assignment_excess) -// { -// TextBuffer buffer{0}; -// Text text(longer_text.begin(), longer_text.end(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// Text other_text(text, buffer2.data(), buffer2.size()); -// -//#include "etl/private/diagnostic_self_assign_overloaded_push.h" -// other_text = other_text; -//#include "etl/private/diagnostic_pop.h" -// -// bool is_equal = Equal(text, other_text); -// -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -// CHECK(other_text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_assignment_from_literal) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// -// text = STR("Hello World"); -// -// bool is_equal = Equal(std::u16string(STR("Hello World")), text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_assignment_from_literal_excess) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// -// text = STR("Hello World There"); -// -// bool is_equal = Equal(std::u16string(STR("Hello World")), text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_assignment_from_literal_via_interface) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// IText& itext = text; -// -// itext = STR("Hello World"); -// -// bool is_equal = Equal(std::u16string(STR("Hello World")), itext); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!itext.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_assignment_from_literal_via_interface_excess) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// IText& itext = text; -// -// itext = STR("Hello World There"); -// -// bool is_equal = Equal(std::u16string(STR("Hello World")), itext); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(itext.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_begin) -// { -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// const Text constText(initial_text.c_str(), buffer2.data(), buffer2.size()); -// -// CHECK_EQUAL(&text[0], text.begin()); -// CHECK_EQUAL(&constText[0], constText.begin()); -// } -// -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_end) -// { -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// const Text constText(initial_text.c_str(), buffer2.data(), buffer2.size()); -// -// CHECK_EQUAL(&text[initial_text.size()], text.end()); -// CHECK_EQUAL(&constText[initial_text.size()], constText.end()); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_resize_up) -// { -// const size_t INITIAL_SIZE = 5; -// const size_t NEW_SIZE = 8; -// -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), INITIAL_SIZE, buffer.data(), buffer.size()); -// text.resize(NEW_SIZE); -// -// CHECK_EQUAL(text.size(), NEW_SIZE); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_resize_up_value) -// { -// const size_t INITIAL_SIZE = 5; -// const size_t NEW_SIZE = 8; -// const value_t INITIAL_VALUE = STR('A'); -// -// TextBuffer buffer{0}; -// Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size()); -// text.resize(NEW_SIZE, INITIAL_VALUE); -// -// std::array compare_text; -// compare_text.fill(INITIAL_VALUE); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_resize_excess) -// { -// const size_t INITIAL_SIZE = 5; -// const size_t NEW_SIZE = SIZE + 1; -// -// TextBuffer buffer{0}; -// Text text(INITIAL_SIZE, STR('A'), buffer.data(), buffer.size()); -// text.resize(NEW_SIZE, STR('A')); -// CHECK_EQUAL(SIZE, text.size()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_resize_down) -// { -// const size_t INITIAL_SIZE = 5; -// const size_t NEW_SIZE = 2; -// -// TextBuffer buffer{0}; -// Text text(INITIAL_SIZE, STR('A'), buffer.data(), buffer.size()); -// text.resize(NEW_SIZE); -// -// CHECK_EQUAL(text.size(), NEW_SIZE); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_resize_down_value) -// { -// const size_t INITIAL_SIZE = 5; -// const size_t NEW_SIZE = 2; -// const value_t INITIAL_VALUE = STR('A'); -// -// TextBuffer buffer{0}; -// Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size()); -// text.resize(NEW_SIZE, INITIAL_VALUE); -// -// CHECK_EQUAL(text.size(), NEW_SIZE); -// -// std::array compare_text; -// compare_text.fill(INITIAL_VALUE); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_uninitialized_resize_up) -// { -// const size_t INITIAL_SIZE = 5; -// const size_t NEW_SIZE = 8; -// const value_t INITIAL_VALUE = STR('A'); -// const value_t FILL_VALUE = STR('B'); -// -// TextBuffer buffer{0}; -// Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size()); -// -// Text::pointer pbegin = &text.front(); -// Text::pointer pend = &text.back() + 1; -// Text::pointer pmax = pbegin + text.max_size(); -// -// // Fill free space with a pattern. -// std::fill(pend, pmax, FILL_VALUE); -// -// text.uninitialized_resize(NEW_SIZE); -// -// std::array compare_text; -// compare_text.fill(FILL_VALUE); -// std::fill(compare_text.begin(), compare_text.begin() + INITIAL_SIZE, INITIAL_VALUE); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -// -// CHECK_EQUAL(text.size(), NEW_SIZE); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_uninitialized_resize_up_excess) -// { -// const size_t INITIAL_SIZE = 5; -// const size_t NEW_SIZE = SIZE + 1; -// -// TextBuffer buffer{0}; -// Text text(INITIAL_SIZE, STR('A'), buffer.data(), buffer.size()); -// -// text.uninitialized_resize(NEW_SIZE); -// -// CHECK_EQUAL(text.size(), SIZE); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_uninitialized_resize_down) -// { -// const size_t INITIAL_SIZE = 5; -// const size_t NEW_SIZE = 2; -// const value_t INITIAL_VALUE = STR('A'); -// const value_t FILL_VALUE = STR('B'); -// -// TextBuffer buffer{0}; -// Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size()); -// -// Text::pointer pbegin = &text.front(); -// Text::pointer pend = &text.back() + 1; -// Text::pointer pmax = pbegin + text.max_size(); -// -// // Fill free space with a pattern. -// std::fill(pend, pmax, FILL_VALUE); -// -// text.uninitialized_resize(NEW_SIZE); -// -// std::array compare_text; -// compare_text.fill(INITIAL_VALUE); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -// -// CHECK_EQUAL(text.size(), NEW_SIZE); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_empty_full) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// text.resize(text.max_size(), STR('A')); -// -// CHECK(!text.empty()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_empty_half) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// text.resize(text.max_size() / 2, STR('A')); -// -// CHECK(!text.empty()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_empty_empty) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// -// CHECK(text.empty()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_full_full) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// text.resize(text.max_size(), STR('A')); -// -// CHECK(text.full()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_full_half) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// text.resize(text.max_size() / 2, STR('A')); -// -// CHECK(!text.full()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_full_empty) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// -// CHECK(!text.full()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_index) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// for (size_t i = 0UL; i < text.size(); ++i) -// { -// CHECK_EQUAL(text[i], compare_text[i]); -// } -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_index_const) -// { -// const Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// const Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// for (size_t i = 0UL; i < text.size(); ++i) -// { -// CHECK_EQUAL(text[i], compare_text[i]); -// } -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_at) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// for (size_t i = 0UL; i < text.size(); ++i) -// { -// CHECK_EQUAL(text.at(i), compare_text.at(i)); -// } -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// CHECK_THROW(text.at(text.size()), etl::string_out_of_bounds); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_at_const) -// { -// const Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// const Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// for (size_t i = 0UL; i < text.size(); ++i) -// { -// CHECK_EQUAL(text.at(i), compare_text.at(i)); -// } -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// CHECK_THROW(text.at(text.size()), etl::string_out_of_bounds); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_front) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// CHECK(text.front() == compare_text.front()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_front_const) -// { -// const Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// const Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// CHECK(text.front() == compare_text.front()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_back) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// CHECK(text.back() == compare_text.back()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_back_const) -// { -// const Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// const Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// CHECK(text.back() == compare_text.back()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_data) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); -// -// bool is_equal = std::equal(text.data(), -// text.data() + text.size(), -// compare_text.begin()); -// -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_data_const) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// const Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); -// -// bool is_equal = std::equal(text.data(), -// text.data() + text.size(), -// compare_text.begin()); -// -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_assign_string) -// { -// Compare_Text compare_input(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text input(initial_text.c_str(), buffer.data(), buffer.size()); -// -// Compare_Text compare_text; -// -// TextBuffer buffer2{0}; -// Text text(buffer2.data(), buffer2.size()); -// -// compare_text.assign(compare_input); -// text.assign(input); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_assign_string_excess) -// { -// Compare_Text compare_input(initial_text.c_str()); -// -// TextBufferL bufferl{0}; -// Text input(longer_text.c_str(), bufferl.data(), bufferl.size()); -// -// Compare_Text compare_text; -// -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// -// compare_text.assign(compare_input); -// text.assign(input); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_assign_pointer) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// text.assign(initial_text.c_str()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_assign_pointer_excess) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// text.assign(longer_text.c_str()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_assign_pointer_length) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// text.assign(initial_text.c_str(), initial_text.size()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_assign_pointer_length_excess) -// { -// Compare_Text compare_text(longer_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// text.assign(longer_text.c_str(), longer_text.size()); -// -// compare_text.resize(text.max_size()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_assign_range) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// -// text.assign(compare_text.begin(), compare_text.end()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_assign_range_excess) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// -// text.assign(longer_text.begin(), longer_text.end()); -// -// CHECK_EQUAL(initial_text.size(), text.size()); -// -// bool is_equal = Equal(initial_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_assign_size_value) -// { -// const size_t INITIAL_SIZE = 5; -// const value_t INITIAL_VALUE = STR('A'); -// -// std::array compare_text; -// compare_text.fill(INITIAL_VALUE); -// -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// text.assign(INITIAL_SIZE, INITIAL_VALUE); -// -// CHECK(text.size() == INITIAL_SIZE); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_assign_size_value_excess) -// { -// const size_t INITIAL_SIZE = SIZE; -// const size_t EXCESS_SIZE = SIZE + 1; -// const value_t INITIAL_VALUE = STR('A'); -// std::array compare_text; -// compare_text.fill(INITIAL_VALUE); -// -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// text.assign(EXCESS_SIZE, INITIAL_VALUE); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_push_back) -// { -// Compare_Text compare_text; -// -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// -// for (size_t i = 0UL; i < SIZE; ++i) -// { -// compare_text.push_back(STR('A') + value_t(i)); -// } -// -// for (size_t i = 0UL; i < SIZE; ++i) -// { -// text.push_back(STR('A') + value_t(i)); -// } -// -// CHECK_EQUAL(etl::strlen(compare_text.data()), etl::strlen(text.data())); -// CHECK_EQUAL(compare_text.size(), text.size()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_push_back_excess) -// { -// Compare_Text compare_text; -// -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// -// for (size_t i = 0UL; i < SIZE; ++i) -// { -// compare_text.push_back(STR('A') + value_t(i)); -// } -// -// for (size_t i = 0UL; i < SIZE; ++i) -// { -// text.push_back(STR('A') + value_t(i)); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// text.push_back(STR('A') + value_t(SIZE)); -// -// CHECK_EQUAL(etl::strlen(compare_text.data()), etl::strlen(text.data())); -// CHECK_EQUAL(compare_text.size(), text.size()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_pop_back) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// compare_text.pop_back(); -// compare_text.pop_back(); -// -// text.pop_back(); -// text.pop_back(); -// -// CHECK_EQUAL(compare_text.size(), text.size()); -// -// bool is_equal = Equal(compare_text, text); -// -// CHECK(is_equal); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_insert_position_value) -// { -// const size_t INITIAL_SIZE = 5; -// const value_t INITIAL_VALUE = STR('A'); -// -// for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset) -// { -// Compare_Text compare_text; -// -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// -// text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE); -// compare_text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE); -// -// text.insert(text.begin() + offset, INITIAL_VALUE); -// compare_text.insert(compare_text.begin() + offset, INITIAL_VALUE); -// -// CHECK_EQUAL(compare_text.size(), text.size()); -// -// bool is_equal = Equal(compare_text, text); -// -// CHECK(is_equal); -// } -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_insert_position_value_excess) -// { -// Compare_Text compare_text(initial_text.begin(), initial_text.end()); -// TextBuffer buffer{0}; -// Text text(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); -// -// const value_t INITIAL_VALUE = STR('A'); -// -// size_t offset = 2UL; -// text.insert(text.cbegin() + offset, INITIAL_VALUE); -// compare_text.insert(compare_text.cbegin() + offset, INITIAL_VALUE); -// compare_text.erase(compare_text.cend() - 1); -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -// -// offset = 0; -// text.insert(text.cbegin() + offset, STR('A')); -// compare_text.insert(compare_text.cbegin() + offset, STR('A')); -// compare_text.erase(compare_text.cend() - 1); -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -// -// offset = text.size(); -// text.insert(text.cbegin() + offset, STR('A')); -// compare_text.insert(compare_text.cbegin() + offset, STR('A')); -// compare_text.erase(compare_text.cend() - 1); -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_insert_position_n_value) -// { -// Compare_Text compare_text; -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// -// const size_t INITIAL_SIZE = 5UL; -// const size_t INSERT_SIZE = 3UL; -// const value_t INITIAL_VALUE = STR('A'); -// -// for (size_t offset = 0UL; offset <= INITIAL_SIZE; ++offset) -// { -// text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE); -// compare_text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE); -// text.insert(text.begin() + offset, INSERT_SIZE, INITIAL_VALUE); -// compare_text.insert(compare_text.begin() + offset, INSERT_SIZE, INITIAL_VALUE); -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -// } -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess) -// { -// Compare_Text compare_text; -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// -// const size_t INSERT_SIZE = 4UL; -// const value_t INSERT_VALUE = STR('A'); -// -// size_t offset = 0UL; -// compare_text.assign(initial_text.cbegin(), initial_text.cend()); -// text.assign(initial_text.cbegin(), initial_text.cend()); -// compare_text.insert(compare_text.cbegin() + offset, INSERT_SIZE, INSERT_VALUE); -// compare_text.erase(compare_text.cend() - INSERT_SIZE, compare_text.cend()); -// text.insert(text.cbegin() + offset, INSERT_SIZE, INSERT_VALUE); -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -// -// offset = 2; -// compare_text.assign(initial_text.cbegin(), initial_text.cend()); -// text.assign(initial_text.cbegin(), initial_text.cend()); -// compare_text.insert(compare_text.cbegin() + offset, INSERT_SIZE, INSERT_VALUE); -// compare_text.erase(compare_text.cend() - INSERT_SIZE, compare_text.cend()); -// text.assign(initial_text.cbegin(), initial_text.cend()); -// text.insert(text.cbegin() + offset, INSERT_SIZE, INSERT_VALUE); -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -// -// offset = 4; -// compare_text.assign(initial_text.cbegin(), initial_text.cend()); -// text.assign(initial_text.cbegin(), initial_text.cend()); -// compare_text.insert(compare_text.cbegin() + offset, INSERT_SIZE, INSERT_VALUE); -// compare_text.erase(compare_text.cend() - INSERT_SIZE, compare_text.cend()); -// text.assign(initial_text.cbegin(), initial_text.cend()); -// text.insert(text.cbegin() + offset, INSERT_SIZE, INSERT_VALUE); -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -// -// offset = text.size(); -// compare_text.assign(initial_text.cbegin(), initial_text.cend()); -// text.assign(initial_text.cbegin(), initial_text.cend()); -// compare_text.insert(compare_text.cbegin() + offset, INSERT_SIZE, INSERT_VALUE); -// compare_text.erase(compare_text.cend() - INSERT_SIZE, compare_text.cend()); -// text.assign(initial_text.cbegin(), initial_text.cend()); -// text.insert(text.cbegin() + offset, INSERT_SIZE, INSERT_VALUE); -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_insert_position_range) -// { -// const size_t INITIAL_SIZE = 5UL; -// -// for (size_t offset = 0UL; offset <= INITIAL_SIZE; ++offset) -// { -// Compare_Text compare_text; -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// -// text.assign(initial_text.cbegin(), initial_text.cbegin() + INITIAL_SIZE); -// compare_text.assign(initial_text.cbegin(), initial_text.cbegin() + INITIAL_SIZE); -// text.insert(text.cbegin() + offset, insert_text.cbegin(), insert_text.cend()); -// compare_text.insert(compare_text.cbegin() + offset, insert_text.cbegin(), insert_text.cend()); -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -// } -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_insert_position_range_excess) -// { -// const size_t INITIAL_SIZE = 5UL; -// const value_t INITIAL_VALUE = STR('A'); -// -// Compare_Text compare_text; -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// -// size_t offset = 0UL; -// -// compare_text.assign(INITIAL_SIZE, INITIAL_VALUE); -// text.assign(INITIAL_SIZE, INITIAL_VALUE); -// compare_text.insert(compare_text.cbegin() + offset, initial_text.cbegin(), initial_text.cend()); -// compare_text.resize(initial_text.size()); -// text.insert(text.cbegin() + offset, initial_text.cbegin(), initial_text.cend()); -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -// -// offset = 2; -// -// compare_text.assign(INITIAL_SIZE, INITIAL_VALUE); -// text.assign(INITIAL_SIZE, INITIAL_VALUE); -// compare_text.insert(compare_text.cbegin() + offset, initial_text.cbegin(), initial_text.cend()); -// compare_text.resize(initial_text.size()); -// text.insert(text.cbegin() + offset, initial_text.cbegin(), initial_text.cend()); -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -// -// -// offset = 4; -// -// compare_text.assign(INITIAL_SIZE, INITIAL_VALUE); -// text.assign(INITIAL_SIZE, INITIAL_VALUE); -// compare_text.insert(compare_text.cbegin() + offset, initial_text.cbegin(), initial_text.cend()); -// compare_text.resize(initial_text.size()); -// text.insert(text.cbegin() + offset, initial_text.cbegin(), initial_text.cend()); -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// CHECK_EQUAL(compare_text.size(), text.size()); -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_insert_position_range_self) -// { -// size_t length = SIZE_L / 2; -// -// for (size_t offset = 10UL; offset < length; ++offset) -// { -// Compare_Text compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); -// TextBufferL bufferl{0}; -// Text text(bufferl.data(), bufferl.size()); -// text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); -// -// text.insert(text.cbegin() + offset, text.cbegin() + 5, text.cbegin() + 10); -// compare_text.insert(compare_text.cbegin() + offset, compare_text.cbegin() + 5, compare_text.cbegin() + 10); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_default_constructor) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + CHECK_EQUAL(text.size(), size_t(0)); + CHECK(text.empty()); + CHECK_EQUAL(SIZE, text.capacity()); + CHECK_EQUAL(SIZE, text.max_size()); + CHECK(text.begin() == text.end()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string) + TEST_FIXTURE(SetupFixture, test_default_constructor_use_buffer_and_size) { - size_t s = short_text.size(); - (void)s; + size_t length = etl::strlen(p_text); + Text text(p_text, length + 1); - assert(s <= 5); + CHECK_EQUAL(0U, text.size()); + CHECK(text.empty()); + CHECK_EQUAL(length, text.capacity()); + CHECK_EQUAL(length, text.max_size()); + CHECK(text.begin() == text.end()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } -// /*for (*/size_t offset = s;/* offset <= short_text.size(); ++offset)*/ -// //{ -// Compare_Text compare_text(short_text.cbegin(), short_text.cend()); -// TextBuffer buffer{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -// Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -// Text insert(insert_text.begin(), insert_text.end(), buffer2.data(), buffer2.size()); -// -// text.insert(offset, insert); -// compare_text.insert(offset, insert_text); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif - //} + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_default_constructor_use_buffer_text_and_size) + { + Text text(p_text, p_text, etl::strlen(p_text) + 1); + + CHECK_EQUAL(text.size(), etl::strlen(p_text)); + CHECK(!text.empty()); + CHECK_EQUAL(etl::strlen(p_text), text.capacity()); + CHECK_EQUAL(etl::strlen(p_text), text.max_size()); + CHECK(text.begin() != text.end()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_2) + TEST_FIXTURE(SetupFixture, test_default_constructor_use_array_buffer) + { + Text text(array_text, ETL_OR_STD17::size(array_text)); + + CHECK_EQUAL(0U, text.size()); + CHECK(text.empty()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.capacity()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.max_size()); + CHECK(text.begin() == text.end()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_default_constructor_use_array_buffer_text) + { + Text text(array_text, array_text, ETL_OR_STD17::size(array_text)); + + CHECK_EQUAL(text.size(), etl::strlen(array_text)); + CHECK(!text.empty()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.capacity()); + CHECK_EQUAL(ETL_OR_STD17::size(array_text) - 1, text.max_size()); + CHECK(text.begin() != text.end()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST(test_iterator_comparison_empty) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + CHECK(text.begin() == text.end()); + CHECK(text.cbegin() == text.cend()); + CHECK(text.rbegin() == text.rend()); + CHECK(text.crbegin() == text.crend()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_size_value) + { + const size_t INITIAL_SIZE = 5; + const value_t INITIAL_VALUE = STR('A'); + TextBuffer buffer{0}; + + Compare_Text compare_text(INITIAL_SIZE, INITIAL_VALUE); + Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size()); + + CHECK(text.size() == INITIAL_SIZE); + CHECK(!text.empty()); + + bool is_equal = Equal(compare_text, text); + + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_size_excess) + { + TextBuffer buffer{0}; + Text text(buffer.size() + 1, STR('A'), buffer.data(), buffer.size()); + + CHECK_EQUAL(buffer.size() - 1, text.size()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_char_pointer) + { + TextBuffer buffer{0}; + Compare_Text compare_text(initial_text.c_str()); + + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + CHECK(!text.empty()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_excess) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + Text text(longer_text.c_str(), buffer.data(), buffer.size()); + + CHECK(!text.empty()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size) + { + Compare_Text compare_text(SIZE, STR('A')); + + TextBuffer buffer{0}; + Text text(SIZE, STR('A'), buffer.data(), buffer.size()); + + CHECK(!text.empty()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size_excess) + { + Compare_Text compare_text(SIZE, STR('A')); + + TextBuffer buffer{0}; + Text text(SIZE + 1, STR('A'), buffer.data(), buffer.size()); + + CHECK(!text.empty()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_size_char) + { + Compare_Text compare_text(initial_text.c_str(), initial_text.size() / 2); + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), initial_text.size() / 2, buffer.data(), buffer.size()); + + CHECK(!text.empty()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_size_char_excess) + { + Compare_Text compare_text(initial_text.c_str(), initial_text.size()); + + TextBuffer buffer{0}; + Text text(longer_text.c_str(), longer_text.size(), buffer.data(), buffer.size()); + + CHECK(!text.empty()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_range) + { + Compare_Text compare_text(initial_text.begin(), initial_text.end()); + + TextBuffer buffer{0}; + Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); + + CHECK(text.size() == SIZE); + CHECK(!text.empty()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_range_excess) + { + TextBuffer buffer{0}; + Text text(longer_text.begin(), longer_text.end(), buffer.data(), buffer.size()); + + bool is_equal = Equal(initial_text, text); + CHECK(is_equal); + CHECK(text.size() == SIZE); + CHECK(!text.empty()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_from_literal) + { + TextBuffer buffer{0}; + Text text(STR("Hello World"), buffer.data(), buffer.size()); + + bool is_equal = Equal(initial_text, text); + CHECK(is_equal); + CHECK(text.size() == SIZE); + CHECK(!text.empty()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_from_string_view) + { + etl::u16string_view view(initial_text.data(), initial_text.size()); + + TextBuffer buffer{0}; + Text text(view, buffer.data(), buffer.size()); + + bool is_equal = Equal(initial_text, text); + CHECK(is_equal); + CHECK(text.size() == SIZE); + CHECK(!text.empty()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_copy_constructor) + { + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + Text text2(text, buffer2.data(), buffer2.size()); + CHECK(text2 == text); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text2.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_copy_constructor_i) + { + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + IText& itext = text; + + TextBuffer buffer2{0}; + Text text2(itext, buffer2.data(), buffer2.size()); + CHECK(text2 == text); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text2.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_copy_constructor_excess) + { + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + TextBufferL bufferl{0}; + Text textl(longer_text.c_str(), bufferl.data(), bufferl.size()); + + TextBuffer buffer2{0}; + Text text2(textl, buffer2.data(), buffer2.size()); + CHECK(text2 == text); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text2.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_copy_constructor_from_truncated) + { + TextBuffer buffer{0}; + Text text(longer_text.c_str(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + Text text2(text, buffer2.data(), buffer2.size()); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text2.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_construct_position_length) + { + Compare_Text compare_text(initial_text.c_str()); + Compare_Text compare_text2(compare_text, 2, 4); + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + Text text2(text, buffer2.data(), buffer2.size(), 2, 4); + + bool is_equal = Equal(compare_text2, text2); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text2.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_construct_position_length_excess) + { + Compare_Text compare_text(longer_text.c_str()); + Compare_Text compare_text2(compare_text, 2, 11); + + TextBufferL bufferl{0}; + Text textl(longer_text.c_str(), bufferl.data(), bufferl.size()); + + TextBuffer buffer{0}; + Text text2(textl, buffer.data(), buffer.size(), 2, 12); + + bool is_equal = Equal(compare_text2, text2); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text2.is_truncated()); +#endif + } + +#if ETL_HAS_INITIALIZER_LIST + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_construct_initializer_list) + { + Compare_Text compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + + std::initializer_list il = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + TextBuffer buffer{0}; + Text text(il, buffer.data(), buffer.size()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_construct_initializer_list_excess) + { + Compare_Text compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), + STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; + + std::initializer_list il = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), + STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), + STR('T'), STR('h'), STR('e'), STR('r'), STR('e') }; + TextBuffer buffer{0}; + Text text(il, buffer.data(), buffer.size()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment) + { + TextBuffer buffer{0}; + Text text(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + Text other_text(buffer2.data(), buffer2.size()); + + other_text = text; + + bool is_equal = Equal(text, other_text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); + CHECK(!other_text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_excess) + { + TextBuffer buffer{0}; + Text text(longer_text.begin(), longer_text.end(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + Text other_text(buffer2.data(), buffer2.size()); + + other_text = text; + + bool is_equal = Equal(text, other_text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); + CHECK(other_text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_iterface) + { + TextBuffer buffer{0}; + Text text1(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + Text text2(buffer2.data(), buffer2.size()); + + IText& itext1 = text1; + IText& itext2 = text2; + + itext2 = itext1; + + bool is_equal = Equal(text1, text2); + + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text1.is_truncated()); + CHECK(!text2.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_iterface_excess) + { + TextBuffer buffer{0}; + Text text1(longer_text.begin(), longer_text.end(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + Text text2(buffer2.data(), buffer2.size()); + + IText& itext1 = text1; + IText& itext2 = text2; + + itext2 = itext1; + + bool is_equal = Equal(text1, text2); + + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text1.is_truncated()); + CHECK(text2.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_self_assignment) + { + TextBuffer buffer{0}; + Text text(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + Text other_text(text, buffer2.data(), buffer2.size()); + +#include "etl/private/diagnostic_self_assign_overloaded_push.h" + other_text = other_text; +#include "etl/private/diagnostic_pop.h" + + bool is_equal = Equal(text, other_text); + + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); + CHECK(!other_text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_self_assignment_excess) + { + TextBuffer buffer{0}; + Text text(longer_text.begin(), longer_text.end(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + Text other_text(text, buffer2.data(), buffer2.size()); + +#include "etl/private/diagnostic_self_assign_overloaded_push.h" + other_text = other_text; +#include "etl/private/diagnostic_pop.h" + + bool is_equal = Equal(text, other_text); + + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); + CHECK(other_text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_literal) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + text = STR("Hello World"); + + bool is_equal = Equal(std::u16string(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_literal_excess) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + text = STR("Hello World There"); + + bool is_equal = Equal(std::u16string(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_literal_via_interface) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + IText& itext = text; + + itext = STR("Hello World"); + + bool is_equal = Equal(std::u16string(STR("Hello World")), itext); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!itext.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_literal_via_interface_excess) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + IText& itext = text; + + itext = STR("Hello World There"); + + bool is_equal = Equal(std::u16string(STR("Hello World")), itext); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(itext.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_begin) + { + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + const Text constText(initial_text.c_str(), buffer2.data(), buffer2.size()); + + CHECK_EQUAL(&text[0], text.begin()); + CHECK_EQUAL(&constText[0], constText.begin()); + } + + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_end) + { + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + const Text constText(initial_text.c_str(), buffer2.data(), buffer2.size()); + + CHECK_EQUAL(&text[initial_text.size()], text.end()); + CHECK_EQUAL(&constText[initial_text.size()], constText.end()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_up) + { + const size_t INITIAL_SIZE = 5; + const size_t NEW_SIZE = 8; + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), INITIAL_SIZE, buffer.data(), buffer.size()); + text.resize(NEW_SIZE); + + CHECK_EQUAL(text.size(), NEW_SIZE); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_up_value) + { + const size_t INITIAL_SIZE = 5; + const size_t NEW_SIZE = 8; + const value_t INITIAL_VALUE = STR('A'); + + TextBuffer buffer{0}; + Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size()); + text.resize(NEW_SIZE, INITIAL_VALUE); + + std::array compare_text; + compare_text.fill(INITIAL_VALUE); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_excess) { + const size_t INITIAL_SIZE = 5; + const size_t NEW_SIZE = SIZE + 1; + + TextBuffer buffer{0}; + Text text(INITIAL_SIZE, STR('A'), buffer.data(), buffer.size()); + text.resize(NEW_SIZE, STR('A')); + CHECK_EQUAL(SIZE, text.size()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_down) + { + const size_t INITIAL_SIZE = 5; + const size_t NEW_SIZE = 2; + + TextBuffer buffer{0}; + Text text(INITIAL_SIZE, STR('A'), buffer.data(), buffer.size()); + text.resize(NEW_SIZE); + + CHECK_EQUAL(text.size(), NEW_SIZE); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_down_value) + { + const size_t INITIAL_SIZE = 5; + const size_t NEW_SIZE = 2; + const value_t INITIAL_VALUE = STR('A'); + + TextBuffer buffer{0}; + Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size()); + text.resize(NEW_SIZE, INITIAL_VALUE); + + CHECK_EQUAL(text.size(), NEW_SIZE); + + std::array compare_text; + compare_text.fill(INITIAL_VALUE); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_uninitialized_resize_up) + { + const size_t INITIAL_SIZE = 5; + const size_t NEW_SIZE = 8; + const value_t INITIAL_VALUE = STR('A'); + const value_t FILL_VALUE = STR('B'); + + TextBuffer buffer{0}; + Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size()); + + Text::pointer pbegin = &text.front(); + Text::pointer pend = &text.back() + 1; + Text::pointer pmax = pbegin + text.max_size(); + + // Fill free space with a pattern. + std::fill(pend, pmax, FILL_VALUE); + + text.uninitialized_resize(NEW_SIZE); + + std::array compare_text; + compare_text.fill(FILL_VALUE); + std::fill(compare_text.begin(), compare_text.begin() + INITIAL_SIZE, INITIAL_VALUE); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); + + CHECK_EQUAL(text.size(), NEW_SIZE); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_uninitialized_resize_up_excess) + { + const size_t INITIAL_SIZE = 5; + const size_t NEW_SIZE = SIZE + 1; + + TextBuffer buffer{0}; + Text text(INITIAL_SIZE, STR('A'), buffer.data(), buffer.size()); + + text.uninitialized_resize(NEW_SIZE); + + CHECK_EQUAL(text.size(), SIZE); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_uninitialized_resize_down) + { + const size_t INITIAL_SIZE = 5; + const size_t NEW_SIZE = 2; + const value_t INITIAL_VALUE = STR('A'); + const value_t FILL_VALUE = STR('B'); + + TextBuffer buffer{0}; + Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size()); + + Text::pointer pbegin = &text.front(); + Text::pointer pend = &text.back() + 1; + Text::pointer pmax = pbegin + text.max_size(); + + // Fill free space with a pattern. + std::fill(pend, pmax, FILL_VALUE); + + text.uninitialized_resize(NEW_SIZE); + + std::array compare_text; + compare_text.fill(INITIAL_VALUE); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); + + CHECK_EQUAL(text.size(), NEW_SIZE); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_fill) + { + TextBuffer buffer1{ 0 }; + TextBuffer buffer2{ 0 }; + Text text(11, STR('A'), buffer1.data(), buffer1.size()); + Text expected(11, STR('B'), buffer2.data(), buffer2.size()); + + text.fill(STR('B')); + + bool is_equal = Equal(expected, text); + CHECK(is_equal); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_empty_full) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + text.resize(text.max_size(), STR('A')); + + CHECK(!text.empty()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_empty_half) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + text.resize(text.max_size() / 2, STR('A')); + + CHECK(!text.empty()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_empty_empty) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + CHECK(text.empty()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_full_full) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + text.resize(text.max_size(), STR('A')); + + CHECK(text.full()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_full_half) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + text.resize(text.max_size() / 2, STR('A')); + + CHECK(!text.full()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_full_empty) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + CHECK(!text.full()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_index) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + for (size_t i = 0UL; i < text.size(); ++i) + { + CHECK_EQUAL(text[i], compare_text[i]); + } + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_index_const) + { + const Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + const Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + for (size_t i = 0UL; i < text.size(); ++i) + { + CHECK_EQUAL(text[i], compare_text[i]); + } + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_at) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + for (size_t i = 0UL; i < text.size(); ++i) + { + CHECK_EQUAL(text.at(i), compare_text.at(i)); + } + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + CHECK_THROW(text.at(text.size()), etl::string_out_of_bounds); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_at_const) + { + const Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + const Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + for (size_t i = 0UL; i < text.size(); ++i) + { + CHECK_EQUAL(text.at(i), compare_text.at(i)); + } + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + CHECK_THROW(text.at(text.size()), etl::string_out_of_bounds); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_front) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + CHECK(text.front() == compare_text.front()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_front_const) + { + const Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + const Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + CHECK(text.front() == compare_text.front()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_back) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + CHECK(text.back() == compare_text.back()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_back_const) + { + const Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + const Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + CHECK(text.back() == compare_text.back()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_data) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); + + bool is_equal = std::equal(text.data(), + text.data() + text.size(), + compare_text.begin()); + + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_data_const) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + const Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); + + bool is_equal = std::equal(text.data(), + text.data() + text.size(), + compare_text.begin()); + + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_string) + { + Compare_Text compare_input(initial_text.c_str()); + + TextBuffer buffer{0}; + Text input(initial_text.c_str(), buffer.data(), buffer.size()); + + Compare_Text compare_text; + + TextBuffer buffer2{0}; + Text text(buffer2.data(), buffer2.size()); + + compare_text.assign(compare_input); + text.assign(input); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_string_excess) + { + Compare_Text compare_input(initial_text.c_str()); + + TextBufferL bufferl{0}; + Text input(longer_text.c_str(), bufferl.data(), bufferl.size()); + + Compare_Text compare_text; + + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + compare_text.assign(compare_input); + text.assign(input); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_pointer) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + text.assign(initial_text.c_str()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_pointer_excess) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + text.assign(longer_text.c_str()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_pointer_length) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + text.assign(initial_text.c_str(), initial_text.size()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_pointer_length_excess) + { + Compare_Text compare_text(longer_text.c_str()); + + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + text.assign(longer_text.c_str(), longer_text.size()); + + compare_text.resize(text.max_size()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_range) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + text.assign(compare_text.begin(), compare_text.end()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_range_excess) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + text.assign(longer_text.begin(), longer_text.end()); + + CHECK_EQUAL(initial_text.size(), text.size()); + + bool is_equal = Equal(initial_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_size_value) + { + const size_t INITIAL_SIZE = 5; + const value_t INITIAL_VALUE = STR('A'); + + std::array compare_text; + compare_text.fill(INITIAL_VALUE); + + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + text.assign(INITIAL_SIZE, INITIAL_VALUE); + + CHECK(text.size() == INITIAL_SIZE); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_size_value_excess) + { + const size_t INITIAL_SIZE = SIZE; + const size_t EXCESS_SIZE = SIZE + 1; + const value_t INITIAL_VALUE = STR('A'); + std::array compare_text; + compare_text.fill(INITIAL_VALUE); + + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + text.assign(EXCESS_SIZE, INITIAL_VALUE); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_push_back) + { + Compare_Text compare_text; + + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + for (size_t i = 0UL; i < SIZE; ++i) + { + compare_text.push_back(STR('A') + value_t(i)); + } + + for (size_t i = 0UL; i < SIZE; ++i) + { + text.push_back(STR('A') + value_t(i)); + } + + CHECK_EQUAL(etl::strlen(compare_text.data()), etl::strlen(text.data())); + CHECK_EQUAL(compare_text.size(), text.size()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_push_back_excess) + { + Compare_Text compare_text; + + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + for (size_t i = 0UL; i < SIZE; ++i) + { + compare_text.push_back(STR('A') + value_t(i)); + } + + for (size_t i = 0UL; i < SIZE; ++i) + { + text.push_back(STR('A') + value_t(i)); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + text.push_back(STR('A') + value_t(SIZE)); + + CHECK_EQUAL(etl::strlen(compare_text.data()), etl::strlen(text.data())); + CHECK_EQUAL(compare_text.size(), text.size()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_pop_back) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + compare_text.pop_back(); + compare_text.pop_back(); + + text.pop_back(); + text.pop_back(); + + CHECK_EQUAL(compare_text.size(), text.size()); + + bool is_equal = Equal(compare_text, text); + + CHECK(is_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_value) + { + const size_t INITIAL_SIZE = 5; + const value_t INITIAL_VALUE = STR('A'); + + for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset) + { + Compare_Text compare_text; + + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE); + compare_text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE); + + text.insert(text.begin() + offset, INITIAL_VALUE); + compare_text.insert(compare_text.begin() + offset, INITIAL_VALUE); + + CHECK_EQUAL(compare_text.size(), text.size()); + + bool is_equal = Equal(compare_text, text); + + CHECK(is_equal); + } + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_value_excess) + { + Compare_Text compare_text(initial_text.begin(), initial_text.end()); + TextBuffer buffer{0}; + Text text(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); + + const value_t INITIAL_VALUE = STR('A'); + + size_t offset = 2UL; + text.insert(text.cbegin() + offset, INITIAL_VALUE); + compare_text.insert(compare_text.cbegin() + offset, INITIAL_VALUE); + compare_text.erase(compare_text.cend() - 1); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); + + offset = 0; + text.insert(text.cbegin() + offset, STR('A')); + compare_text.insert(compare_text.cbegin() + offset, STR('A')); + compare_text.erase(compare_text.cend() - 1); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + is_equal = Equal(compare_text, text); + CHECK(is_equal); + + offset = text.size(); + text.insert(text.cbegin() + offset, STR('A')); + compare_text.insert(compare_text.cbegin() + offset, STR('A')); + compare_text.erase(compare_text.cend() - 1); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + is_equal = Equal(compare_text, text); + CHECK(is_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_n_value) + { + Compare_Text compare_text; + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + const size_t INITIAL_SIZE = 5UL; + const size_t INSERT_SIZE = 3UL; + const value_t INITIAL_VALUE = STR('A'); + + for (size_t offset = 0UL; offset <= INITIAL_SIZE; ++offset) + { + text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE); + compare_text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE); + text.insert(text.begin() + offset, INSERT_SIZE, INITIAL_VALUE); + compare_text.insert(compare_text.begin() + offset, INSERT_SIZE, INITIAL_VALUE); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); + } + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess) + { + Compare_Text compare_text; + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + const size_t INSERT_SIZE = 4UL; + const value_t INSERT_VALUE = STR('A'); + + size_t offset = 0UL; + compare_text.assign(initial_text.cbegin(), initial_text.cend()); + text.assign(initial_text.cbegin(), initial_text.cend()); + compare_text.insert(compare_text.cbegin() + offset, INSERT_SIZE, INSERT_VALUE); + compare_text.erase(compare_text.cend() - INSERT_SIZE, compare_text.cend()); + text.insert(text.cbegin() + offset, INSERT_SIZE, INSERT_VALUE); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); + + offset = 2; + compare_text.assign(initial_text.cbegin(), initial_text.cend()); + text.assign(initial_text.cbegin(), initial_text.cend()); + compare_text.insert(compare_text.cbegin() + offset, INSERT_SIZE, INSERT_VALUE); + compare_text.erase(compare_text.cend() - INSERT_SIZE, compare_text.cend()); + text.assign(initial_text.cbegin(), initial_text.cend()); + text.insert(text.cbegin() + offset, INSERT_SIZE, INSERT_VALUE); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + is_equal = Equal(compare_text, text); + CHECK(is_equal); + + offset = 4; + compare_text.assign(initial_text.cbegin(), initial_text.cend()); + text.assign(initial_text.cbegin(), initial_text.cend()); + compare_text.insert(compare_text.cbegin() + offset, INSERT_SIZE, INSERT_VALUE); + compare_text.erase(compare_text.cend() - INSERT_SIZE, compare_text.cend()); + text.assign(initial_text.cbegin(), initial_text.cend()); + text.insert(text.cbegin() + offset, INSERT_SIZE, INSERT_VALUE); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + is_equal = Equal(compare_text, text); + CHECK(is_equal); + + offset = text.size(); + compare_text.assign(initial_text.cbegin(), initial_text.cend()); + text.assign(initial_text.cbegin(), initial_text.cend()); + compare_text.insert(compare_text.cbegin() + offset, INSERT_SIZE, INSERT_VALUE); + compare_text.erase(compare_text.cend() - INSERT_SIZE, compare_text.cend()); + text.assign(initial_text.cbegin(), initial_text.cend()); + text.insert(text.cbegin() + offset, INSERT_SIZE, INSERT_VALUE); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + is_equal = Equal(compare_text, text); + CHECK(is_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_range) + { + const size_t INITIAL_SIZE = 5UL; + + for (size_t offset = 0UL; offset <= INITIAL_SIZE; ++offset) + { + Compare_Text compare_text; + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + text.assign(initial_text.cbegin(), initial_text.cbegin() + INITIAL_SIZE); + compare_text.assign(initial_text.cbegin(), initial_text.cbegin() + INITIAL_SIZE); + text.insert(text.cbegin() + offset, insert_text.cbegin(), insert_text.cend()); + compare_text.insert(compare_text.cbegin() + offset, insert_text.cbegin(), insert_text.cend()); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); + } + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_range_excess) + { + const size_t INITIAL_SIZE = 5UL; + const value_t INITIAL_VALUE = STR('A'); + + Compare_Text compare_text; + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + size_t offset = 0UL; + + compare_text.assign(INITIAL_SIZE, INITIAL_VALUE); + text.assign(INITIAL_SIZE, INITIAL_VALUE); + compare_text.insert(compare_text.cbegin() + offset, initial_text.cbegin(), initial_text.cend()); + compare_text.resize(initial_text.size()); + text.insert(text.cbegin() + offset, initial_text.cbegin(), initial_text.cend()); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); + + offset = 2; + + compare_text.assign(INITIAL_SIZE, INITIAL_VALUE); + text.assign(INITIAL_SIZE, INITIAL_VALUE); + compare_text.insert(compare_text.cbegin() + offset, initial_text.cbegin(), initial_text.cend()); + compare_text.resize(initial_text.size()); + text.insert(text.cbegin() + offset, initial_text.cbegin(), initial_text.cend()); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + is_equal = Equal(compare_text, text); + CHECK(is_equal); + + + offset = 4; + + compare_text.assign(INITIAL_SIZE, INITIAL_VALUE); + text.assign(INITIAL_SIZE, INITIAL_VALUE); + compare_text.insert(compare_text.cbegin() + offset, initial_text.cbegin(), initial_text.cend()); + compare_text.resize(initial_text.size()); + text.insert(text.cbegin() + offset, initial_text.cbegin(), initial_text.cend()); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + CHECK_EQUAL(compare_text.size(), text.size()); + is_equal = Equal(compare_text, text); + CHECK(is_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_range_self) + { + size_t length = SIZE_L / 2; + + for (size_t offset = 10UL; offset < length; ++offset) + { + Compare_Text compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + TextBufferL bufferl{0}; + Text text(bufferl.data(), bufferl.size()); + text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + + text.insert(text.cbegin() + offset, text.cbegin() + 5, text.cbegin() + 10); + compare_text.insert(compare_text.cbegin() + offset, compare_text.cbegin() + 5, compare_text.cbegin() + 10); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string) + { + size_t s = short_text.size(); + (void)s; + + assert(s <= 5); + + for (size_t offset = s; offset <= short_text.size(); ++offset) + { + Compare_Text compare_text(short_text.cbegin(), short_text.cend()); + TextBuffer buffer{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); + + TextBuffer buffer2{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + Text insert(insert_text.begin(), insert_text.end(), buffer2.data(), buffer2.size()); + + text.insert(offset, insert); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_2) + { + + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) + { +#include "etl/private/diagnostic_array_bounds_push.h" + for (size_t offset = 0UL; offset <= initial_text.size(); ++offset) + { + Compare_Text compare_text(initial_text.cbegin(), initial_text.cend()); + + TextBuffer buffer{ 0 }; + Text text(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); + + TextBuffer buffer2{ 0 }; + Text insert(insert_text.begin(), insert_text.end(), buffer2.data(), buffer2.size()); + + text.insert(offset, insert); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#include "etl/private/diagnostic_pop.h" + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_from_truncated) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + Compare_Text compare_text(short_text.cbegin(), short_text.cend()); + + TextBuffer buffer{0}; + Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + Text insert(longer_text.begin(), longer_text.end(), buffer2.data(), buffer2.size()); + + insert.erase(insert.cbegin(), insert.cend()); + insert.append(insert_text.cbegin(), insert_text.cend()); + + text.insert(offset, insert); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_subpos_sunlen) + { + Compare_Text compare_text(short_text.cbegin(), short_text.cend()); + + TextBuffer buffer{0}; + Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + Text insert(insert_text.begin(), insert_text.end(), buffer2.data(), buffer2.size()); + + text.insert(0, insert, 0, insert.size()); + compare_text.insert(0, insert_text, 0, insert_text.size()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + compare_text.assign(short_text.cbegin(), short_text.cend()); + text.assign(short_text.cbegin(), short_text.cend()); + + text.insert(2, insert, 2, insert.size() - 2); + compare_text.insert(2, insert_text, 2, insert_text.size() - 2); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + CHECK_EQUAL(compare_text.size(), text.size()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + compare_text.assign(short_text.cbegin(), short_text.cend()); + text.assign(short_text.cbegin(), short_text.cend()); + + text.insert(short_text.size(), insert, 0, insert.size()); + compare_text.insert(short_text.size(), insert_text, 0, insert_text.size()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_string) + { + Compare_Text compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + Text append(insert_text.c_str(), buffer2.data(), buffer2.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(append); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + append.assign(initial_text.c_str()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(append); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_truncated_string) + { +#include "etl/private/diagnostic_array_bounds_push.h" + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + TextBufferS buffers{0}; + Text append(short_text.c_str(), buffers.data(), buffers.size()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(append.is_truncated()); +#endif + + text.append(append); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif +#include "etl/private/diagnostic_pop.h" + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_string_to_self) + { + Compare_Text compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + // Non-overflow. + compare_text.append(compare_text); + text.append(text); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(shorter_text.c_str()); + text.assign(shorter_text.c_str()); + + compare_text.append(compare_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(text); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_string_subpos_sublen) + { + Compare_Text compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + Text append(insert_text.c_str(), buffer2.data(), buffer2.size()); + + // Whole string. + compare_text.append(insert_text, 0, std::u16string::npos); + text.append(append, 0, Text::npos); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Partial string. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + append.assign(initial_text.c_str()); + + compare_text.append(short_text, 1, 3); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(append, 1, 3); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + append.assign(initial_text.c_str()); + + compare_text.append(initial_text, 1, initial_text.size()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(append, 1, append.size()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_truncated_string_subpos_sublen) + { + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + TextBufferS buffer2{0}; + Text append(short_text.c_str(), buffer2.data(), buffer2.size()); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(append.is_truncated()); +#endif + + text.append(append, 1, 2); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_c_string) + { + // Non-overflow. + Compare_Text compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + // Whole string. + compare_text.append(insert_text.c_str()); + text.append(insert_text.c_str()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.append(initial_text.c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(initial_text.c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_n_c) + { + // Non-overflow. + Compare_Text compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + // Non-overflow. + compare_text.append(5, STR('A')); + text.append(5, STR('A')); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.append(SIZE, STR('A')); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(SIZE, STR('A')); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_range) + { + // Non-overflow. + Compare_Text compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + Text append(insert_text.c_str(), buffer2.data(), buffer2.size()); + + compare_text.append(insert_text.begin(), insert_text.end()); + text.append(append.begin(), append.end()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + append.assign(initial_text.c_str()); + + compare_text.append(initial_text.begin(), initial_text.end()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(append.begin(), append.end()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_string) + { + // Non-overflow short text, npos. + Compare_Text compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextT(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, Compare_Text(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, TextT(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, Compare_Text(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, TextT(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextT(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, Compare_Text(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, TextT(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, Compare_Text(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, TextT(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextT(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_string) + { + // Non-overflow short text. + Compare_Text compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, Compare_Text(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, TextT(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, Compare_Text(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, TextT(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, Compare_Text(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, TextT(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, Compare_Text(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, TextT(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) + { + // Non-overflow short text. + Compare_Text compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, 4, Compare_Text(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, TextT(STR("Replace")), 1, 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace")), 1, Compare_Text::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextT(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, Compare_Text(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, TextT(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace with some text")), 1, Compare_Text::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextT(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, Compare_Text(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, TextT(STR("Replace")), 1, 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace")), 1, Compare_Text::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextT(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, Compare_Text(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, TextT(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace with some text")), 1, Compare_Text::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextT(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) + { + // Non-overflow short text. + Compare_Text compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, 4, Compare_Text(STR("Replace")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, TextT(STR("Replace")).c_str()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextT(STR("Replace")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, Compare_Text(STR("Replace with some text")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, TextT(STR("Replace with some text")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace with some text")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextT(STR("Replace with some text")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, Compare_Text(STR("Replace")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, TextT(STR("Replace")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextT(STR("Replace")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, Compare_Text(STR("Replace with some text")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, TextT(STR("Replace with some text")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace with some text")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextT(STR("Replace with some text")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer) + { + // Non-overflow short text. + Compare_Text compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, Compare_Text(STR("Replace")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, TextT(STR("Replace")).c_str()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, Compare_Text(STR("Replace with some text")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, TextT(STR("Replace with some text")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, Compare_Text(STR("Replace")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, TextT(STR("Replace")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, Compare_Text(STR("Replace with some text")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, TextT(STR("Replace with some text")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer_n) + { + // Non-overflow short text. + Compare_Text compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, 4, Compare_Text(STR("Replace")).c_str(), 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, TextT(STR("Replace")).c_str(), 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace")).c_str(), 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextT(STR("Replace")).c_str(), 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, Compare_Text(STR("Replace with some text")).c_str(), 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, TextT(STR("Replace with some text")).c_str(), 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace with some text")).c_str(), 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextT(STR("Replace with some text")).c_str(), 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, Compare_Text(STR("Replace")).c_str(), 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, TextT(STR("Replace")).c_str(), 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace")).c_str(), 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextT(STR("Replace")).c_str(), 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, Compare_Text(STR("Replace with some text")).c_str(), 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, TextT(STR("Replace with some text")).c_str(), 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace with some text")).c_str(), 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextT(STR("Replace with some text")).c_str(), 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer_n) + { + // Non-overflow short text. + Compare_Text compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, Compare_Text(STR("Replace")).c_str(), 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, TextT(STR("Replace")).c_str(), 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + +#include "etl/private/diagnostic_array_bounds_push.h" +#include "etl/private/diagnostic_stringop_overread_push.h" + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, Compare_Text(STR("Replace with some text")).c_str(), 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, TextT(STR("Replace with some text")).c_str(), 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif +#include "etl/private/diagnostic_pop.h" +#include "etl/private/diagnostic_pop.h" + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, Compare_Text(STR("Replace")).c_str(), 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, TextT(STR("Replace")).c_str(), 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + +#include "etl/private/diagnostic_array_bounds_push.h" +#include "etl/private/diagnostic_stringop_overread_push.h" + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, Compare_Text(STR("Replace with some text")).c_str(), 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, TextT(STR("Replace with some text")).c_str(), 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif +#include "etl/private/diagnostic_pop.h" +#include "etl/private/diagnostic_pop.h" + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_n_c) + { + // Non-overflow short text. + Compare_Text compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, 4, 7, STR('A')); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, 7, STR('A')); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, Compare_Text::npos, 7, STR('A')); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, 7, STR('A')); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, 15, STR('A')); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, 15, STR('A')); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, Compare_Text::npos, 15, STR('A')); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, 15, STR('A')); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, 7, STR('A')); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, 7, STR('A')); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, Compare_Text::npos, 7, STR('A')); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, 7, STR('A')); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, 15, STR('A')); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, 15, STR('A')); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, Compare_Text::npos, 15, STR('A')); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, 15, STR('A')); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_n_c) + { + // Non-overflow short text. + Compare_Text compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, 7, STR('A')); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, 7, STR('A')); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, 15, STR('A')); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, 15, STR('A')); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, 7, STR('A')); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, 7, STR('A')); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, 15, STR('A')); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, 15, STR('A')); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_first_last) + { + // Non-overflow short text. + Compare_Text compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + Compare_Text replace(STR("Replace")); + Compare_Text replace_long(STR("Replace with some text")); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, replace.begin() + 1, replace.begin() + 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, replace.begin() + 1, replace.begin() + 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, replace_long.begin() + 1, replace_long.begin() + 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, replace_long.begin() + 1, replace_long.begin() + 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 7, replace.begin() + 1, replace.begin() + 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 7, replace_long.begin() + 1, replace_long.begin() + 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, replace_long.begin() + 1, replace_long.begin() + 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, replace_long.begin() + 1, replace_long.begin() + 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_single_iterator) + { + Compare_Text compare_text(initial_text.c_str()); + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + Compare_Text::iterator citr = compare_text.erase(compare_text.begin() + 2); + Text::iterator ditr = text.erase(text.begin() + 2); + CHECK(*citr == *ditr); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_single_const_iterator) + { + Compare_Text compare_text(initial_text.c_str()); + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + Compare_Text::iterator citr = compare_text.erase(compare_text.cbegin() + 2); + Text::iterator ditr = text.erase(text.cbegin() + 2); + CHECK(*citr == *ditr); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_range) + { + Compare_Text compare_text(initial_text.c_str()); + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + Compare_Text::iterator citr = compare_text.erase(compare_text.cbegin() + 2, compare_text.cbegin() + 4); + Text::iterator ditr = text.erase(text.cbegin() + 2, text.cbegin() + 4); + CHECK(*citr == *ditr); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_clear) + { + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + text.clear(); + + CHECK_EQUAL(text.size(), size_t(0)); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_iterator) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + bool is_equal = std::equal(text.begin(), text.end(), compare_text.begin()); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_iterator) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + bool is_equal = std::equal(text.cbegin(), text.cend(), compare_text.cbegin()); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_reverse_iterator) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + bool is_equal = std::equal(text.rbegin(), text.rend(), compare_text.rbegin()); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_const_reverse_iterator) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + bool is_equal = std::equal(text.crbegin(), text.crend(), compare_text.crbegin()); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_equal) + { + TextBuffer buffer{0}; + const Text initial1(initial_text.c_str(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + const Text initial2(initial_text.c_str(), buffer2.data(), buffer2.size()); + + CHECK(initial1 == initial2); + + TextBuffer buffer3; + const Text different(different_text.c_str(), buffer3.data(), buffer3.size()); + + CHECK(!(initial1 == different)); + + TextBuffer buffer4; + const Text shorter(shorter_text.c_str(), buffer4.data(), buffer4.size()); + + CHECK(!(shorter == initial1)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_not_equal) + { + TextBuffer buffer{0}; + const Text initial1(initial_text.c_str(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + const Text initial2(initial_text.c_str(), buffer2.data(), buffer2.size()); + + CHECK(!(initial1 != initial2)); + + TextBuffer buffer3; + const Text different(different_text.begin(), different_text.end(), buffer3.data(), buffer3.size()); + + CHECK(initial1 != different); + + TextBuffer buffer4; + const Text shorter(shorter_text.begin(), shorter_text.end(), buffer4.data(), buffer4.size()); + + CHECK(shorter != initial1); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_less_than) + { + TextBuffer buffer{0}; + const Text less(less_text.c_str(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + const Text initial(initial_text.c_str(), buffer2.data(), buffer2.size()); + + // String-String + CHECK((less < initial) == (less_text < initial_text)); + CHECK((initial < less) == (initial_text < less_text)); + + TextBuffer buffer3; + const Text greater(greater_text.c_str(), buffer3.data(), buffer3.size()); + CHECK((greater < initial) == (greater_text < initial_text)); + CHECK((initial < greater) == (initial_text < greater_text)); + + TextBuffer buffer4; + const Text shorter(shorter_text.c_str(), buffer4.data(), buffer4.size()); + CHECK((shorter < initial) == (shorter_text < initial_text)); + CHECK((initial < shorter) == (initial_text < shorter_text)); + + CHECK((initial < initial) == (initial_text < initial_text)); + CHECK((initial < initial) == (initial_text < initial_text)); + + // String-Pointer Pointer-String + CHECK((less < pinitial_text) == (less_text < pinitial_text)); + CHECK((pinitial_text < less) == (pinitial_text < less_text)); + + CHECK((greater < pinitial_text) == (greater_text < pinitial_text)); + CHECK((pinitial_text < greater) == (pinitial_text < greater_text)); + + CHECK((shorter < pinitial_text) == (shorter_text < pinitial_text)); + CHECK((pinitial_text < shorter) == (pinitial_text < shorter_text)); + + CHECK((initial < pinitial_text) == (initial_text < pinitial_text)); + CHECK((pinitial_text < initial) == (pinitial_text < initial_text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_less_than_or_equal) + { + TextBuffer buffer{0}; + const Text less(less_text.c_str(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + const Text initial(initial_text.c_str(), buffer2.data(), buffer2.size()); + + // String-String + CHECK((less <= initial) == (less_text <= initial_text)); + CHECK((initial <= less) == (initial_text <= less_text)); + + TextBuffer buffer3; + const Text greater(greater_text.c_str(), buffer3.data(), buffer3.size()); + CHECK((greater <= initial) == (greater_text <= initial_text)); + CHECK((initial <= greater) == (initial_text <= greater_text)); + + TextBuffer buffer4; + const Text shorter(shorter_text.c_str(), buffer4.data(), buffer4.size()); + CHECK((shorter <= initial) == (shorter_text <= initial_text)); + CHECK((initial <= shorter) == (initial_text <= shorter_text)); + + CHECK((initial <= initial) == (initial_text <= initial_text)); + CHECK((initial <= initial) == (initial_text <= initial_text)); + + // String-Pointer Pointer-String + CHECK((less <= pinitial_text) == (less_text <= pinitial_text)); + CHECK((pinitial_text <= less) == (pinitial_text <= less_text)); + + CHECK((greater <= pinitial_text) == (greater_text <= pinitial_text)); + CHECK((pinitial_text <= greater) == (pinitial_text <= greater_text)); + + CHECK((shorter <= pinitial_text) == (shorter_text <= pinitial_text)); + CHECK((pinitial_text <= shorter) == (pinitial_text <= shorter_text)); + + CHECK((initial <= pinitial_text) == (initial_text <= pinitial_text)); + CHECK((pinitial_text <= initial) == (pinitial_text <= initial_text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_greater_than) + { + TextBuffer buffer{0}; + const Text less(less_text.c_str(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + const Text initial(initial_text.c_str(), buffer2.data(), buffer2.size()); + + // String-String + CHECK((less > initial) == (less_text > initial_text)); + CHECK((initial > less) == (initial_text > less_text)); + + TextBuffer buffer3; + const Text greater(greater_text.c_str(), buffer3.data(), buffer3.size()); + CHECK((greater > initial) == (greater_text > initial_text)); + CHECK((initial > greater) == (initial_text > greater_text)); + + TextBuffer buffer4; + const Text shorter(shorter_text.c_str(), buffer4.data(), buffer4.size()); + CHECK((shorter > initial) == (shorter_text > initial_text)); + CHECK((initial > shorter) == (initial_text > shorter_text)); + + CHECK((initial > initial) == (initial_text > initial_text)); + CHECK((initial > initial) == (initial_text > initial_text)); + + // String-Pointer Pointer-String + CHECK((less > pinitial_text) == (less_text > pinitial_text)); + CHECK((pinitial_text > less) == (pinitial_text > less_text)); + + CHECK((greater > pinitial_text) == (greater_text > pinitial_text)); + CHECK((pinitial_text > greater) == (pinitial_text > greater_text)); + + CHECK((shorter > pinitial_text) == (shorter_text > pinitial_text)); + CHECK((pinitial_text > shorter) == (pinitial_text > shorter_text)); + + CHECK((initial > pinitial_text) == (initial_text > pinitial_text)); + CHECK((pinitial_text > initial) == (pinitial_text > initial_text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_greater_than_or_equal) + { + TextBuffer buffer{0}; + const Text less(less_text.begin(), less_text.end(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + const Text initial(initial_text.begin(), initial_text.end(), buffer2.data(), buffer2.size()); + + // String-String + CHECK((less >= initial) == (less_text >= initial_text)); + CHECK((initial >= less) == (initial_text >= less_text)); + + TextBuffer buffer3; + const Text greater(greater_text.begin(), greater_text.end(), buffer3.data(), buffer3.size()); + CHECK((greater >= initial) == (greater_text >= initial_text)); + CHECK((initial >= greater) == (initial_text >= greater_text)); + + TextBuffer buffer4; + const Text shorter(shorter_text.begin(), shorter_text.end(), buffer4.data(), buffer4.size()); + CHECK((shorter >= initial) == (shorter_text >= initial_text)); + CHECK((initial >= shorter) == (initial_text > shorter_text)); + + CHECK((initial >= initial) == (initial_text >= initial_text)); + CHECK((initial >= initial) == (initial_text >= initial_text)); + + // String-Pointer Pointer-String + CHECK((less >= pinitial_text) == (less_text >= pinitial_text)); + CHECK((pinitial_text >= less) == (pinitial_text >= less_text)); + + CHECK((greater >= pinitial_text) == (greater_text >= pinitial_text)); + CHECK((pinitial_text >= greater) == (pinitial_text >= greater_text)); + + CHECK((shorter >= pinitial_text) == (shorter_text >= pinitial_text)); + CHECK((pinitial_text >= shorter) == (pinitial_text >= shorter_text)); + + CHECK((initial >= pinitial_text) == (initial_text >= pinitial_text)); + CHECK((pinitial_text >= initial) == (pinitial_text >= initial_text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_copy) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + value_t buffer1[SIZE]; + value_t buffer2[SIZE]; + + size_t length1 = compare_text.copy(buffer1, 5, 2); + buffer1[length1] = STR('\0'); + + size_t length2 = text.copy(buffer2, 5, 2); + buffer2[length2] = STR('\0'); + + CHECK_EQUAL(length1, length2); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + bool is_equal = std::equal(buffer1, + buffer1 + length1, + buffer2); + CHECK(is_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_copy_start_pos_too_large) + { + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + value_t buffer1[SIZE]; + + size_t length1 = text.copy(buffer1, 5, SIZE); + + CHECK_EQUAL(0U, length1); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_copy_count_equals_npos) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + value_t buffer1[SIZE]; + value_t buffer2[SIZE]; + + size_t length1 = compare_text.copy(buffer1, Compare_Text::npos, 2); + buffer1[length1] = STR('\0'); + + size_t length2 = text.copy(buffer2, Text::npos, 2); + buffer2[length2] = STR('\0'); + + CHECK_EQUAL(length1, length2); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + bool is_equal = std::equal(buffer1, + buffer1 + length1, + buffer2); + CHECK(is_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_copy_count_too_large) + { + Compare_Text compare_text(initial_text.c_str()); + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), buffer.data(), buffer.size()); + + value_t buffer1[SIZE]; + value_t buffer2[SIZE]; + + size_t length1 = compare_text.copy(buffer1, SIZE, 2); + buffer1[length1] = STR('\0'); + + size_t length2 = text.copy(buffer2, SIZE, 2); + buffer2[length2] = STR('\0'); + + CHECK_EQUAL(length1, length2); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + bool is_equal = std::equal(buffer1, + buffer1 + length1, + buffer2); + CHECK(is_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_string) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::u16string compare_needle(STR("needle")); + + TextBuffer buffer{0}; + Text needle(STR("needle"), buffer.data(), buffer.size()); + + std::u16string compare_haystack(the_haystack); + + TextBufferL buffer2{0}; + Text haystack(the_haystack, buffer2.data(), buffer2.size()); + + size_t position1 = 0; + size_t position2 = 0; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle, position2 + 1); + CHECK_EQUAL(etl::u16string<50>::npos, position2); + + etl::u16string<50> pin(STR("pin")); + position2 = haystack.find(pin); + CHECK_EQUAL(IText::npos, position2); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_pointer) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + const value_t* needle = STR("needle"); + + std::u16string compare_haystack(the_haystack); + + TextBufferL buffer{0}; + Text haystack(the_haystack, buffer.data(), buffer.size()); + + size_t position1 = 0; + size_t position2 = 0; + + position1 = compare_haystack.find(needle, position1); + position2 = haystack.find(needle, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(needle, position1 + 1); + position2 = haystack.find(needle, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle, position2 + 1); + CHECK_EQUAL(IText::npos, position2); + + const value_t* pin = STR("pin"); + position2 = haystack.find(pin); + CHECK_EQUAL(IText::npos, position2); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_char_pointer_n) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + const value_t* needle = STR("needle"); + + std::u16string compare_haystack(the_haystack); + + TextBufferL buffer{0}; + Text haystack(the_haystack, buffer.data(), buffer.size()); + + size_t position1 = 0; + size_t position2 = 0; + + position1 = compare_haystack.find(needle, position1, 3); + position2 = haystack.find(needle, position2, 3); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(needle, position1 + 1, 3); + position2 = haystack.find(needle, position2 + 1, 3); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle, position2 + 1, 3); + CHECK_EQUAL(IText::npos, position2); + + const value_t* pin = STR("pin"); + position2 = haystack.find(pin, 0, 3); + CHECK_EQUAL(IText::npos, position2); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_string) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::u16string compare_needle(STR("needle")); + + TextBufferL buffer{0}; + Text needle(STR("needle"), buffer.data(), buffer.size()); + + std::u16string compare_haystack(the_haystack); + + TextBufferL buffer2{0}; + Text haystack(the_haystack, buffer2.data(), buffer2.size()); + + size_t position1 = std::u16string::npos; + size_t position2 = etl::u16string<50>::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + TextBufferL buffer3; + Text pin(STR("pin"), buffer3.data(), buffer3.size()); + position2 = haystack.rfind(pin); + CHECK_EQUAL(IText::npos, position2); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_pointer) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::u16string compare_haystack(the_haystack); + + TextBufferL buffer{0}; + Text haystack(the_haystack, buffer.data(), buffer.size()); + + const value_t* needle = STR("needle"); + + size_t position1 = std::u16string::npos; + size_t position2 = etl::u16string<50>::npos; + + position1 = compare_haystack.rfind(needle, position1); + position2 = haystack.rfind(needle, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + TextBufferL buffer2{0}; + Text pin(STR("pin"), buffer2.data(), buffer2.size()); + position2 = haystack.rfind(pin); + CHECK_EQUAL(IText::npos, position2); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_pointer_n) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::u16string compare_haystack(the_haystack); + + TextBufferL buffer{0}; + Text haystack(the_haystack, buffer.data(), buffer.size()); + + const value_t* needle = STR("needle"); + + size_t position1 = std::u16string::npos; + + size_t position2 = Text::npos; + + position1 = compare_haystack.rfind(needle, position1, 3); + position2 = haystack.rfind(needle, position2, 3); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(needle, compare_haystack.size() - 10, 3); + position2 = haystack.rfind(needle, haystack.size() - 10, 3); + CHECK_EQUAL(position1, position2); + + position2 = haystack.rfind(STR("pin"), 3); + CHECK_EQUAL(IText::npos, position2); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_c_position) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::u16string compare_haystack(the_haystack); + + TextBufferL buffer{0}; + Text haystack(the_haystack, buffer.data(), buffer.size()); + + size_t position1 = std::u16string::npos; + size_t position2 = etl::u16string<50>::npos; + + position1 = compare_haystack.rfind(STR('e'), position1); + position2 = haystack.rfind(STR('e'), position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(STR('e'), compare_haystack.size() - 10); + position2 = haystack.rfind(STR('e'), haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + position2 = haystack.rfind(STR('z')); + CHECK_EQUAL(IText::npos, position2); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_string) + { + Compare_Text compare_text(STR("ABCDEF")); + + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(Compare_Text(STR("ABCDEF"))); + result = text.compare(TextT(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(Compare_Text(STR("ABCDEE"))); + result = text.compare(TextT(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(Compare_Text(STR("ABCDEG"))); + result = text.compare(TextT(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(Compare_Text(STR("ABCDE"))); + result = text.compare(TextT(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(Compare_Text(STR("ABCDEFG"))); + result = text.compare(TextT(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_string) + { + Compare_Text compare_text(STR("xxxABCDEFyyy")); + + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, Compare_Text(STR("ABCDEF"))); + result = text.compare(3, 6, TextT(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, Compare_Text(STR("ABCDEE"))); + result = text.compare(3, 6, TextT(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, Compare_Text(STR("ABCDEG"))); + result = text.compare(3, 6, TextT(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, Compare_Text(STR("ABCDE"))); + result = text.compare(3, 6, TextT(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, Compare_Text(STR("ABCDEFG"))); + result = text.compare(3, 6, TextT(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) + { + Compare_Text compare_text(STR("xxxABCDEFyyy")); + + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, Compare_Text(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, TextT(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, Compare_Text(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, TextT(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, Compare_Text(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, TextT(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, Compare_Text(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, TextT(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, Compare_Text(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, TextT(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_c_string) + { + Compare_Text compare_text(STR("ABCDEF")); + + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(STR("ABCDEF")); + result = text.compare(STR("ABCDEF")); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(STR("ABCDEE")); + result = text.compare(STR("ABCDEE")); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(STR("ABCDEG")); + result = text.compare(STR("ABCDEG")); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(STR("ABCDE")); + result = text.compare(STR("ABCDE")); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(STR("ABCDEFG")); + result = text.compare(STR("ABCDEFG")); + CHECK(compares_agree(compare_result, result)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string) + { + Compare_Text compare_text(STR("xxxABCDEFyyy")); + + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, STR("ABCDEF")); + result = text.compare(3, 6, STR("ABCDEF")); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, STR("ABCDEE")); + result = text.compare(3, 6, STR("ABCDEE")); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, STR("ABCDEG")); + result = text.compare(3, 6, STR("ABCDEG")); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, STR("ABCDE")); + result = text.compare(3, 6, STR("ABCDE")); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, STR("ABCDEFG")); + result = text.compare(3, 6, STR("ABCDEFG")); + CHECK(compares_agree(compare_result, result)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string_n) + { + Compare_Text compare_text(STR("xxxABCDEFyyy")); + + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, STR("ABCDEFbb"), 6); + result = text.compare(3, 6, STR("ABCDEFbb"), 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, STR("ABCDEEbb"), 6); + result = text.compare(3, 6, STR("ABCDEEbb"), 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, STR("ABCDEGbb"), 6); + result = text.compare(3, 6, STR("ABCDEGbb"), 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, STR("ABCDEbb"), 5); + result = text.compare(3, 6, STR("ABCDEbb"), 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, STR("ABCDEFGbb"), 7); + result = text.compare(3, 6, STR("ABCDEFGbb"), 7); + CHECK(compares_agree(compare_result, result)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_string_position) + { + Compare_Text compare_text(STR("ABCDEF")); + + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_of(Compare_Text(STR("ZCXF"))); + size_t position2 = text.find_first_of(TextT(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(Compare_Text(STR("WXYZ"))); + position2 = text.find_first_of(TextT(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(Compare_Text(STR("ZCXF")), 3); + position2 = text.find_first_of(TextT(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(Compare_Text(STR("ZCXF")), 100); + position2 = text.find_first_of(TextT(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) + { + Compare_Text compare_text(STR("ABCDEF")); + + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_of(STR("ZCXF")); + size_t position2 = text.find_first_of(STR("ZCXF")); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(STR("WXYZ")); + position2 = text.find_first_of(STR("WXYZ")); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(STR("ZCXF"), 3); + position2 = text.find_first_of(STR("ZCXF"), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(STR("ZCXF"), 100); + position2 = text.find_first_of(STR("ZCXF"), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position_n) + { + Compare_Text compare_text(STR("ABCDEF")); + + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_of(STR("ZCXF"), 0, 4); + size_t position2 = text.find_first_of(STR("ZCXF"), 0, 4); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(STR("WXYZ"), 0, 4); + position2 = text.find_first_of(STR("WXYZ"), 0, 4); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(STR("ZCXF"), 1, 3); + position2 = text.find_first_of(STR("ZCXF"), 1, 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(STR("ZCXF"), 3, 3); + position2 = text.find_first_of(STR("ZCXF"), 3, 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(STR("ZCXF"), 100); + position2 = text.find_first_of(STR("ZCXF"), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_character_position) + { + Compare_Text compare_text(STR("ABCDEF")); + + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_of(STR('C')); + size_t position2 = text.find_first_of(STR('C')); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(STR('Z')); + position2 = text.find_first_of(STR('Z')); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(STR('F'), 3); + position2 = text.find_first_of(STR('F'), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(STR('C'), 3); + position2 = text.find_first_of(STR('C'), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(STR('C'), compare_text.size()); + position2 = text.find_first_of(STR('C'), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(STR('C'), 100); + position2 = text.find_first_of(STR('C'), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_string_position) + { + Compare_Text compare_text(STR("ABCDEFABCDE")); + + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_of(Compare_Text(STR("ZCXE"))); + size_t position2 = text.find_last_of(TextT(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(Compare_Text(STR("WXYZ")), 3); + position2 = text.find_last_of(TextT(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(Compare_Text(STR("ZCXE")), 5); + position2 = text.find_last_of(TextT(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(Compare_Text(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(TextT(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(Compare_Text(STR("ZCXE")), 100); + position2 = text.find_last_of(TextT(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) + { + Compare_Text compare_text(STR("ABCDEFABCDE")); + + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_of(STR("ZCXE")); + size_t position2 = text.find_last_of(STR("ZCXE")); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(STR("WXYZ"), 3); + position2 = text.find_last_of(STR("WXYZ"), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(STR("ZCXE"), 5); + position2 = text.find_last_of(STR("ZCXE"), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(STR("ZCXE"), 6); + position2 = text.find_last_of(STR("ZCXE"), 6); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(STR("ZCXE"), compare_text.size()); + position2 = text.find_last_of(STR("ZCXE"), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(STR("ZCXE"), 100); + position2 = text.find_last_of(STR("ZCXE"), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position_n) + { + Compare_Text compare_text(STR("ABCDEFABCDE")); + + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_of(STR("AZCXE"), 0, 4); + size_t position2 = text.find_last_of(STR("AZCXE"), 0, 4); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(STR("WXYZ"), 4, 3); + position2 = text.find_last_of(STR("WXYZ"), 4, 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(STR("ZCXE"), 5, 3); + position2 = text.find_last_of(STR("ZCXE"), 5, 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(STR("ZCXE"), 1, 3); + position2 = text.find_last_of(STR("ZCXE"), 1, 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(STR("ZCXE"), compare_text.size(), 4); + position2 = text.find_last_of(STR("ZCXE"), text.size(), 4); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(STR("ZCXE"), 100, 4); + position2 = text.find_last_of(STR("ZCXE"), 100, 4); + + CHECK_EQUAL(position1, position2); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_character_position) + { + Compare_Text compare_text(STR("ABCDEF")); + + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_of(STR('C')); + size_t position2 = text.find_last_of(STR('C')); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(STR('Z')); + position2 = text.find_last_of(STR('Z')); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(STR('F'), compare_text.size()); + position2 = text.find_last_of(STR('F'), text.size()); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(STR('C'), 3); + position2 = text.find_last_of(STR('C'), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(STR('C'), compare_text.size()); + position2 = text.find_last_of(STR('C'), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(STR('C'), 100); + position2 = text.find_last_of(STR('C'), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_string_position) + { + Compare_Text compare_text(STR("ABCDEF")); + + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_not_of(Compare_Text(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(TextT(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(Compare_Text(STR("ZAXB"))); + position2 = text.find_first_not_of(TextT(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(Compare_Text(STR("ZAXB")), 3); + position2 = text.find_first_not_of(TextT(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(Compare_Text(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(TextT(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(Compare_Text(STR("ZAXB")), 100); + position2 = text.find_first_not_of(TextT(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) + { + Compare_Text compare_text(STR("ABCDEF")); + + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_not_of(STR("ZAXB")); + size_t position2 = text.find_first_not_of(STR("ZAXB")); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(STR("ZAXB")); + position2 = text.find_first_not_of(STR("ZAXB")); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(STR("ZAXB"), 3); + position2 = text.find_first_not_of(STR("ZAXB"), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(STR("ZAXB"), compare_text.size()); + position2 = text.find_first_not_of(STR("ZAXB"), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(STR("ZAXB"), 100); + position2 = text.find_first_not_of(STR("ZAXB"), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position_n) + { + Compare_Text compare_text(STR("ABCDEF")); + + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_not_of(STR("ZAXB"), 0, 4); + size_t position2 = text.find_first_not_of(STR("ZAXB"), 0, 4); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(STR("ZAXB"), 0, 4); + position2 = text.find_first_not_of(STR("ZAXB"), 0, 4); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(STR("ZAXB"), 1, 3); + position2 = text.find_first_not_of(STR("ZAXB"), 1, 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(STR("ZAXB"), 3, 3); + position2 = text.find_first_not_of(STR("ZAXB"), 3, 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(STR("ZAXB"), compare_text.size(), 3); + position2 = text.find_first_not_of(STR("ZAXB"), text.size(), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(STR("ZAXB"), 100); + position2 = text.find_first_not_of(STR("ZAXB"), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_character_position) + { + Compare_Text compare_text(STR("ABCDEF")); + + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_not_of(STR('A')); + size_t position2 = text.find_first_not_of(STR('A')); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(STR('B')); + position2 = text.find_first_not_of(STR('B')); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(STR('C'), 3); + position2 = text.find_first_not_of(STR('C'), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(STR('D'), 3); + position2 = text.find_first_not_of(STR('D'), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(STR('C'), compare_text.size()); + position2 = text.find_first_not_of(STR('C'), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(STR('C'), 100); + position2 = text.find_first_not_of(STR('C'), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_string_position) + { + Compare_Text compare_text(STR("ABCDEFABCDE")); + + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_not_of(Compare_Text(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(TextT(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(Compare_Text(STR("ZEXD")), 3); + position2 = text.find_last_not_of(TextT(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(Compare_Text(STR("ZEXD")), 5); + position2 = text.find_last_not_of(TextT(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(Compare_Text(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(TextT(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(Compare_Text(STR("ZEXD")), 100); + position2 = text.find_last_not_of(TextT(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) + { + Compare_Text compare_text(STR("ABCDEFABCDE")); + + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_not_of(STR("ZEXD")); + size_t position2 = text.find_last_not_of(STR("ZEXD")); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(STR("ZEXD"), 3); + position2 = text.find_last_not_of(STR("ZEXD"), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(STR("ZEXD"), 5); + position2 = text.find_last_not_of(STR("ZEXD"), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(STR("ZEXD"), compare_text.size()); + position2 = text.find_last_not_of(STR("ZEXD"), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(STR("ZEXD"), 100); + position2 = text.find_last_not_of(STR("ZEXD"), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position_n) + { + Compare_Text compare_text(STR("ABCDEFABCDE")); + + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_not_of(STR("ZEXD"), 0, 4); + size_t position2 = text.find_last_not_of(STR("ZEXD"), 0, 4); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(STR("ZEXD"), 5, 3); + position2 = text.find_last_not_of(STR("ZEXD"), 5, 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(STR("ZEXD"), 1, 3); + position2 = text.find_last_not_of(STR("ZEXD"), 1, 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(STR("ZEXD"), compare_text.size(), 4); + position2 = text.find_last_not_of(STR("ZEXD"), text.size(), 4); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(STR("ZEXD"), 100, 4); + position2 = text.find_last_not_of(STR("ZEXD"), 100, 4); + + CHECK_EQUAL(position1, position2); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_character_position) + { + Compare_Text compare_text(STR("ABCDEF")); + + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_not_of(STR('F')); + size_t position2 = text.find_last_not_of(STR('F')); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(STR('Z')); + position2 = text.find_last_not_of(STR('Z')); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(STR('A'), compare_text.size()); + position2 = text.find_last_not_of(STR('A'), text.size()); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(STR('C'), 3); + position2 = text.find_last_not_of(STR('C'), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(STR('C'), compare_text.size()); + position2 = text.find_last_not_of(STR('C'), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(STR('C'), 100); + position2 = text.find_last_not_of(STR('C'), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_hash) + { + // Test with actual string type. + TextBuffer buffer{0}; + Text text(STR("ABCDEFHIJKL"), buffer.data(), buffer.size()); + size_t hash = etl::hash()(text); + size_t compare_hash = etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); + CHECK_EQUAL(compare_hash, hash); + + // Test with interface string type. + IText& itext = text; + hash = etl::hash()(itext); + CHECK_EQUAL(compare_hash, hash); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_memcpy_repair) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + text.assign(STR("ABCDEF")); + + char buffer2[sizeof(Text)]; + + // Will not copy the buffer! + memcpy(&buffer2, (const void*)&text, sizeof(text)); + + Text& rtext(*reinterpret_cast(buffer2)); + rtext.repair(); + + CHECK(!rtext.empty()); + CHECK(!rtext.full()); + + bool is_equal = Equal(text, rtext); + CHECK(is_equal); + + text = STR("GHIJKL"); + is_equal = Equal(text, rtext); + CHECK(is_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_memcpy_repair_virtual) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + text.assign(STR("ABCDEF")); + + char buffer2[sizeof(Text)]; + + // Will not copy the buffer! + memcpy(&buffer2, (const void*)&text, sizeof(text)); + + IText& itext(*reinterpret_cast(buffer2)); + itext.repair(); + + CHECK(!itext.empty()); + CHECK(!itext.full()); + + bool is_equal = Equal(text, itext); + CHECK(is_equal); + + text = STR("GHIJKL"); + is_equal = Equal(text, itext); + CHECK(is_equal); + } + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_truncate_over_many_operations) + { + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + CHECK(!text.is_truncated()); + + text.insert(3, initial_text.c_str()); + CHECK(text.is_truncated()); + + while (text.size() != 0) + { + text.pop_back(); + CHECK(text.is_truncated()); + } + + text.clear(); + CHECK(!text.is_truncated()); + + text.assign(longer_text.c_str()); + CHECK(text.is_truncated()); + + text.assign(short_text.c_str()); + CHECK(!text.is_truncated()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_add_from_truncated) + { + TextBuffer buffer{0}; + Text text1(short_text.c_str(), buffer.data(), buffer.size()); + + TextBufferS buffers{0}; + Text text2(short_text.c_str(), buffers.data(), buffers.size()); + + CHECK(!text1.is_truncated()); + CHECK(text2.is_truncated()); + + // text2 has the truncate flag set. + text1 += text2; + + CHECK(text1.is_truncated()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_add_to_truncated) + { + TextBuffer buffer{0}; + Text text1(longer_text.c_str(), buffer.data(), buffer.size()); + + TextBuffer buffer2{0}; + Text text2(short_text.c_str(), buffer2.data(), buffer2.size()); + + CHECK(text1.is_truncated()); + CHECK(!text2.is_truncated()); + + // Clear text but not the truncate flag. + text1.erase(text1.begin(), text1.end()); + + // text1 still has the truncate flag set. + text1 += text2; + + CHECK(text1.is_truncated()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_clear_truncated) + { + TextBuffer buffer{0}; + Text text(longer_text.c_str(), buffer.data(), buffer.size()); + CHECK(text.is_truncated()); + + text.clear_truncated(); + CHECK(!text.is_truncated()); + } +#endif + +#if ETL_HAS_STRING_CLEAR_AFTER_USE + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_secure_after_destructor) + { + char buffer[sizeof(Text)]; + std::fill_n(buffer, sizeof(Text), 0); + + TextBuffer buffer2{0}; + ::new (buffer) Text(STR("ABCDEF"), buffer2.data(), buffer2.size()); + + Text& text = *reinterpret_cast(buffer); + text.set_secure(); + + CHECK(TextT(STR("ABCDEF")) == text); + + Text::pointer pb = text.begin(); + Text::pointer pe = text.end(); + + // Destroy the text object. + text.~Text(); + + // Check there no non-zero values in the string. + CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_secure_after_assign) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + text.set_secure(); + text.assign(STR("ABCDEF")); + + Text::pointer pe = text.end(); + + text.assign(STR("ABC")); + + CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_secure_after_resize_down) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + text.set_secure(); + text.assign(STR("ABCDEF")); + + Text::pointer pe = text.end(); + + text.resize(text.size() - 3U); + + CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_secure_after_erase) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + text.set_secure(); + text.assign(STR("ABCDEF")); + + Text::pointer pb = text.begin(); + Text::pointer pe = text.end(); + + text.erase(pb + 2, pb + 5); + + // Check there no non-zero values in the remainder of the string. + CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_secure_after_replace) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + text.set_secure(); + text.assign(STR("ABCDEF")); + + Text::pointer pb = text.begin(); + Text::pointer pe = text.end(); + + text.replace(pb + 1, pb + 4, STR("G")); + + // Check there no non-zero values in the remainder of the string. + CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_secure_after_clear) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + text.set_secure(); + text.assign(STR("ABCDEF")); + + Text::pointer pb = text.begin(); + Text::pointer pe = text.end(); + + text.clear(); + + // Check there no non-zero values in the remainder of the string. + CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy) + { + TextBuffer buffer1{0}; + Text text1(STR("Hello World"), buffer1.data(), buffer1.size()); + text1.set_secure(); + + TextBuffer buffer2{0}; + Text text2(text1, buffer2.data(), buffer2.size()); + + TextBuffer buffer3; + Text text3(buffer3.data(), buffer3.size()); + text3 = text1; + + TextBuffer buffer4; + Text text4(text1, buffer4.data(), buffer4.size(), 6U, 2U); + + CHECK(text2.is_secure()); + CHECK(text3.is_secure()); + CHECK(text4.is_secure()); + } +#endif + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_initialize_free_space_empty_string) + { + TextBuffer buffer1{0}; + TextBuffer buffer2{0}; + Text text(buffer1.data(), buffer1.size()); + Text empty(buffer2.data(), buffer2.size()); + + text.initialize_free_space(); + + CHECK(text.empty()); + CHECK(text == empty); + + for (size_t i = text.size(); i < text.max_size(); ++i) + { + CHECK_EQUAL(0, text[i]); + } + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_initialize_free_space_part_filled_string) + { + TextBuffer buffer1{0}; + TextBuffer buffer2{0}; + Text initial(STR("ABC"), buffer1.data(), buffer1.size()); + Text empty(buffer2.data(), buffer2.size()); + Text text(initial, buffer2.data(), buffer2.size()); + + text.initialize_free_space(); + + CHECK(text == initial); + CHECK(text != empty); + + for (size_t i = text.size(); i < text.max_size(); ++i) + { + CHECK_EQUAL(0, text[i]); + } + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_update_after_c_string_max_size) + { + TextBuffer buffer1{0}; + Text text(buffer1.data(), buffer1.size()); + + text.initialize_free_space(); + std::fill(text.data(), text.data() + text.max_size(), STR('A')); + text.trim_to_terminator(); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + CHECK_EQUAL(text.max_size(), text.size()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_update_after_c_string_shorter_size) + { + TextBuffer buffer1{0}; + Text text(buffer1.data(), buffer1.size()); + + text.initialize_free_space(); + std::fill(text.data(), text.data() + text.max_size() - 1, STR('A')); + text.trim_to_terminator(); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + CHECK_EQUAL(text.max_size() - 1, text.size()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_update_after_c_string_greater_size) + { + TextBuffer buffer1{0}; + Text text(buffer1.data(), buffer1.size()); + + text.initialize_free_space(); + std::fill(text.data(), text.data() + text.max_size() + 1, STR('A')); // Overwrites to terminating null. + text.trim_to_terminator(); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + CHECK_EQUAL(text.max_size(), text.size()); } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) -// { -//#include "etl/private/diagnostic_array_bounds_push.h" -// for (size_t offset = 0UL; offset <= initial_text.size(); ++offset) -// { -// Compare_Text compare_text(initial_text.cbegin(), initial_text.cend()); -// -// TextBuffer buffer{ 0 }; -// Text text(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{ 0 }; -// Text insert(insert_text.begin(), insert_text.end(), buffer2.data(), buffer2.size()); -// -// text.insert(offset, insert); -// compare_text.insert(offset, insert_text); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -//#include "etl/private/diagnostic_pop.h" -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_from_truncated) -// { -// for (size_t offset = 0UL; offset <= short_text.size(); ++offset) -// { -// Compare_Text compare_text(short_text.cbegin(), short_text.cend()); -// -// TextBuffer buffer{0}; -// Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// Text insert(longer_text.begin(), longer_text.end(), buffer2.data(), buffer2.size()); -// -// insert.erase(insert.cbegin(), insert.cend()); -// insert.append(insert_text.cbegin(), insert_text.cend()); -// -// text.insert(offset, insert); -// compare_text.insert(offset, insert_text); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_subpos_sunlen) -// { -// Compare_Text compare_text(short_text.cbegin(), short_text.cend()); -// -// TextBuffer buffer{0}; -// Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// Text insert(insert_text.begin(), insert_text.end(), buffer2.data(), buffer2.size()); -// -// text.insert(0, insert, 0, insert.size()); -// compare_text.insert(0, insert_text, 0, insert_text.size()); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// compare_text.assign(short_text.cbegin(), short_text.cend()); -// text.assign(short_text.cbegin(), short_text.cend()); -// -// text.insert(2, insert, 2, insert.size() - 2); -// compare_text.insert(2, insert_text, 2, insert_text.size() - 2); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// -// CHECK_EQUAL(compare_text.size(), text.size()); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// compare_text.assign(short_text.cbegin(), short_text.cend()); -// text.assign(short_text.cbegin(), short_text.cend()); -// -// text.insert(short_text.size(), insert, 0, insert.size()); -// compare_text.insert(short_text.size(), insert_text, 0, insert_text.size()); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_append_string) -// { -// Compare_Text compare_text(short_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// Text append(insert_text.c_str(), buffer2.data(), buffer2.size()); -// -// // Non-overflow. -// compare_text.append(insert_text); -// text.append(append); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// append.assign(initial_text.c_str()); -// -// compare_text.append(initial_text); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.append(append); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_append_truncated_string) -// { -//#include "etl/private/diagnostic_array_bounds_push.h" -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// -// TextBufferS buffers{0}; -// Text append(short_text.c_str(), buffers.data(), buffers.size()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(append.is_truncated()); -//#endif -// -// text.append(append); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -//#include "etl/private/diagnostic_pop.h" -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_append_string_to_self) -// { -// Compare_Text compare_text(short_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// -// // Non-overflow. -// compare_text.append(compare_text); -// text.append(text); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow. -// compare_text.assign(shorter_text.c_str()); -// text.assign(shorter_text.c_str()); -// -// compare_text.append(compare_text); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.append(text); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_append_string_subpos_sublen) -// { -// Compare_Text compare_text(short_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// Text append(insert_text.c_str(), buffer2.data(), buffer2.size()); -// -// // Whole string. -// compare_text.append(insert_text, 0, std::u16string::npos); -// text.append(append, 0, Text::npos); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Partial string. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// append.assign(initial_text.c_str()); -// -// compare_text.append(short_text, 1, 3); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.append(append, 1, 3); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// append.assign(initial_text.c_str()); -// -// compare_text.append(initial_text, 1, initial_text.size()); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.append(append, 1, append.size()); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_append_truncated_string_subpos_sublen) -// { -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// -// TextBufferS buffer2{0}; -// Text append(short_text.c_str(), buffer2.data(), buffer2.size()); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(append.is_truncated()); -//#endif -// -// text.append(append, 1, 2); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_append_c_string) -// { -// // Non-overflow. -// Compare_Text compare_text(short_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// -// // Whole string. -// compare_text.append(insert_text.c_str()); -// text.append(insert_text.c_str()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.append(initial_text.c_str()); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.append(initial_text.c_str()); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_append_n_c) -// { -// // Non-overflow. -// Compare_Text compare_text(short_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// -// // Non-overflow. -// compare_text.append(5, STR('A')); -// text.append(5, STR('A')); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.append(SIZE, STR('A')); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.append(SIZE, STR('A')); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_append_range) -// { -// // Non-overflow. -// Compare_Text compare_text(short_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// Text append(insert_text.c_str(), buffer2.data(), buffer2.size()); -// -// compare_text.append(insert_text.begin(), insert_text.end()); -// text.append(append.begin(), append.end()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// append.assign(initial_text.c_str()); -// -// compare_text.append(initial_text.begin(), initial_text.end()); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.append(append.begin(), append.end()); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_replace_position_length_string) -// { -// // Non-overflow short text, npos. -// Compare_Text compare_text(short_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// -// compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace"))); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, TextT(STR("Replace"))); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Non-overflow short text. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(2, 2, Compare_Text(STR("Replace"))); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 2, TextT(STR("Replace"))); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow short text. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(2, 2, Compare_Text(STR("Replace with some text"))); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 2, TextT(STR("Replace with some text"))); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Overflow short text, npos. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace with some text"))); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, TextT(STR("Replace with some text"))); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Non-overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, 7, Compare_Text(STR("Replace"))); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 7, TextT(STR("Replace"))); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, 2, Compare_Text(STR("Replace with some text"))); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 2, TextT(STR("Replace with some text"))); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Overflow, npos. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace with some text"))); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, TextT(STR("Replace with some text"))); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_replace_first_last_string) -// { -// // Non-overflow short text. -// Compare_Text compare_text(short_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, Compare_Text(STR("Replace"))); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 4, TextT(STR("Replace"))); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow short text. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, Compare_Text(STR("Replace with some text"))); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 4, TextT(STR("Replace with some text"))); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Non-overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, Compare_Text(STR("Replace"))); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 9, TextT(STR("Replace"))); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, Compare_Text(STR("Replace with some text"))); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 4, TextT(STR("Replace with some text"))); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) -// { -// // Non-overflow short text. -// Compare_Text compare_text(short_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// -// compare_text.replace(2, 4, Compare_Text(STR("Replace")), 1, 5); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 4, TextT(STR("Replace")), 1, 5); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Non-overflow short text, npos. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace")), 1, Compare_Text::npos); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, TextT(STR("Replace")), 1, Text::npos); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow short text. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(2, 4, Compare_Text(STR("Replace with some text")), 1, 15); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 4, TextT(STR("Replace with some text")), 1, 15); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Overflow short text, npos. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace with some text")), 1, Compare_Text::npos); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, TextT(STR("Replace with some text")), 1, Text::npos); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Non-overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, 7, Compare_Text(STR("Replace")), 1, 5); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 7, TextT(STR("Replace")), 1, 5); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Non-overflow, npos. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace")), 1, Compare_Text::npos); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, TextT(STR("Replace")), 1, Text::npos); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, 4, Compare_Text(STR("Replace with some text")), 1, 15); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 4, TextT(STR("Replace with some text")), 1, 15); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Overflow, npos. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace with some text")), 1, Compare_Text::npos); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, TextT(STR("Replace with some text")), 1, Text::npos); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) -// { -// // Non-overflow short text. -// Compare_Text compare_text(short_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// -// compare_text.replace(2, 4, Compare_Text(STR("Replace")).c_str()); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 4, TextT(STR("Replace")).c_str()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Non-overflow short text, npos. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace")).c_str()); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, TextT(STR("Replace")).c_str()); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow short text. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(2, 4, Compare_Text(STR("Replace with some text")).c_str()); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 4, TextT(STR("Replace with some text")).c_str()); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Overflow short text, npos. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace with some text")).c_str()); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, TextT(STR("Replace with some text")).c_str()); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Non-overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, 7, Compare_Text(STR("Replace")).c_str()); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 7, TextT(STR("Replace")).c_str()); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Non-overflow, npos. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace")).c_str()); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, TextT(STR("Replace")).c_str()); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, 4, Compare_Text(STR("Replace with some text")).c_str()); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 4, TextT(STR("Replace with some text")).c_str()); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Overflow, npos. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace with some text")).c_str()); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, TextT(STR("Replace with some text")).c_str()); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer) -// { -// // Non-overflow short text. -// Compare_Text compare_text(short_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, Compare_Text(STR("Replace")).c_str()); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 4, TextT(STR("Replace")).c_str()); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow short text. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, Compare_Text(STR("Replace with some text")).c_str()); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 4, TextT(STR("Replace with some text")).c_str()); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Non-overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, Compare_Text(STR("Replace")).c_str()); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 9, TextT(STR("Replace")).c_str()); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, Compare_Text(STR("Replace with some text")).c_str()); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 4, TextT(STR("Replace with some text")).c_str()); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer_n) -// { -// // Non-overflow short text. -// Compare_Text compare_text(short_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// -// compare_text.replace(2, 4, Compare_Text(STR("Replace")).c_str(), 5); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 4, TextT(STR("Replace")).c_str(), 5); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Non-overflow short text, npos. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace")).c_str(), 5); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, TextT(STR("Replace")).c_str(), 5); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow short text. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(2, 4, Compare_Text(STR("Replace with some text")).c_str(), 15); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 4, TextT(STR("Replace with some text")).c_str(), 15); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Overflow short text, npos. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace with some text")).c_str(), 15); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, TextT(STR("Replace with some text")).c_str(), 15); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Non-overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, 7, Compare_Text(STR("Replace")).c_str(), 5); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 7, TextT(STR("Replace")).c_str(), 5); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Non-overflow, npos. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace")).c_str(), 5); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, TextT(STR("Replace")).c_str(), 5); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, 4, Compare_Text(STR("Replace with some text")).c_str(), 15); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 4, TextT(STR("Replace with some text")).c_str(), 15); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Overflow, npos. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace with some text")).c_str(), 15); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, TextT(STR("Replace with some text")).c_str(), 15); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer_n) -// { -// // Non-overflow short text. -// Compare_Text compare_text(short_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, Compare_Text(STR("Replace")).c_str(), 5); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 4, TextT(STR("Replace")).c_str(), 5); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -//#include "etl/private/diagnostic_array_bounds_push.h" -//#include "etl/private/diagnostic_stringop_overread_push.h" -// // Overflow short text. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, Compare_Text(STR("Replace with some text")).c_str(), 15); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 4, TextT(STR("Replace with some text")).c_str(), 15); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -//#include "etl/private/diagnostic_pop.h" -//#include "etl/private/diagnostic_pop.h" -// -// // Non-overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, Compare_Text(STR("Replace")).c_str(), 5); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 9, TextT(STR("Replace")).c_str(), 5); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -//#include "etl/private/diagnostic_array_bounds_push.h" -//#include "etl/private/diagnostic_stringop_overread_push.h" -// // Overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, Compare_Text(STR("Replace with some text")).c_str(), 15); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 4, TextT(STR("Replace with some text")).c_str(), 15); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -//#include "etl/private/diagnostic_pop.h" -//#include "etl/private/diagnostic_pop.h" -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_replace_position_length_n_c) -// { -// // Non-overflow short text. -// Compare_Text compare_text(short_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// -// compare_text.replace(2, 4, 7, STR('A')); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 4, 7, STR('A')); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Non-overflow short text, npos. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(2, Compare_Text::npos, 7, STR('A')); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, 7, STR('A')); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow short text. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(2, 4, 15, STR('A')); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 4, 15, STR('A')); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Overflow short text, npos. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(2, Compare_Text::npos, 15, STR('A')); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, 15, STR('A')); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Non-overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, 7, 7, STR('A')); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 7, 7, STR('A')); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Non-overflow, npos. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, Compare_Text::npos, 7, STR('A')); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, 7, STR('A')); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, 4, 15, STR('A')); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, 4, 15, STR('A')); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Overflow, npos. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(2, Compare_Text::npos, 15, STR('A')); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(2, Text::npos, 15, STR('A')); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_replace_first_last_n_c) -// { -// // Non-overflow short text. -// Compare_Text compare_text(short_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, 7, STR('A')); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 4, 7, STR('A')); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow short text. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, 15, STR('A')); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 4, 15, STR('A')); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Non-overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, 7, STR('A')); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 9, 7, STR('A')); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, 15, STR('A')); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 4, 15, STR('A')); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_replace_first_last_first_last) -// { -// // Non-overflow short text. -// Compare_Text compare_text(short_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// -// Compare_Text replace(STR("Replace")); -// Compare_Text replace_long(STR("Replace with some text")); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, replace.begin() + 1, replace.begin() + 5); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 4, replace.begin() + 1, replace.begin() + 5); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow short text. -// compare_text.assign(short_text.c_str()); -// text.assign(short_text.c_str()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, replace_long.begin() + 1, replace_long.begin() + 15); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 4, replace_long.begin() + 1, replace_long.begin() + 15); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// -// // Non-overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 7, replace.begin() + 1, replace.begin() + 5); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 7, replace_long.begin() + 1, replace_long.begin() + 5); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// // Overflow. -// compare_text.assign(initial_text.c_str()); -// text.assign(initial_text.c_str()); -// -// compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, replace_long.begin() + 1, replace_long.begin() + 15); -// compare_text.resize(std::min(compare_text.size(), SIZE)); -// text.replace(text.begin() + 2, text.begin() + 4, replace_long.begin() + 1, replace_long.begin() + 15); -// -// is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_erase_single_iterator) -// { -// Compare_Text compare_text(initial_text.c_str()); -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// Compare_Text::iterator citr = compare_text.erase(compare_text.begin() + 2); -// Text::iterator ditr = text.erase(text.begin() + 2); -// CHECK(*citr == *ditr); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_erase_single_const_iterator) -// { -// Compare_Text compare_text(initial_text.c_str()); -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// Compare_Text::iterator citr = compare_text.erase(compare_text.cbegin() + 2); -// Text::iterator ditr = text.erase(text.cbegin() + 2); -// CHECK(*citr == *ditr); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_erase_range) -// { -// Compare_Text compare_text(initial_text.c_str()); -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// Compare_Text::iterator citr = compare_text.erase(compare_text.cbegin() + 2, compare_text.cbegin() + 4); -// Text::iterator ditr = text.erase(text.cbegin() + 2, text.cbegin() + 4); -// CHECK(*citr == *ditr); -// -// bool is_equal = Equal(compare_text, text); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_clear) -// { -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// text.clear(); -// -// CHECK_EQUAL(text.size(), size_t(0)); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_iterator) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// bool is_equal = std::equal(text.begin(), text.end(), compare_text.begin()); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_const_iterator) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// bool is_equal = std::equal(text.cbegin(), text.cend(), compare_text.cbegin()); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_reverse_iterator) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// bool is_equal = std::equal(text.rbegin(), text.rend(), compare_text.rbegin()); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_const_reverse_iterator) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// bool is_equal = std::equal(text.crbegin(), text.crend(), compare_text.crbegin()); -// CHECK(is_equal); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_equal) -// { -// TextBuffer buffer{0}; -// const Text initial1(initial_text.c_str(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// const Text initial2(initial_text.c_str(), buffer2.data(), buffer2.size()); -// -// CHECK(initial1 == initial2); -// -// TextBuffer buffer3; -// const Text different(different_text.c_str(), buffer3.data(), buffer3.size()); -// -// CHECK(!(initial1 == different)); -// -// TextBuffer buffer4; -// const Text shorter(shorter_text.c_str(), buffer4.data(), buffer4.size()); -// -// CHECK(!(shorter == initial1)); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_not_equal) -// { -// TextBuffer buffer{0}; -// const Text initial1(initial_text.c_str(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// const Text initial2(initial_text.c_str(), buffer2.data(), buffer2.size()); -// -// CHECK(!(initial1 != initial2)); -// -// TextBuffer buffer3; -// const Text different(different_text.begin(), different_text.end(), buffer3.data(), buffer3.size()); -// -// CHECK(initial1 != different); -// -// TextBuffer buffer4; -// const Text shorter(shorter_text.begin(), shorter_text.end(), buffer4.data(), buffer4.size()); -// -// CHECK(shorter != initial1); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_less_than) -// { -// TextBuffer buffer{0}; -// const Text less(less_text.c_str(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// const Text initial(initial_text.c_str(), buffer2.data(), buffer2.size()); -// -// // String-String -// CHECK((less < initial) == (less_text < initial_text)); -// CHECK((initial < less) == (initial_text < less_text)); -// -// TextBuffer buffer3; -// const Text greater(greater_text.c_str(), buffer3.data(), buffer3.size()); -// CHECK((greater < initial) == (greater_text < initial_text)); -// CHECK((initial < greater) == (initial_text < greater_text)); -// -// TextBuffer buffer4; -// const Text shorter(shorter_text.c_str(), buffer4.data(), buffer4.size()); -// CHECK((shorter < initial) == (shorter_text < initial_text)); -// CHECK((initial < shorter) == (initial_text < shorter_text)); -// -// CHECK((initial < initial) == (initial_text < initial_text)); -// CHECK((initial < initial) == (initial_text < initial_text)); -// -// // String-Pointer Pointer-String -// CHECK((less < pinitial_text) == (less_text < pinitial_text)); -// CHECK((pinitial_text < less) == (pinitial_text < less_text)); -// -// CHECK((greater < pinitial_text) == (greater_text < pinitial_text)); -// CHECK((pinitial_text < greater) == (pinitial_text < greater_text)); -// -// CHECK((shorter < pinitial_text) == (shorter_text < pinitial_text)); -// CHECK((pinitial_text < shorter) == (pinitial_text < shorter_text)); -// -// CHECK((initial < pinitial_text) == (initial_text < pinitial_text)); -// CHECK((pinitial_text < initial) == (pinitial_text < initial_text)); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_less_than_or_equal) -// { -// TextBuffer buffer{0}; -// const Text less(less_text.c_str(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// const Text initial(initial_text.c_str(), buffer2.data(), buffer2.size()); -// -// // String-String -// CHECK((less <= initial) == (less_text <= initial_text)); -// CHECK((initial <= less) == (initial_text <= less_text)); -// -// TextBuffer buffer3; -// const Text greater(greater_text.c_str(), buffer3.data(), buffer3.size()); -// CHECK((greater <= initial) == (greater_text <= initial_text)); -// CHECK((initial <= greater) == (initial_text <= greater_text)); -// -// TextBuffer buffer4; -// const Text shorter(shorter_text.c_str(), buffer4.data(), buffer4.size()); -// CHECK((shorter <= initial) == (shorter_text <= initial_text)); -// CHECK((initial <= shorter) == (initial_text <= shorter_text)); -// -// CHECK((initial <= initial) == (initial_text <= initial_text)); -// CHECK((initial <= initial) == (initial_text <= initial_text)); -// -// // String-Pointer Pointer-String -// CHECK((less <= pinitial_text) == (less_text <= pinitial_text)); -// CHECK((pinitial_text <= less) == (pinitial_text <= less_text)); -// -// CHECK((greater <= pinitial_text) == (greater_text <= pinitial_text)); -// CHECK((pinitial_text <= greater) == (pinitial_text <= greater_text)); -// -// CHECK((shorter <= pinitial_text) == (shorter_text <= pinitial_text)); -// CHECK((pinitial_text <= shorter) == (pinitial_text <= shorter_text)); -// -// CHECK((initial <= pinitial_text) == (initial_text <= pinitial_text)); -// CHECK((pinitial_text <= initial) == (pinitial_text <= initial_text)); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_greater_than) -// { -// TextBuffer buffer{0}; -// const Text less(less_text.c_str(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// const Text initial(initial_text.c_str(), buffer2.data(), buffer2.size()); -// -// // String-String -// CHECK((less > initial) == (less_text > initial_text)); -// CHECK((initial > less) == (initial_text > less_text)); -// -// TextBuffer buffer3; -// const Text greater(greater_text.c_str(), buffer3.data(), buffer3.size()); -// CHECK((greater > initial) == (greater_text > initial_text)); -// CHECK((initial > greater) == (initial_text > greater_text)); -// -// TextBuffer buffer4; -// const Text shorter(shorter_text.c_str(), buffer4.data(), buffer4.size()); -// CHECK((shorter > initial) == (shorter_text > initial_text)); -// CHECK((initial > shorter) == (initial_text > shorter_text)); -// -// CHECK((initial > initial) == (initial_text > initial_text)); -// CHECK((initial > initial) == (initial_text > initial_text)); -// -// // String-Pointer Pointer-String -// CHECK((less > pinitial_text) == (less_text > pinitial_text)); -// CHECK((pinitial_text > less) == (pinitial_text > less_text)); -// -// CHECK((greater > pinitial_text) == (greater_text > pinitial_text)); -// CHECK((pinitial_text > greater) == (pinitial_text > greater_text)); -// -// CHECK((shorter > pinitial_text) == (shorter_text > pinitial_text)); -// CHECK((pinitial_text > shorter) == (pinitial_text > shorter_text)); -// -// CHECK((initial > pinitial_text) == (initial_text > pinitial_text)); -// CHECK((pinitial_text > initial) == (pinitial_text > initial_text)); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_greater_than_or_equal) -// { -// TextBuffer buffer{0}; -// const Text less(less_text.begin(), less_text.end(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// const Text initial(initial_text.begin(), initial_text.end(), buffer2.data(), buffer2.size()); -// -// // String-String -// CHECK((less >= initial) == (less_text >= initial_text)); -// CHECK((initial >= less) == (initial_text >= less_text)); -// -// TextBuffer buffer3; -// const Text greater(greater_text.begin(), greater_text.end(), buffer3.data(), buffer3.size()); -// CHECK((greater >= initial) == (greater_text >= initial_text)); -// CHECK((initial >= greater) == (initial_text >= greater_text)); -// -// TextBuffer buffer4; -// const Text shorter(shorter_text.begin(), shorter_text.end(), buffer4.data(), buffer4.size()); -// CHECK((shorter >= initial) == (shorter_text >= initial_text)); -// CHECK((initial >= shorter) == (initial_text > shorter_text)); -// -// CHECK((initial >= initial) == (initial_text >= initial_text)); -// CHECK((initial >= initial) == (initial_text >= initial_text)); -// -// // String-Pointer Pointer-String -// CHECK((less >= pinitial_text) == (less_text >= pinitial_text)); -// CHECK((pinitial_text >= less) == (pinitial_text >= less_text)); -// -// CHECK((greater >= pinitial_text) == (greater_text >= pinitial_text)); -// CHECK((pinitial_text >= greater) == (pinitial_text >= greater_text)); -// -// CHECK((shorter >= pinitial_text) == (shorter_text >= pinitial_text)); -// CHECK((pinitial_text >= shorter) == (pinitial_text >= shorter_text)); -// -// CHECK((initial >= pinitial_text) == (initial_text >= pinitial_text)); -// CHECK((pinitial_text >= initial) == (pinitial_text >= initial_text)); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_copy) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// value_t buffer1[SIZE]; -// value_t buffer2[SIZE]; -// -// size_t length1 = compare_text.copy(buffer1, 5, 2); -// buffer1[length1] = STR('\0'); -// -// size_t length2 = text.copy(buffer2, 5, 2); -// buffer2[length2] = STR('\0'); -// -// CHECK_EQUAL(length1, length2); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// bool is_equal = std::equal(buffer1, -// buffer1 + length1, -// buffer2); -// CHECK(is_equal); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_copy_start_pos_too_large) -// { -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// value_t buffer1[SIZE]; -// -// size_t length1 = text.copy(buffer1, 5, SIZE); -// -// CHECK_EQUAL(0U, length1); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_copy_count_equals_npos) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// value_t buffer1[SIZE]; -// value_t buffer2[SIZE]; -// -// size_t length1 = compare_text.copy(buffer1, Compare_Text::npos, 2); -// buffer1[length1] = STR('\0'); -// -// size_t length2 = text.copy(buffer2, Text::npos, 2); -// buffer2[length2] = STR('\0'); -// -// CHECK_EQUAL(length1, length2); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// bool is_equal = std::equal(buffer1, -// buffer1 + length1, -// buffer2); -// CHECK(is_equal); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_copy_count_too_large) -// { -// Compare_Text compare_text(initial_text.c_str()); -// -// TextBuffer buffer{0}; -// Text text(initial_text.c_str(), buffer.data(), buffer.size()); -// -// value_t buffer1[SIZE]; -// value_t buffer2[SIZE]; -// -// size_t length1 = compare_text.copy(buffer1, SIZE, 2); -// buffer1[length1] = STR('\0'); -// -// size_t length2 = text.copy(buffer2, SIZE, 2); -// buffer2[length2] = STR('\0'); -// -// CHECK_EQUAL(length1, length2); -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// -// bool is_equal = std::equal(buffer1, -// buffer1 + length1, -// buffer2); -// CHECK(is_equal); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_string) -// { -// const value_t* the_haystack = STR("A haystack with a needle and another needle"); -// -// std::u16string compare_needle(STR("needle")); -// -// TextBuffer buffer{0}; -// Text needle(STR("needle"), buffer.data(), buffer.size()); -// -// std::u16string compare_haystack(the_haystack); -// -// TextBufferL buffer2{0}; -// Text haystack(the_haystack, buffer2.data(), buffer2.size()); -// -// size_t position1 = 0; -// size_t position2 = 0; -// -// position1 = compare_haystack.find(compare_needle, position1); -// position2 = haystack.find(needle, position2); -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_haystack.find(compare_needle, position1 + 1); -// position2 = haystack.find(needle, position2 + 1); -// CHECK_EQUAL(position1, position2); -// -// position2 = haystack.find(needle, position2 + 1); -// CHECK_EQUAL(etl::u16string<50>::npos, position2); -// -// etl::u16string<50> pin(STR("pin")); -// position2 = haystack.find(pin); -// CHECK_EQUAL(IText::npos, position2); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_pointer) -// { -// const value_t* the_haystack = STR("A haystack with a needle and another needle"); -// -// const value_t* needle = STR("needle"); -// -// std::u16string compare_haystack(the_haystack); -// -// TextBufferL buffer{0}; -// Text haystack(the_haystack, buffer.data(), buffer.size()); -// -// size_t position1 = 0; -// size_t position2 = 0; -// -// position1 = compare_haystack.find(needle, position1); -// position2 = haystack.find(needle, position2); -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_haystack.find(needle, position1 + 1); -// position2 = haystack.find(needle, position2 + 1); -// CHECK_EQUAL(position1, position2); -// -// position2 = haystack.find(needle, position2 + 1); -// CHECK_EQUAL(IText::npos, position2); -// -// const value_t* pin = STR("pin"); -// position2 = haystack.find(pin); -// CHECK_EQUAL(IText::npos, position2); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_char_pointer_n) -// { -// const value_t* the_haystack = STR("A haystack with a needle and another needle"); -// -// const value_t* needle = STR("needle"); -// -// std::u16string compare_haystack(the_haystack); -// -// TextBufferL buffer{0}; -// Text haystack(the_haystack, buffer.data(), buffer.size()); -// -// size_t position1 = 0; -// size_t position2 = 0; -// -// position1 = compare_haystack.find(needle, position1, 3); -// position2 = haystack.find(needle, position2, 3); -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_haystack.find(needle, position1 + 1, 3); -// position2 = haystack.find(needle, position2 + 1, 3); -// CHECK_EQUAL(position1, position2); -// -// position2 = haystack.find(needle, position2 + 1, 3); -// CHECK_EQUAL(IText::npos, position2); -// -// const value_t* pin = STR("pin"); -// position2 = haystack.find(pin, 0, 3); -// CHECK_EQUAL(IText::npos, position2); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_rfind_string) -// { -// const value_t* the_haystack = STR("A haystack with a needle and another needle"); -// -// std::u16string compare_needle(STR("needle")); -// -// TextBufferL buffer{0}; -// Text needle(STR("needle"), buffer.data(), buffer.size()); -// -// std::u16string compare_haystack(the_haystack); -// -// TextBufferL buffer2{0}; -// Text haystack(the_haystack, buffer2.data(), buffer2.size()); -// -// size_t position1 = std::u16string::npos; -// size_t position2 = etl::u16string<50>::npos; -// -// position1 = compare_haystack.rfind(compare_needle, position1); -// position2 = haystack.rfind(needle, position2); -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); -// position2 = haystack.rfind(needle, haystack.size() - 10); -// CHECK_EQUAL(position1, position2); -// -// TextBufferL buffer3; -// Text pin(STR("pin"), buffer3.data(), buffer3.size()); -// position2 = haystack.rfind(pin); -// CHECK_EQUAL(IText::npos, position2); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_rfind_pointer) -// { -// const value_t* the_haystack = STR("A haystack with a needle and another needle"); -// -// std::u16string compare_haystack(the_haystack); -// -// TextBufferL buffer{0}; -// Text haystack(the_haystack, buffer.data(), buffer.size()); -// -// const value_t* needle = STR("needle"); -// -// size_t position1 = std::u16string::npos; -// size_t position2 = etl::u16string<50>::npos; -// -// position1 = compare_haystack.rfind(needle, position1); -// position2 = haystack.rfind(needle, position2); -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_haystack.rfind(needle, compare_haystack.size() - 10); -// position2 = haystack.rfind(needle, haystack.size() - 10); -// CHECK_EQUAL(position1, position2); -// -// TextBufferL buffer2{0}; -// Text pin(STR("pin"), buffer2.data(), buffer2.size()); -// position2 = haystack.rfind(pin); -// CHECK_EQUAL(IText::npos, position2); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_rfind_pointer_n) -// { -// const value_t* the_haystack = STR("A haystack with a needle and another needle"); -// -// std::u16string compare_haystack(the_haystack); -// -// TextBufferL buffer{0}; -// Text haystack(the_haystack, buffer.data(), buffer.size()); -// -// const value_t* needle = STR("needle"); -// -// size_t position1 = std::u16string::npos; -// -// size_t position2 = Text::npos; -// -// position1 = compare_haystack.rfind(needle, position1, 3); -// position2 = haystack.rfind(needle, position2, 3); -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_haystack.rfind(needle, compare_haystack.size() - 10, 3); -// position2 = haystack.rfind(needle, haystack.size() - 10, 3); -// CHECK_EQUAL(position1, position2); -// -// position2 = haystack.rfind(STR("pin"), 3); -// CHECK_EQUAL(IText::npos, position2); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_rfind_c_position) -// { -// const value_t* the_haystack = STR("A haystack with a needle and another needle"); -// -// std::u16string compare_haystack(the_haystack); -// -// TextBufferL buffer{0}; -// Text haystack(the_haystack, buffer.data(), buffer.size()); -// -// size_t position1 = std::u16string::npos; -// size_t position2 = etl::u16string<50>::npos; -// -// position1 = compare_haystack.rfind(STR('e'), position1); -// position2 = haystack.rfind(STR('e'), position2); -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_haystack.rfind(STR('e'), compare_haystack.size() - 10); -// position2 = haystack.rfind(STR('e'), haystack.size() - 10); -// CHECK_EQUAL(position1, position2); -// -// position2 = haystack.rfind(STR('z')); -// CHECK_EQUAL(IText::npos, position2); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_compare_string) -// { -// Compare_Text compare_text(STR("ABCDEF")); -// -// TextBuffer buffer{0}; -// Text text(STR("ABCDEF"), buffer.data(), buffer.size()); -// -// int compare_result; -// int result; -// -// // Equal. -// compare_result = compare_text.compare(Compare_Text(STR("ABCDEF"))); -// result = text.compare(TextT(STR("ABCDEF"))); -// CHECK(compares_agree(compare_result, result)); -// -// // Less. -// compare_result = compare_text.compare(Compare_Text(STR("ABCDEE"))); -// result = text.compare(TextT(STR("ABCDEE"))); -// CHECK(compares_agree(compare_result, result)); -// -// // Greater. -// compare_result = compare_text.compare(Compare_Text(STR("ABCDEG"))); -// result = text.compare(TextT(STR("ABCDEG"))); -// CHECK(compares_agree(compare_result, result)); -// -// // Shorter. -// compare_result = compare_text.compare(Compare_Text(STR("ABCDE"))); -// result = text.compare(TextT(STR("ABCDE"))); -// CHECK(compares_agree(compare_result, result)); -// -// // Longer. -// compare_result = compare_text.compare(Compare_Text(STR("ABCDEFG"))); -// result = text.compare(TextT(STR("ABCDEFG"))); -// CHECK(compares_agree(compare_result, result)); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_compare_position_length_string) -// { -// Compare_Text compare_text(STR("xxxABCDEFyyy")); -// -// TextBuffer buffer{0}; -// Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); -// -// int compare_result; -// int result; -// -// // Equal. -// compare_result = compare_text.compare(3, 6, Compare_Text(STR("ABCDEF"))); -// result = text.compare(3, 6, TextT(STR("ABCDEF"))); -// CHECK(compares_agree(compare_result, result)); -// -// // Less. -// compare_result = compare_text.compare(3, 6, Compare_Text(STR("ABCDEE"))); -// result = text.compare(3, 6, TextT(STR("ABCDEE"))); -// CHECK(compares_agree(compare_result, result)); -// -// // Greater. -// compare_result = compare_text.compare(3, 6, Compare_Text(STR("ABCDEG"))); -// result = text.compare(3, 6, TextT(STR("ABCDEG"))); -// CHECK(compares_agree(compare_result, result)); -// -// // Shorter. -// compare_result = compare_text.compare(3, 6, Compare_Text(STR("ABCDE"))); -// result = text.compare(3, 6, TextT(STR("ABCDE"))); -// CHECK(compares_agree(compare_result, result)); -// -// // Longer. -// compare_result = compare_text.compare(3, 6, Compare_Text(STR("ABCDEFG"))); -// result = text.compare(3, 6, TextT(STR("ABCDEFG"))); -// CHECK(compares_agree(compare_result, result)); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) -// { -// Compare_Text compare_text(STR("xxxABCDEFyyy")); -// -// TextBuffer buffer{0}; -// Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); -// -// int compare_result; -// int result; -// -// // Equal. -// compare_result = compare_text.compare(3, 6, Compare_Text(STR("aaABCDEFbb")), 2, 6); -// result = text.compare(3, 6, TextT(STR("aaABCDEFbb")), 2, 6); -// CHECK(compares_agree(compare_result, result)); -// -// // Less. -// compare_result = compare_text.compare(3, 6, Compare_Text(STR("aaABCDEEbb")), 2, 6); -// result = text.compare(3, 6, TextT(STR("aaABCDEEbb")), 2, 6); -// CHECK(compares_agree(compare_result, result)); -// -// // Greater. -// compare_result = compare_text.compare(3, 6, Compare_Text(STR("aaABCDEGbb")), 2, 6); -// result = text.compare(3, 6, TextT(STR("aaABCDEGbb")), 2, 6); -// CHECK(compares_agree(compare_result, result)); -// -// // Shorter. -// compare_result = compare_text.compare(3, 6, Compare_Text(STR("aaABCDEbb")), 2, 5); -// result = text.compare(3, 6, TextT(STR("aaABCDEbb")), 2, 5); -// CHECK(compares_agree(compare_result, result)); -// -// // Longer. -// compare_result = compare_text.compare(3, 6, Compare_Text(STR("aaABCDEFGbb")), 2, 7); -// result = text.compare(3, 6, TextT(STR("aaABCDEFGbb")), 2, 7); -// CHECK(compares_agree(compare_result, result)); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_compare_c_string) -// { -// Compare_Text compare_text(STR("ABCDEF")); -// -// TextBuffer buffer{0}; -// Text text(STR("ABCDEF"), buffer.data(), buffer.size()); -// -// int compare_result; -// int result; -// -// // Equal. -// compare_result = compare_text.compare(STR("ABCDEF")); -// result = text.compare(STR("ABCDEF")); -// CHECK(compares_agree(compare_result, result)); -// -// // Less. -// compare_result = compare_text.compare(STR("ABCDEE")); -// result = text.compare(STR("ABCDEE")); -// CHECK(compares_agree(compare_result, result)); -// -// // Greater. -// compare_result = compare_text.compare(STR("ABCDEG")); -// result = text.compare(STR("ABCDEG")); -// CHECK(compares_agree(compare_result, result)); -// -// // Shorter. -// compare_result = compare_text.compare(STR("ABCDE")); -// result = text.compare(STR("ABCDE")); -// CHECK(compares_agree(compare_result, result)); -// -// // Longer. -// compare_result = compare_text.compare(STR("ABCDEFG")); -// result = text.compare(STR("ABCDEFG")); -// CHECK(compares_agree(compare_result, result)); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string) -// { -// Compare_Text compare_text(STR("xxxABCDEFyyy")); -// -// TextBuffer buffer{0}; -// Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); -// -// int compare_result; -// int result; -// -// // Equal. -// compare_result = compare_text.compare(3, 6, STR("ABCDEF")); -// result = text.compare(3, 6, STR("ABCDEF")); -// CHECK(compares_agree(compare_result, result)); -// -// // Less. -// compare_result = compare_text.compare(3, 6, STR("ABCDEE")); -// result = text.compare(3, 6, STR("ABCDEE")); -// CHECK(compares_agree(compare_result, result)); -// -// // Greater. -// compare_result = compare_text.compare(3, 6, STR("ABCDEG")); -// result = text.compare(3, 6, STR("ABCDEG")); -// CHECK(compares_agree(compare_result, result)); -// -// // Shorter. -// compare_result = compare_text.compare(3, 6, STR("ABCDE")); -// result = text.compare(3, 6, STR("ABCDE")); -// CHECK(compares_agree(compare_result, result)); -// -// // Longer. -// compare_result = compare_text.compare(3, 6, STR("ABCDEFG")); -// result = text.compare(3, 6, STR("ABCDEFG")); -// CHECK(compares_agree(compare_result, result)); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string_n) -// { -// Compare_Text compare_text(STR("xxxABCDEFyyy")); -// -// TextBuffer buffer{0}; -// Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); -// -// int compare_result; -// int result; -// -// // Equal. -// compare_result = compare_text.compare(3, 6, STR("ABCDEFbb"), 6); -// result = text.compare(3, 6, STR("ABCDEFbb"), 6); -// CHECK(compares_agree(compare_result, result)); -// -// // Less. -// compare_result = compare_text.compare(3, 6, STR("ABCDEEbb"), 6); -// result = text.compare(3, 6, STR("ABCDEEbb"), 6); -// CHECK(compares_agree(compare_result, result)); -// -// // Greater. -// compare_result = compare_text.compare(3, 6, STR("ABCDEGbb"), 6); -// result = text.compare(3, 6, STR("ABCDEGbb"), 6); -// CHECK(compares_agree(compare_result, result)); -// -// // Shorter. -// compare_result = compare_text.compare(3, 6, STR("ABCDEbb"), 5); -// result = text.compare(3, 6, STR("ABCDEbb"), 5); -// CHECK(compares_agree(compare_result, result)); -// -// // Longer. -// compare_result = compare_text.compare(3, 6, STR("ABCDEFGbb"), 7); -// result = text.compare(3, 6, STR("ABCDEFGbb"), 7); -// CHECK(compares_agree(compare_result, result)); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_first_of_string_position) -// { -// Compare_Text compare_text(STR("ABCDEF")); -// -// TextBuffer buffer{0}; -// Text text(STR("ABCDEF"), buffer.data(), buffer.size()); -// -// size_t position1 = compare_text.find_first_of(Compare_Text(STR("ZCXF"))); -// size_t position2 = text.find_first_of(TextT(STR("ZCXF"))); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_of(Compare_Text(STR("WXYZ"))); -// position2 = text.find_first_of(TextT(STR("WXYZ"))); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_of(Compare_Text(STR("ZCXF")), 3); -// position2 = text.find_first_of(TextT(STR("ZCXF")), 3); -// -// CHECK_EQUAL(position1, position2); -// -//#include "etl/private/diagnostic_array_bounds_push.h" -// position1 = compare_text.find_first_of(Compare_Text(STR("ZCXF")), 100); -// position2 = text.find_first_of(TextT(STR("ZCXF")), 100); -// -// CHECK_EQUAL(position1, position2); -//#include "etl/private/diagnostic_pop.h" -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) -// { -// Compare_Text compare_text(STR("ABCDEF")); -// -// TextBuffer buffer{0}; -// Text text(STR("ABCDEF"), buffer.data(), buffer.size()); -// -// size_t position1 = compare_text.find_first_of(STR("ZCXF")); -// size_t position2 = text.find_first_of(STR("ZCXF")); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_of(STR("WXYZ")); -// position2 = text.find_first_of(STR("WXYZ")); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_of(STR("ZCXF"), 3); -// position2 = text.find_first_of(STR("ZCXF"), 3); -// -// CHECK_EQUAL(position1, position2); -// -//#include "etl/private/diagnostic_array_bounds_push.h" -// position1 = compare_text.find_first_of(STR("ZCXF"), 100); -// position2 = text.find_first_of(STR("ZCXF"), 100); -// -// CHECK_EQUAL(position1, position2); -//#include "etl/private/diagnostic_pop.h" -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position_n) -// { -// Compare_Text compare_text(STR("ABCDEF")); -// -// TextBuffer buffer{0}; -// Text text(STR("ABCDEF"), buffer.data(), buffer.size()); -// -// size_t position1 = compare_text.find_first_of(STR("ZCXF"), 0, 4); -// size_t position2 = text.find_first_of(STR("ZCXF"), 0, 4); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_of(STR("WXYZ"), 0, 4); -// position2 = text.find_first_of(STR("WXYZ"), 0, 4); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_of(STR("ZCXF"), 1, 3); -// position2 = text.find_first_of(STR("ZCXF"), 1, 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_of(STR("ZCXF"), 3, 3); -// position2 = text.find_first_of(STR("ZCXF"), 3, 3); -// -// CHECK_EQUAL(position1, position2); -// -//#include "etl/private/diagnostic_array_bounds_push.h" -// position1 = compare_text.find_first_of(STR("ZCXF"), 100); -// position2 = text.find_first_of(STR("ZCXF"), 100); -// -// CHECK_EQUAL(position1, position2); -//#include "etl/private/diagnostic_pop.h" -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_first_of_character_position) -// { -// Compare_Text compare_text(STR("ABCDEF")); -// -// TextBuffer buffer{0}; -// Text text(STR("ABCDEF"), buffer.data(), buffer.size()); -// -// size_t position1 = compare_text.find_first_of(STR('C')); -// size_t position2 = text.find_first_of(STR('C')); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_of(STR('Z')); -// position2 = text.find_first_of(STR('Z')); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_of(STR('F'), 3); -// position2 = text.find_first_of(STR('F'), 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_of(STR('C'), 3); -// position2 = text.find_first_of(STR('C'), 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_of(STR('C'), compare_text.size()); -// position2 = text.find_first_of(STR('C'), text.size()); -// -// CHECK_EQUAL(position1, position2); -// -//#include "etl/private/diagnostic_array_bounds_push.h" -// position1 = compare_text.find_first_of(STR('C'), 100); -// position2 = text.find_first_of(STR('C'), 100); -// -// CHECK_EQUAL(position1, position2); -//#include "etl/private/diagnostic_pop.h" -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_last_of_string_position) -// { -// Compare_Text compare_text(STR("ABCDEFABCDE")); -// -// TextBuffer buffer{0}; -// Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); -// -// size_t position1 = compare_text.find_last_of(Compare_Text(STR("ZCXE"))); -// size_t position2 = text.find_last_of(TextT(STR("ZCXE"))); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_of(Compare_Text(STR("WXYZ")), 3); -// position2 = text.find_last_of(TextT(STR("WXYZ")), 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_of(Compare_Text(STR("ZCXE")), 5); -// position2 = text.find_last_of(TextT(STR("ZCXE")), 5); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_of(Compare_Text(STR("ZCXE")), compare_text.size()); -// position2 = text.find_last_of(TextT(STR("ZCXE")), text.size()); -// -// CHECK_EQUAL(position1, position2); -// -//#include "etl/private/diagnostic_array_bounds_push.h" -// position1 = compare_text.find_last_of(Compare_Text(STR("ZCXE")), 100); -// position2 = text.find_last_of(TextT(STR("ZCXE")), 100); -// -// CHECK_EQUAL(position1, position2); -//#include "etl/private/diagnostic_pop.h" -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) -// { -// Compare_Text compare_text(STR("ABCDEFABCDE")); -// -// TextBuffer buffer{0}; -// Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); -// -// size_t position1 = compare_text.find_last_of(STR("ZCXE")); -// size_t position2 = text.find_last_of(STR("ZCXE")); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_of(STR("WXYZ"), 3); -// position2 = text.find_last_of(STR("WXYZ"), 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_of(STR("ZCXE"), 5); -// position2 = text.find_last_of(STR("ZCXE"), 5); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_of(STR("ZCXE"), 6); -// position2 = text.find_last_of(STR("ZCXE"), 6); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_of(STR("ZCXE"), compare_text.size()); -// position2 = text.find_last_of(STR("ZCXE"), text.size()); -// -// CHECK_EQUAL(position1, position2); -// -//#include "etl/private/diagnostic_array_bounds_push.h" -// position1 = compare_text.find_last_of(STR("ZCXE"), 100); -// position2 = text.find_last_of(STR("ZCXE"), 100); -// -// CHECK_EQUAL(position1, position2); -//#include "etl/private/diagnostic_pop.h" -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position_n) -// { -// Compare_Text compare_text(STR("ABCDEFABCDE")); -// -// TextBuffer buffer{0}; -// Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); -// -// size_t position1 = compare_text.find_last_of(STR("AZCXE"), 0, 4); -// size_t position2 = text.find_last_of(STR("AZCXE"), 0, 4); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_of(STR("WXYZ"), 4, 3); -// position2 = text.find_last_of(STR("WXYZ"), 4, 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_of(STR("ZCXE"), 5, 3); -// position2 = text.find_last_of(STR("ZCXE"), 5, 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_of(STR("ZCXE"), 1, 3); -// position2 = text.find_last_of(STR("ZCXE"), 1, 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_of(STR("ZCXE"), compare_text.size(), 4); -// position2 = text.find_last_of(STR("ZCXE"), text.size(), 4); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_of(STR("ZCXE"), 100, 4); -// position2 = text.find_last_of(STR("ZCXE"), 100, 4); -// -// CHECK_EQUAL(position1, position2); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_last_of_character_position) -// { -// Compare_Text compare_text(STR("ABCDEF")); -// -// TextBuffer buffer{0}; -// Text text(STR("ABCDEF"), buffer.data(), buffer.size()); -// -// size_t position1 = compare_text.find_last_of(STR('C')); -// size_t position2 = text.find_last_of(STR('C')); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_of(STR('Z')); -// position2 = text.find_last_of(STR('Z')); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_of(STR('F'), compare_text.size()); -// position2 = text.find_last_of(STR('F'), text.size()); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_of(STR('C'), 3); -// position2 = text.find_last_of(STR('C'), 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_of(STR('C'), compare_text.size()); -// position2 = text.find_last_of(STR('C'), text.size()); -// -// CHECK_EQUAL(position1, position2); -// -//#include "etl/private/diagnostic_array_bounds_push.h" -// position1 = compare_text.find_last_of(STR('C'), 100); -// position2 = text.find_last_of(STR('C'), 100); -// -// CHECK_EQUAL(position1, position2); -//#include "etl/private/diagnostic_pop.h" -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_first_not_of_string_position) -// { -// Compare_Text compare_text(STR("ABCDEF")); -// -// TextBuffer buffer{0}; -// Text text(STR("ABCDEF"), buffer.data(), buffer.size()); -// -// size_t position1 = compare_text.find_first_not_of(Compare_Text(STR("ZAXB"))); -// size_t position2 = text.find_first_not_of(TextT(STR("ZAXB"))); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_not_of(Compare_Text(STR("ZAXB"))); -// position2 = text.find_first_not_of(TextT(STR("ZAXB"))); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_not_of(Compare_Text(STR("ZAXB")), 3); -// position2 = text.find_first_not_of(TextT(STR("ZAXB")), 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_not_of(Compare_Text(STR("ZAXB")), compare_text.size()); -// position2 = text.find_first_not_of(TextT(STR("ZAXB")), text.size()); -// -// CHECK_EQUAL(position1, position2); -// -//#include "etl/private/diagnostic_array_bounds_push.h" -// position1 = compare_text.find_first_not_of(Compare_Text(STR("ZAXB")), 100); -// position2 = text.find_first_not_of(TextT(STR("ZAXB")), 100); -// -// CHECK_EQUAL(position1, position2); -//#include "etl/private/diagnostic_pop.h" -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) -// { -// Compare_Text compare_text(STR("ABCDEF")); -// -// TextBuffer buffer{0}; -// Text text(STR("ABCDEF"), buffer.data(), buffer.size()); -// -// size_t position1 = compare_text.find_first_not_of(STR("ZAXB")); -// size_t position2 = text.find_first_not_of(STR("ZAXB")); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_not_of(STR("ZAXB")); -// position2 = text.find_first_not_of(STR("ZAXB")); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_not_of(STR("ZAXB"), 3); -// position2 = text.find_first_not_of(STR("ZAXB"), 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_not_of(STR("ZAXB"), compare_text.size()); -// position2 = text.find_first_not_of(STR("ZAXB"), text.size()); -// -// CHECK_EQUAL(position1, position2); -// -//#include "etl/private/diagnostic_array_bounds_push.h" -// position1 = compare_text.find_first_not_of(STR("ZAXB"), 100); -// position2 = text.find_first_not_of(STR("ZAXB"), 100); -// -// CHECK_EQUAL(position1, position2); -//#include "etl/private/diagnostic_pop.h" -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position_n) -// { -// Compare_Text compare_text(STR("ABCDEF")); -// -// TextBuffer buffer{0}; -// Text text(STR("ABCDEF"), buffer.data(), buffer.size()); -// -// size_t position1 = compare_text.find_first_not_of(STR("ZAXB"), 0, 4); -// size_t position2 = text.find_first_not_of(STR("ZAXB"), 0, 4); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_not_of(STR("ZAXB"), 0, 4); -// position2 = text.find_first_not_of(STR("ZAXB"), 0, 4); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_not_of(STR("ZAXB"), 1, 3); -// position2 = text.find_first_not_of(STR("ZAXB"), 1, 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_not_of(STR("ZAXB"), 3, 3); -// position2 = text.find_first_not_of(STR("ZAXB"), 3, 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_not_of(STR("ZAXB"), compare_text.size(), 3); -// position2 = text.find_first_not_of(STR("ZAXB"), text.size(), 3); -// -// CHECK_EQUAL(position1, position2); -// -//#include "etl/private/diagnostic_array_bounds_push.h" -// position1 = compare_text.find_first_not_of(STR("ZAXB"), 100); -// position2 = text.find_first_not_of(STR("ZAXB"), 100); -// -// CHECK_EQUAL(position1, position2); -//#include "etl/private/diagnostic_pop.h" -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_first_not_of_character_position) -// { -// Compare_Text compare_text(STR("ABCDEF")); -// -// TextBuffer buffer{0}; -// Text text(STR("ABCDEF"), buffer.data(), buffer.size()); -// -// size_t position1 = compare_text.find_first_not_of(STR('A')); -// size_t position2 = text.find_first_not_of(STR('A')); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_not_of(STR('B')); -// position2 = text.find_first_not_of(STR('B')); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_not_of(STR('C'), 3); -// position2 = text.find_first_not_of(STR('C'), 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_not_of(STR('D'), 3); -// position2 = text.find_first_not_of(STR('D'), 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_first_not_of(STR('C'), compare_text.size()); -// position2 = text.find_first_not_of(STR('C'), text.size()); -// -// CHECK_EQUAL(position1, position2); -// -//#include "etl/private/diagnostic_array_bounds_push.h" -// position1 = compare_text.find_first_not_of(STR('C'), 100); -// position2 = text.find_first_not_of(STR('C'), 100); -// -// CHECK_EQUAL(position1, position2); -//#include "etl/private/diagnostic_pop.h" -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_last_not_of_string_position) -// { -// Compare_Text compare_text(STR("ABCDEFABCDE")); -// -// TextBuffer buffer{0}; -// Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); -// -// size_t position1 = compare_text.find_last_not_of(Compare_Text(STR("ZEXD"))); -// size_t position2 = text.find_last_not_of(TextT(STR("ZEXD"))); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_not_of(Compare_Text(STR("ZEXD")), 3); -// position2 = text.find_last_not_of(TextT(STR("ZEXD")), 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_not_of(Compare_Text(STR("ZEXD")), 5); -// position2 = text.find_last_not_of(TextT(STR("ZEXD")), 5); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_not_of(Compare_Text(STR("ZEXD")), compare_text.size()); -// position2 = text.find_last_not_of(TextT(STR("ZEXD")), text.size()); -// -// CHECK_EQUAL(position1, position2); -// -//#include "etl/private/diagnostic_array_bounds_push.h" -// position1 = compare_text.find_last_not_of(Compare_Text(STR("ZEXD")), 100); -// position2 = text.find_last_not_of(TextT(STR("ZEXD")), 100); -// -// CHECK_EQUAL(position1, position2); -//#include "etl/private/diagnostic_pop.h" -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) -// { -// Compare_Text compare_text(STR("ABCDEFABCDE")); -// -// TextBuffer buffer{0}; -// Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); -// -// size_t position1 = compare_text.find_last_not_of(STR("ZEXD")); -// size_t position2 = text.find_last_not_of(STR("ZEXD")); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_not_of(STR("ZEXD"), 3); -// position2 = text.find_last_not_of(STR("ZEXD"), 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_not_of(STR("ZEXD"), 5); -// position2 = text.find_last_not_of(STR("ZEXD"), 5); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_not_of(STR("ZEXD"), compare_text.size()); -// position2 = text.find_last_not_of(STR("ZEXD"), text.size()); -// -// CHECK_EQUAL(position1, position2); -// -//#include "etl/private/diagnostic_array_bounds_push.h" -// position1 = compare_text.find_last_not_of(STR("ZEXD"), 100); -// position2 = text.find_last_not_of(STR("ZEXD"), 100); -// -// CHECK_EQUAL(position1, position2); -//#include "etl/private/diagnostic_pop.h" -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position_n) -// { -// Compare_Text compare_text(STR("ABCDEFABCDE")); -// -// TextBuffer buffer{0}; -// Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); -// -// size_t position1 = compare_text.find_last_not_of(STR("ZEXD"), 0, 4); -// size_t position2 = text.find_last_not_of(STR("ZEXD"), 0, 4); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_not_of(STR("ZEXD"), 5, 3); -// position2 = text.find_last_not_of(STR("ZEXD"), 5, 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_not_of(STR("ZEXD"), 1, 3); -// position2 = text.find_last_not_of(STR("ZEXD"), 1, 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_not_of(STR("ZEXD"), compare_text.size(), 4); -// position2 = text.find_last_not_of(STR("ZEXD"), text.size(), 4); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_not_of(STR("ZEXD"), 100, 4); -// position2 = text.find_last_not_of(STR("ZEXD"), 100, 4); -// -// CHECK_EQUAL(position1, position2); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_find_last_not_of_character_position) -// { -// Compare_Text compare_text(STR("ABCDEF")); -// -// TextBuffer buffer{0}; -// Text text(STR("ABCDEF"), buffer.data(), buffer.size()); -// -// size_t position1 = compare_text.find_last_not_of(STR('F')); -// size_t position2 = text.find_last_not_of(STR('F')); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_not_of(STR('Z')); -// position2 = text.find_last_not_of(STR('Z')); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_not_of(STR('A'), compare_text.size()); -// position2 = text.find_last_not_of(STR('A'), text.size()); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_not_of(STR('C'), 3); -// position2 = text.find_last_not_of(STR('C'), 3); -// -// CHECK_EQUAL(position1, position2); -// -// position1 = compare_text.find_last_not_of(STR('C'), compare_text.size()); -// position2 = text.find_last_not_of(STR('C'), text.size()); -// -// CHECK_EQUAL(position1, position2); -// -//#include "etl/private/diagnostic_array_bounds_push.h" -// position1 = compare_text.find_last_not_of(STR('C'), 100); -// position2 = text.find_last_not_of(STR('C'), 100); -// -// CHECK_EQUAL(position1, position2); -//#include "etl/private/diagnostic_pop.h" -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_hash) -// { -// // Test with actual string type. -// TextBuffer buffer{0}; -// Text text(STR("ABCDEFHIJKL"), buffer.data(), buffer.size()); -// size_t hash = etl::hash()(text); -// size_t compare_hash = etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); -// CHECK_EQUAL(compare_hash, hash); -// -// // Test with interface string type. -// IText& itext = text; -// hash = etl::hash()(itext); -// CHECK_EQUAL(compare_hash, hash); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_memcpy_repair) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// -// text.assign(STR("ABCDEF")); -// -// char buffer2[sizeof(Text)]; -// -// // Will not copy the buffer! -// memcpy(&buffer2, (const void*)&text, sizeof(text)); -// -// Text& rtext(*reinterpret_cast(buffer2)); -// rtext.repair(); -// -// CHECK(!rtext.empty()); -// CHECK(!rtext.full()); -// -// bool is_equal = Equal(text, rtext); -// CHECK(is_equal); -// -// text = STR("GHIJKL"); -// is_equal = Equal(text, rtext); -// CHECK(is_equal); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_memcpy_repair_virtual) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// -// text.assign(STR("ABCDEF")); -// -// char buffer2[sizeof(Text)]; -// -// // Will not copy the buffer! -// memcpy(&buffer2, (const void*)&text, sizeof(text)); -// -// IText& itext(*reinterpret_cast(buffer2)); -// itext.repair(); -// -// CHECK(!itext.empty()); -// CHECK(!itext.full()); -// -// bool is_equal = Equal(text, itext); -// CHECK(is_equal); -// -// text = STR("GHIJKL"); -// is_equal = Equal(text, itext); -// CHECK(is_equal); -// } -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_truncate_over_many_operations) -// { -// TextBuffer buffer{0}; -// Text text(short_text.c_str(), buffer.data(), buffer.size()); -// CHECK(!text.is_truncated()); -// -// text.insert(3, initial_text.c_str()); -// CHECK(text.is_truncated()); -// -// while (text.size() != 0) -// { -// text.pop_back(); -// CHECK(text.is_truncated()); -// } -// -// text.clear(); -// CHECK(!text.is_truncated()); -// -// text.assign(longer_text.c_str()); -// CHECK(text.is_truncated()); -// -// text.assign(short_text.c_str()); -// CHECK(!text.is_truncated()); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_add_from_truncated) -// { -// TextBuffer buffer{0}; -// Text text1(short_text.c_str(), buffer.data(), buffer.size()); -// -// TextBufferS buffers{0}; -// Text text2(short_text.c_str(), buffers.data(), buffers.size()); -// -// CHECK(!text1.is_truncated()); -// CHECK(text2.is_truncated()); -// -// // text2 has the truncate flag set. -// text1 += text2; -// -// CHECK(text1.is_truncated()); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_add_to_truncated) -// { -// TextBuffer buffer{0}; -// Text text1(longer_text.c_str(), buffer.data(), buffer.size()); -// -// TextBuffer buffer2{0}; -// Text text2(short_text.c_str(), buffer2.data(), buffer2.size()); -// -// CHECK(text1.is_truncated()); -// CHECK(!text2.is_truncated()); -// -// // Clear text but not the truncate flag. -// text1.erase(text1.begin(), text1.end()); -// -// // text1 still has the truncate flag set. -// text1 += text2; -// -// CHECK(text1.is_truncated()); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_clear_truncated) -// { -// TextBuffer buffer{0}; -// Text text(longer_text.c_str(), buffer.data(), buffer.size()); -// CHECK(text.is_truncated()); -// -// text.clear_truncated(); -// CHECK(!text.is_truncated()); -// } -//#endif -// -//#if ETL_HAS_STRING_CLEAR_AFTER_USE -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_secure_after_destructor) -// { -// char buffer[sizeof(Text)]; -// std::fill_n(buffer, sizeof(Text), 0); -// -// TextBuffer buffer2{0}; -// ::new (buffer) Text(STR("ABCDEF"), buffer2.data(), buffer2.size()); -// -// Text& text = *reinterpret_cast(buffer); -// text.set_secure(); -// -// CHECK(TextT(STR("ABCDEF")) == text); -// -// Text::pointer pb = text.begin(); -// Text::pointer pe = text.end(); -// -// // Destroy the text object. -// text.~Text(); -// -// // Check there no non-zero values in the string. -// CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_secure_after_assign) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// text.set_secure(); -// text.assign(STR("ABCDEF")); -// -// Text::pointer pe = text.end(); -// -// text.assign(STR("ABC")); -// -// CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_secure_after_resize_down) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// text.set_secure(); -// text.assign(STR("ABCDEF")); -// -// Text::pointer pe = text.end(); -// -// text.resize(text.size() - 3U); -// -// CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_secure_after_erase) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// text.set_secure(); -// text.assign(STR("ABCDEF")); -// -// Text::pointer pb = text.begin(); -// Text::pointer pe = text.end(); -// -// text.erase(pb + 2, pb + 5); -// -// // Check there no non-zero values in the remainder of the string. -// CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_secure_after_replace) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// text.set_secure(); -// text.assign(STR("ABCDEF")); -// -// Text::pointer pb = text.begin(); -// Text::pointer pe = text.end(); -// -// text.replace(pb + 1, pb + 4, STR("G")); -// -// // Check there no non-zero values in the remainder of the string. -// CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_secure_after_clear) -// { -// TextBuffer buffer{0}; -// Text text(buffer.data(), buffer.size()); -// text.set_secure(); -// text.assign(STR("ABCDEF")); -// -// Text::pointer pb = text.begin(); -// Text::pointer pe = text.end(); -// -// text.clear(); -// -// // Check there no non-zero values in the remainder of the string. -// CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy) -// { -// TextBuffer buffer1{0}; -// Text text1(STR("Hello World"), buffer1.data(), buffer1.size()); -// text1.set_secure(); -// -// TextBuffer buffer2{0}; -// Text text2(text1, buffer2.data(), buffer2.size()); -// -// TextBuffer buffer3; -// Text text3(buffer3.data(), buffer3.size()); -// text3 = text1; -// -// TextBuffer buffer4; -// Text text4(text1, buffer4.data(), buffer4.size(), 6U, 2U); -// -// CHECK(text2.is_secure()); -// CHECK(text3.is_secure()); -// CHECK(text4.is_secure()); -// } -//#endif -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_initialize_free_space_empty_string) -// { -// TextBuffer buffer1{0}; -// TextBuffer buffer2{0}; -// Text text(buffer1.data(), buffer1.size()); -// Text empty(buffer2.data(), buffer2.size()); -// -// text.initialize_free_space(); -// -// CHECK(text.empty()); -// CHECK(text == empty); -// -// for (size_t i = text.size(); i < text.max_size(); ++i) -// { -// CHECK_EQUAL(0, text[i]); -// } -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_initialize_free_space_part_filled_string) -// { -// TextBuffer buffer1{0}; -// TextBuffer buffer2{0}; -// Text initial(STR("ABC"), buffer1.data(), buffer1.size()); -// Text empty(buffer2.data(), buffer2.size()); -// Text text(initial, buffer2.data(), buffer2.size()); -// -// text.initialize_free_space(); -// -// CHECK(text == initial); -// CHECK(text != empty); -// -// for (size_t i = text.size(); i < text.max_size(); ++i) -// { -// CHECK_EQUAL(0, text[i]); -// } -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_update_after_c_string_max_size) -// { -// TextBuffer buffer1{0}; -// Text text(buffer1.data(), buffer1.size()); -// -// text.initialize_free_space(); -// std::fill(text.data(), text.data() + text.max_size(), STR('A')); -// text.trim_to_terminator(); -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// CHECK_EQUAL(text.max_size(), text.size()); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_update_after_c_string_shorter_size) -// { -// TextBuffer buffer1{0}; -// Text text(buffer1.data(), buffer1.size()); -// -// text.initialize_free_space(); -// std::fill(text.data(), text.data() + text.max_size() - 1, STR('A')); -// text.trim_to_terminator(); -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(!text.is_truncated()); -//#endif -// CHECK_EQUAL(text.max_size() - 1, text.size()); -// } -// -// //************************************************************************* -// TEST_FIXTURE(SetupFixture, test_update_after_c_string_greater_size) -// { -// TextBuffer buffer1{0}; -// Text text(buffer1.data(), buffer1.size()); -// -// text.initialize_free_space(); -// std::fill(text.data(), text.data() + text.max_size() + 1, STR('A')); // Overwrites to terminating null. -// text.trim_to_terminator(); -// -//#if ETL_HAS_STRING_TRUNCATION_CHECKS -// CHECK(text.is_truncated()); -//#endif -// CHECK_EQUAL(text.max_size(), text.size()); -// } }; } diff --git a/test/test_string_u32.cpp b/test/test_string_u32.cpp index 3ebb4bdba..b6f1e915f 100644 --- a/test/test_string_u32.cpp +++ b/test/test_string_u32.cpp @@ -768,6 +768,22 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_fill) + { + Text text(SIZE, STR('A')); + Text expected(SIZE, STR('B')); + + text.fill(STR('B')); + + bool is_equal = Equal(expected, text); + CHECK(is_equal); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty_full) { diff --git a/test/test_string_u32_external_buffer.cpp b/test/test_string_u32_external_buffer.cpp index 931937e16..76b0ac309 100644 --- a/test/test_string_u32_external_buffer.cpp +++ b/test/test_string_u32_external_buffer.cpp @@ -916,6 +916,24 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_fill) + { + TextBuffer buffer1{ 0 }; + TextBuffer buffer2{ 0 }; + Text text(11, STR('A'), buffer1.data(), buffer1.size()); + Text expected(11, STR('B'), buffer2.data(), buffer2.size()); + + text.fill(STR('B')); + + bool is_equal = Equal(expected, text); + CHECK(is_equal); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty_full) { diff --git a/test/test_string_wchar_t.cpp b/test/test_string_wchar_t.cpp index 30820defd..3fad55e93 100644 --- a/test/test_string_wchar_t.cpp +++ b/test/test_string_wchar_t.cpp @@ -768,6 +768,22 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_fill) + { + Text text(SIZE, STR('A')); + Text expected(SIZE, STR('B')); + + text.fill(STR('B')); + + bool is_equal = Equal(expected, text); + CHECK(is_equal); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty_full) { diff --git a/test/test_string_wchar_t_external_buffer.cpp b/test/test_string_wchar_t_external_buffer.cpp index cda41521b..f309cffb7 100644 --- a/test/test_string_wchar_t_external_buffer.cpp +++ b/test/test_string_wchar_t_external_buffer.cpp @@ -918,6 +918,24 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_fill) + { + TextBuffer buffer1{ 0 }; + TextBuffer buffer2{ 0 }; + Text text(11, STR('A'), buffer1.data(), buffer1.size()); + Text expected(11, STR('B'), buffer2.data(), buffer2.size()); + + text.fill(STR('B')); + + bool is_equal = Equal(expected, text); + CHECK(is_equal); + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty_full) { diff --git a/test/test_unordered_map.cpp b/test/test_unordered_map.cpp index 9a5879413..45a283979 100644 --- a/test/test_unordered_map.cpp +++ b/test/test_unordered_map.cpp @@ -462,6 +462,7 @@ namespace data1.insert(DataM::value_type(std::string("3"), etl::move(d3))); data1.insert(DataM::value_type(std::string("4"), ItemM(4))); + data2.insert(DataM::value_type(std::string("5"), ItemM(5))); data2 = std::move(data1); CHECK_EQUAL(1, data2.at("1").value); diff --git a/test/test_unordered_multimap.cpp b/test/test_unordered_multimap.cpp index 99c2bae1f..8bd865238 100644 --- a/test/test_unordered_multimap.cpp +++ b/test/test_unordered_multimap.cpp @@ -414,6 +414,7 @@ namespace data1.insert(DataM::value_type(std::string("4"), ItemM(4))); data2 = std::move(data1); + data2.insert(DataM::value_type(std::string("5"), ItemM(5))); CHECK_EQUAL(1, data2.find("1")->second.value); CHECK_EQUAL(2, data2.find("2")->second.value); diff --git a/test/test_unordered_multiset.cpp b/test/test_unordered_multiset.cpp index 012f5b4fe..c891730a3 100644 --- a/test/test_unordered_multiset.cpp +++ b/test/test_unordered_multiset.cpp @@ -357,6 +357,7 @@ namespace data1.insert(ItemM(4)); DataM data2; + data2.insert(ItemM(5)); data2 = std::move(data1); diff --git a/test/test_unordered_set.cpp b/test/test_unordered_set.cpp index 8ad222060..a5fe32c84 100644 --- a/test/test_unordered_set.cpp +++ b/test/test_unordered_set.cpp @@ -341,6 +341,7 @@ namespace data1.insert(ItemM(4)); DataM data2; + data2.insert(ItemM(5)); data2 = std::move(data1); diff --git a/test/test_vector.cpp b/test/test_vector.cpp index bc5e5cf8c..e8e4f1faa 100644 --- a/test/test_vector.cpp +++ b/test/test_vector.cpp @@ -216,6 +216,7 @@ namespace { Data data(initial_data.begin(), initial_data.end()); Data other_data; + other_data.push_back(1); other_data = std::move(data); @@ -419,6 +420,15 @@ namespace CHECK_EQUAL(data.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_reserve) + { + Data data; + + CHECK_NO_THROW(data.reserve(data.max_size())); + CHECK_THROW(data.reserve(data.max_size() + 1), etl::vector_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty) { @@ -795,6 +805,94 @@ namespace } } + //************************************************************************* + TEST(test_emplace_default) + { + const int Initial = 1; + const int Default = 2; + + struct S + { + S() + : value(Default) + { + } + + S(int v) + : value(v) + { + } + + bool operator ==(const S& rhs) const + { + return value == rhs.value; + } + + int value; + }; + + // First fill with Initial values. + etl::vector data; + data.resize(SIZE, S(Initial)); + data.clear(); + + // Then emplace Default values. + for (size_t i = 0; i < SIZE; ++i) + { + data.emplace(data.end()); + } + + // Compare with an array of default values. + std::array compare_data; + compare_data.fill(S()); + + CHECK_TRUE(std::equal(compare_data.begin(), compare_data.end(), data.begin())); + } + + //************************************************************************* + TEST(test_emplace_back_default) + { + const int Initial = 1; + const int Default = 2; + + struct S + { + S() + : value(Default) + { + } + + S(int v) + : value(v) + { + } + + bool operator ==(const S& rhs) const + { + return value == rhs.value; + } + + int value; + }; + + // First fill with Initial values. + etl::vector data; + data.resize(SIZE, S(Initial)); + data.clear(); + + // Then emplace Default values. + for (size_t i = 0; i < SIZE; ++i) + { + data.emplace_back(); + } + + // Compare with an array of default values. + std::array compare_data; + compare_data.fill(S()); + + CHECK_TRUE(std::equal(compare_data.begin(), compare_data.end(), data.begin())); + } + //************************************************************************* #include "etl/private/diagnostic_array_bounds_push.h" TEST_FIXTURE(SetupFixture, test_insert_position_value_excess) @@ -1338,12 +1436,14 @@ namespace } //************************************************************************* +#include "etl/private/diagnostic_uninitialized_push.h" TEST(test_three_parameter_insert_same_type_not_iterator) { // No compilation error. etl::vector v; v.insert(v.end(), 5, 5); } +#include "etl/private/diagnostic_pop.h" //************************************************************************* TEST(remove) diff --git a/test/test_vector_non_trivial.cpp b/test/test_vector_non_trivial.cpp index 9a76b87a7..459715bb2 100644 --- a/test/test_vector_non_trivial.cpp +++ b/test/test_vector_non_trivial.cpp @@ -771,7 +771,6 @@ namespace #endif //************************************************************************* - // To test the CPP03 versions then ETL_TEST_VECTOR_CPP11 must be set to 0 in vector.h TEST_FIXTURE(SetupFixture, test_emplace_back_multiple) { class Data diff --git a/test/test_vector_pointer.cpp b/test/test_vector_pointer.cpp index d07f53fb5..bba84c1de 100644 --- a/test/test_vector_pointer.cpp +++ b/test/test_vector_pointer.cpp @@ -360,6 +360,7 @@ namespace { Data data(initial_data.begin(), initial_data.end()); Data other_data; + other_data.push_back(nullptr); other_data = std::move(data); @@ -1068,6 +1069,52 @@ namespace CHECK_EQUAL(&d2, data.emplace_back(&d2)); } + //************************************************************************* + TEST(test_emplace_default) + { + static int initial = 0; + + // First fill with Initial values. + etl::vector data; + data.resize(SIZE, &initial); + data.clear(); + + // Then emplace Default values. + for (size_t i = 0; i < SIZE; ++i) + { + data.emplace(data.begin()); + } + + // Compare with an array of default values. + std::array compare_data; + compare_data.fill(nullptr); + + CHECK_TRUE(std::equal(compare_data.begin(), compare_data.end(), data.begin())); + } + + //************************************************************************* + TEST(test_emplace_back_default) + { + static int initial = 0; + + // First fill with initial values. + etl::vector data; + data.resize(SIZE, &initial); + data.clear(); + + // Then emplace default values. + for (size_t i = 0; i < SIZE; ++i) + { + data.emplace_back(); + } + + // Compare with an array of default values. + std::array compare_data; + compare_data.fill(nullptr); + + CHECK_TRUE(std::equal(compare_data.begin(), compare_data.end(), data.begin())); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_pop_back) { diff --git a/test/test_vector_pointer_external_buffer.cpp b/test/test_vector_pointer_external_buffer.cpp index cfec18772..2b6457427 100644 --- a/test/test_vector_pointer_external_buffer.cpp +++ b/test/test_vector_pointer_external_buffer.cpp @@ -47,7 +47,7 @@ namespace int* buffer4[SIZE]; int* buffer5[SIZE]; - SUITE(test_vector_pointer) + SUITE(test_vector_pointer_external_buffer) { typedef etl::vector_ext Data; typedef etl::vector_ext CData; diff --git a/test/vs2022/etl.sln b/test/vs2022/etl.sln index cc4ecaab1..48c644d9e 100644 --- a/test/vs2022/etl.sln +++ b/test/vs2022/etl.sln @@ -17,8 +17,12 @@ Global Debug MSVC C++17 - No STL|x64 = Debug MSVC C++17 - No STL|x64 Debug MSVC C++17|Win32 = Debug MSVC C++17|Win32 Debug MSVC C++17|x64 = Debug MSVC C++17|x64 + Debug MSVC C++20 - Force C++03|Win32 = Debug MSVC C++20 - Force C++03|Win32 + Debug MSVC C++20 - Force C++03|x64 = Debug MSVC C++20 - Force C++03|x64 Debug MSVC C++20 - No STL|Win32 = Debug MSVC C++20 - No STL|Win32 Debug MSVC C++20 - No STL|x64 = Debug MSVC C++20 - No STL|x64 + Debug MSVC C++20 - No virtual messages|Win32 = Debug MSVC C++20 - No virtual messages|Win32 + Debug MSVC C++20 - No virtual messages|x64 = Debug MSVC C++20 - No virtual messages|x64 Debug MSVC C++20|Win32 = Debug MSVC C++20|Win32 Debug MSVC C++20|x64 = Debug MSVC C++20|x64 Release MSVC C++20 - No STL - Optimised -O2|Win32 = Release MSVC C++20 - No STL - Optimised -O2|Win32 @@ -47,10 +51,18 @@ Global {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC C++17|Win32.Build.0 = Debug MSVC C++17|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC C++17|x64.ActiveCfg = Debug MSVC C++17|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC C++17|x64.Build.0 = Debug MSVC C++17|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC C++20 - Force C++03|Win32.ActiveCfg = Debug MSVC C++20 - Force C++03|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC C++20 - Force C++03|Win32.Build.0 = Debug MSVC C++20 - Force C++03|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC C++20 - Force C++03|x64.ActiveCfg = Debug MSVC C++20 - Force C++03|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC C++20 - Force C++03|x64.Build.0 = Debug MSVC C++20 - Force C++03|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC C++20 - No STL|Win32.ActiveCfg = Debug MSVC C++20 - No STL|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC C++20 - No STL|Win32.Build.0 = Debug MSVC C++20 - No STL|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC C++20 - No STL|x64.ActiveCfg = Debug MSVC C++20 - No STL|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC C++20 - No STL|x64.Build.0 = Debug MSVC C++20 - No STL|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC C++20 - No virtual messages|Win32.ActiveCfg = Debug MSVC C++20 - No virtual messages|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC C++20 - No virtual messages|Win32.Build.0 = Debug MSVC C++20 - No virtual messages|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC C++20 - No virtual messages|x64.ActiveCfg = Debug MSVC C++20 - No virtual messages|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC C++20 - No virtual messages|x64.Build.0 = Debug MSVC C++20 - No virtual messages|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC C++20|Win32.ActiveCfg = Debug MSVC C++20|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC C++20|Win32.Build.0 = Debug MSVC C++20|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC C++20|x64.ActiveCfg = Debug MSVC C++20|x64 diff --git a/test/vs2022/etl.vcxproj b/test/vs2022/etl.vcxproj index ff3870598..6d02d9024 100644 --- a/test/vs2022/etl.vcxproj +++ b/test/vs2022/etl.vcxproj @@ -41,6 +41,14 @@ Debug MSVC C++17 x64 + + Debug MSVC C++20 - Force C++03 + Win32 + + + Debug MSVC C++20 - Force C++03 + x64 + Debug MSVC C++20 - No STL Win32 @@ -49,6 +57,22 @@ Debug MSVC C++20 - No STL x64 + + Debug MSVC C++20 - No virtual imessage + Win32 + + + Debug MSVC C++20 - No virtual imessage + x64 + + + Debug MSVC C++20 - No virtual messages + Win32 + + + Debug MSVC C++20 - No virtual messages + x64 + Debug MSVC C++20 Win32 @@ -103,6 +127,27 @@ Unicode false + + Application + true + v143 + Unicode + false + + + Application + true + v143 + Unicode + false + + + Application + true + v143 + Unicode + false + Application true @@ -315,6 +360,24 @@ v143 Unicode + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + Application true @@ -545,6 +608,15 @@ + + + + + + + + + @@ -641,6 +713,15 @@ + + + + + + + + + @@ -762,6 +843,21 @@ true $(Configuration)\ + + false + true + $(Configuration)\ + + + false + true + $(Configuration)\ + + + true + true + $(Configuration)\ + false true @@ -925,6 +1021,18 @@ true true + + true + true + + + true + true + + + true + true + true true @@ -1131,7 +1239,59 @@ true stdcpp20 - ProgramDatabase + EditAndContinue + /Zc:__cplusplus %(AdditionalOptions) + true + EnableFastChecks + false + + + Console + true + + + "$(OutDir)\etl.exe" + + + + + + + Level2 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_FORCE_TEST_CPP03_IMPLEMENTATION;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../test + + + true + stdcpp20 + EditAndContinue + /Zc:__cplusplus %(AdditionalOptions) + true + EnableFastChecks + false + + + Console + true + + + "$(OutDir)\etl.exe" + + + + + + + Level2 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_MESSAGES_ARE_NOT_VIRTUAL;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../test + + + true + stdcpp20 + EditAndContinue /Zc:__cplusplus %(AdditionalOptions) true EnableFastChecks @@ -1145,6 +1305,32 @@ "$(OutDir)\etl.exe" + + + + + Level2 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_IMESSAGE_IS_NON_VIRTUAL;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../test + + + true + stdcpp20 + EditAndContinue + /Zc:__cplusplus %(AdditionalOptions) + true + EnableFastChecks + true + + + Console + true + + + "$(OutDir)\etl.exe" + + @@ -1928,6 +2114,69 @@ $(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 + 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 + 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 + stdcpp14 + + + Console + true + + + $(OutDir)\etl.exe + + @@ -2679,6 +2928,7 @@ + @@ -2892,6 +3142,7 @@ + @@ -3006,6 +3257,9 @@ true true true + true + true + true true true true @@ -3040,6 +3294,9 @@ true true true + true + true + true true true true @@ -3074,6 +3331,9 @@ true true true + true + true + true true true true @@ -3108,6 +3368,9 @@ true true true + true + true + true true true true @@ -3186,6 +3449,9 @@ true true true + true + true + true true true true @@ -3220,6 +3486,9 @@ true true true + true + true + true true true true @@ -3254,6 +3523,9 @@ true true true + true + true + true true true true @@ -3288,6 +3560,9 @@ true true true + true + true + true true true true @@ -3320,9957 +3595,3622 @@ - - true - true - true + true + true true + true + true + true + true + true true + true + true + true + + + true + true + true + true true + true true true - true - true + true + true true - true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true + true + true - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true + true + true + true + true + true true + true + true + true + + + true + true + true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true + true + true - - true - true + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true - true - true - true - true - true + true - - true - true - true + true + true true - true + true true + true true true - true + true + true true - true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true + true + true + true + true true - true - true - true + true + + true + true true + true + true + true + true + true true + true + true + true + + + true + true + true + true true + true true true - true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true + true + true - - true - true + true + true true - true + true true + true true true - true - true + true + true true - true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true + true + true - - true - true + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true + true + true + true + true true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true + true - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true + true + true - - true - true + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true + true + true + true + true true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true + true - - true - true + true + true true - true + true true + true true true - true - true + true + true true - true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true + true + true - - true - true + true + true true - true + true true + true true true - true - true + true + true true - true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true + true + true - - true - true + true + true true - true + true true + true true true - true - true + true + true true - true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true + true + true - - true - true + true + true true - true + true true + true true true - true - true + true + true true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true + true + true - - true - true + true + true true - true + true true + true true true - true - true + true + true true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true + true + true - - true - true + true + true true - true + true true + true true true - true - true + true + true true - true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true + true + true - - true - true + true + true true - true + true true + true true true - true - true + true + true true - true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true - true - true - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true - - true - true + true + true true - true + true true + true true true - true - true + true + true true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true + true - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true + true + true true - true + true true + true true true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true + + true + true true - true + true true + true true true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true + true + true - - true - true + true + true true - true + true true + true true true - true - true + true + true true - true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true + true + true - - true - true - true + true + true true - true + true true + true true true - true + true + true true - true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true + true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true true - true - true - true - true - true - true + true + + true + true true - true + true true + true true true + true + true + true + true + + + true + true + true true + true true - true - true - true - true - true - true - true - true - true - true - true + true + true + true + true + true + true + @@ -13343,6 +7283,7 @@ + @@ -13406,6 +7347,9 @@ false false false + false + false + false false false false @@ -13442,6 +7386,9 @@ false false false + false + false + false false false false @@ -13497,6 +7444,9 @@ false false false + false + false + false false false false @@ -13533,6 +7483,9 @@ false false false + false + false + false false false false @@ -13583,6 +7536,9 @@ false false false + false + false + false false false false @@ -13619,6 +7575,9 @@ false false false + false + false + false false false false @@ -13659,6 +7618,9 @@ false false false + false + false + false false false false @@ -13695,6 +7657,9 @@ false false false + false + false + false false false false @@ -13735,6 +7700,9 @@ false false false + false + false + false false false false @@ -13771,6 +7739,9 @@ false false false + false + false + false false false false @@ -13811,6 +7782,9 @@ false false false + false + false + false false false false @@ -13847,6 +7821,9 @@ false false false + false + false + false false false false @@ -13892,6 +7869,9 @@ false false false + false + false + false false false false @@ -13928,6 +7908,9 @@ false false false + false + false + false false false false @@ -13972,6 +7955,9 @@ false false false + false + false + false false false false @@ -14008,6 +7994,9 @@ false false false + false + false + false false false false @@ -14061,6 +8050,9 @@ false false false + false + false + false false false false @@ -14097,6 +8089,9 @@ false false false + false + false + false false false false @@ -14298,8 +8293,12 @@ + + + + @@ -14315,6 +8314,9 @@ true true true + true + true + true true true true @@ -14349,6 +8351,9 @@ true true true + true + true + true true true true @@ -14383,6 +8388,9 @@ true true true + true + true + true true true true @@ -14417,6 +8425,9 @@ true true true + true + true + true true true true @@ -14452,6 +8463,20 @@ + + true + true + true + true + true + true + true + true + true + true + true + true + diff --git a/test/vs2022/etl.vcxproj.filters b/test/vs2022/etl.vcxproj.filters index a1bf8a0d1..04a0462b9 100644 --- a/test/vs2022/etl.vcxproj.filters +++ b/test/vs2022/etl.vcxproj.filters @@ -220,6 +220,12 @@ {c75cedd3-8b6c-4662-b965-aecbe7fd5d1c} + + {6bbca8f0-f707-45ee-9dad-6d41d401bbaf} + + + {9713a35d-8f0e-4722-9b15-a5c477c9ecdb} + @@ -1359,6 +1365,12 @@ ETL\Private + + ETL\Utilities + + + ETL\Codecs + @@ -2270,1154 +2282,1022 @@ Tests\Messaging - + + Tests\Types + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files + + + UnitTest++\Source Files\Win32 + + + Tests\Types + + + Tests\Patterns + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Sanity Checks\Source + + + Tests\Binary + + + Tests\Containers + + + Tests\Atomic + + + Tests\Binary + + + Tests\Binary + + + Tests\Binary + + + Tests\Containers + + + Tests\Containers + + + Tests\Containers + + + Tests\Initializer List + + + Tests\Error Handler\Log Errors + + + Tests\Error Handler\Exceptions + + + Tests\Messaging + + + Tests\Misc + + + Tests\Binary + + + Tests\Binary + + + Tests\Memory & Iterators + + + Tests\Binary + + + Tests\Binary + + + Tests\Strings + + + Tests\Strings + + + Tests\Strings + + + Tests\Strings + + + Tests\CRC + + + Tests\Misc + + + Tests\Containers + + + Tests\Error Handler\Exceptions_And_Log_Errors + + + Tests\State Machines + + + Tests\Containers + + + Tests\Misc + + + Tests\Misc + + + Tests\Codecs + + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Types - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files - - - UnitTest++\Source Files\Win32 - - - Tests\Types - - - Tests\Patterns - - + Tests\Syntax Checks\Source - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - - Tests\Sanity Checks\Source - - + Tests\Syntax Checks\Source - - Tests\Binary - - - Tests\Containers - - - Tests\Atomic - - - Tests\Binary - - - Tests\Binary - - - Tests\Binary - - + Tests\Syntax Checks\Source - - Tests\Containers - - - Tests\Containers - - - Tests\Containers - - - Tests\Initializer List - - - Tests\Error Handler\Log Errors - - - Tests\Error Handler\Exceptions - - - Tests\Messaging - - + Tests\Syntax Checks\Source - - Tests\Misc - - - Tests\Binary - - + Tests\Syntax Checks\Source - - Tests\Binary - - - Tests\Memory & Iterators - - + Tests\Syntax Checks\Source - - Tests\Binary - - - Tests\Binary - - - Tests\Strings - - - Tests\Strings - - - Tests\Strings - - - Tests\Strings - - + Tests\Syntax Checks\Source - - Tests\CRC - - - Tests\Misc - - - Tests\Containers - - + Tests\Syntax Checks\Source - + Tests\Syntax Checks\Source - - Tests\Error Handler\Exceptions_And_Log_Errors - - - Tests\State Machines - - - Tests\Containers - - - Tests\Misc + + Tests\Syntax Checks\Source @@ -3535,6 +3415,18 @@ Tests\Scripts + + Tests\Scripts + + + Tests\Scripts + + + Tests\Scripts + + + Tests\Scripts + @@ -3579,6 +3471,9 @@ Tests\Syntax Checks\C++20 + + Tests\Syntax Checks\Source + diff --git a/version.txt b/version.txt index b6eade30a..857dc9a4c 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -20.37.3 +20.38.6