From 8e372fcedc12d87f5cdbe419a67748e3777fc7dd Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 2 Mar 2021 11:03:26 +0000 Subject: [PATCH 1/7] Initial code --- include/etl/message_router_registry.h | 160 ++++++++++++++++++++++++++ test/vs2019/etl.vcxproj | 1 + test/vs2019/etl.vcxproj.filters | 3 + 3 files changed, 164 insertions(+) create mode 100644 include/etl/message_router_registry.h diff --git a/include/etl/message_router_registry.h b/include/etl/message_router_registry.h new file mode 100644 index 00000000..88480a47 --- /dev/null +++ b/include/etl/message_router_registry.h @@ -0,0 +1,160 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 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. +******************************************************************************/ + +#ifndef ETL_MESSAGE_ROUTER_REGISTRY_INCLUDED +#define ETL_MESSAGE_ROUTER_REGISTRY_INCLUDED + +#include + +#include "platform.h" +#include "file_error_numbers.h" +#include "message_router.h" +#include "flat_map.h" +#include "exception.h" +#include "error_handler.h" + +#undef ETL_FILE +#define ETL_FILE ETL_MESSAGE_ROUTER_REGISTRY + +namespace etl +{ + ////*************************************************************************** + ///// Base exception class for message router + ////*************************************************************************** + //class message_router_registry_exception : public etl::exception + //{ + //public: + + // message_router_exception(string_type reason_, string_type file_name_, numeric_type line_number_) + // : etl::exception(reason_, file_name_, line_number_) + // { + // } + //}; + + ////*************************************************************************** + ///// Router id is out of the legal range. + ////*************************************************************************** + //class message_router_illegal_id : public etl::message_router_registry_exception + //{ + //public: + + // message_router_illegal_id(string_type file_name_, numeric_type line_number_) + // : message_router_exception(ETL_ERROR_TEXT("message router:illegal id", ETL_FILE"A"), file_name_, line_number_) + // { + // } + //}; + + //*************************************************************************** + /// This is the base of all message router registries. + //*************************************************************************** + class imessage_router_registry + { + public: + + //******************************************** + etl::imessage_router* get_message_router(etl::message_router_id_t id) const + { + IRegistry::const_iterator itr = registry.find(id); + + if (itr != registry.end()) + { + return itr->second; + } + else + { + return ETL_NULLPTR; + } + } + + //******************************************** + bool contains(etl::message_router_id_t id) const + { + return registry.find(id) != registry.end(); + } + + //******************************************** + bool register_message_router(etl::imessage_router& router) + { + if (!registry.full()) + { + typename IRegistry::value_type element(router.get_message_router_id(), &router); + + registry.insert(element); + return true; + } + else + { + return false; + } + } + + //******************************************** + void unregister_message_router(etl::message_router_id_t id) + { + registry.erase(id); + } + + protected: + + typedef etl::iflat_map IRegistry; + + //******************************************** + imessage_router_registry(IRegistry& registry_) + : registry(registry_) + { + } + + private: + + IRegistry& registry; + }; + + //*************************************************************************** + /// Message router registry. + //*************************************************************************** + template + class message_router_registry : public etl::imessage_router_registry + { + public: + + //******************************************** + message_router_registry() + : message_router_registry(registry) + { + } + + private: + + typedef etl::flat_map Registry; + Registry registry; + }; +} + +#undef ETL_FILE + +#endif diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 6d052fde..12d35c56 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -1334,6 +1334,7 @@ + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 55773fa8..084ce1d2 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -948,6 +948,9 @@ ETL\Containers + + ETL\Frameworks + From 95e015d141672307c9e430afec166ce1fe873e1b Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 5 Mar 2021 12:01:19 +0000 Subject: [PATCH 2/7] Fix C++14 only type aliases for STL --- .../etl/generators/type_traits_generator.h | 34 +++++++++---------- include/etl/type_traits.h | 34 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/include/etl/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index 1babf113..776d991b 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -832,7 +832,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using remove_reference_t = std::remove_reference_t; + using remove_reference_t = typename std::remove_reference::type; #endif //*************************************************************************** @@ -842,7 +842,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using remove_pointer_t = std::remove_pointer_t; + using remove_pointer_t = typename std::remove_pointer::type; #endif //*************************************************************************** @@ -852,7 +852,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using add_pointer_t = std::add_pointer_t; + using add_pointer_t = typename std::add_pointer::type; #endif //*************************************************************************** @@ -872,7 +872,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using remove_const_t = std::remove_const_t; + using remove_const_t = typename std::remove_const::type; #endif //*************************************************************************** @@ -882,7 +882,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using add_const_t = std::add_const_t; + using add_const_t = typename std::add_const::type; #endif //*************************************************************************** @@ -902,7 +902,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using remove_volatile_t = std::remove_volatile_t; + using remove_volatile_t = typename std::remove_volatile::type; #endif //*************************************************************************** @@ -912,7 +912,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using add_volatile_t = std::add_volatile_t; + using add_volatile_t = typename std::add_volatile::type; #endif //*************************************************************************** @@ -922,7 +922,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using remove_cv_t = std::remove_cv_t; + using remove_cv_t = typename std::remove_cv::type; #endif //*************************************************************************** @@ -932,7 +932,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using add_cv_t = std::add_cv_t; + using add_cv_t = typename std::add_cv::type; #endif //*************************************************************************** @@ -1209,7 +1209,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using make_signed_t = std::make_signed_t; + using make_signed_t = typename std::make_signed::type; #endif //*************************************************************************** @@ -1219,7 +1219,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using make_unsigned_t = std::make_unsigned_t; + using make_unsigned_t = typename std::make_unsigned::type; #endif //*************************************************************************** @@ -1229,7 +1229,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using enable_if_t = std::enable_if_t; + using enable_if_t = typename std::enable_if::type; #endif //*************************************************************************** @@ -1250,7 +1250,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using remove_extent_t = std::remove_extent_t; + using remove_extent_t = typename std::remove_extent::type; #endif //*************************************************************************** @@ -1260,7 +1260,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using remove_all_extents_t = std::remove_all_extents_t; + using remove_all_extents_t = typename std::remove_all_extents::type; #endif //*************************************************************************** @@ -1280,7 +1280,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using decay_t = std::decay_t; + using decay_t = typename std::decay::type; #endif //*************************************************************************** @@ -1308,7 +1308,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using add_lvalue_reference_t = std::add_lvalue_reference_t; + using add_lvalue_reference_t = typename std::add_lvalue_reference::type; #endif //*************************************************************************** @@ -1319,7 +1319,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using add_rvalue_reference_t = std::add_rvalue_reference_t; + using add_rvalue_reference_t = typename std::add_rvalue_reference::type; #endif //*************************************************************************** diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index c667e9b7..e51a839e 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -820,7 +820,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using remove_reference_t = std::remove_reference_t; + using remove_reference_t = typename std::remove_reference::type; #endif //*************************************************************************** @@ -830,7 +830,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using remove_pointer_t = std::remove_pointer_t; + using remove_pointer_t = typename std::remove_pointer::type; #endif //*************************************************************************** @@ -840,7 +840,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using add_pointer_t = std::add_pointer_t; + using add_pointer_t = typename std::add_pointer::type; #endif //*************************************************************************** @@ -860,7 +860,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using remove_const_t = std::remove_const_t; + using remove_const_t = typename std::remove_const::type; #endif //*************************************************************************** @@ -870,7 +870,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using add_const_t = std::add_const_t; + using add_const_t = typename std::add_const::type; #endif //*************************************************************************** @@ -890,7 +890,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using remove_volatile_t = std::remove_volatile_t; + using remove_volatile_t = typename std::remove_volatile::type; #endif //*************************************************************************** @@ -900,7 +900,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using add_volatile_t = std::add_volatile_t; + using add_volatile_t = typename std::add_volatile::type; #endif //*************************************************************************** @@ -910,7 +910,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using remove_cv_t = std::remove_cv_t; + using remove_cv_t = typename std::remove_cv::type; #endif //*************************************************************************** @@ -920,7 +920,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using add_cv_t = std::add_cv_t; + using add_cv_t = typename std::add_cv::type; #endif //*************************************************************************** @@ -1197,7 +1197,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using make_signed_t = std::make_signed_t; + using make_signed_t = typename std::make_signed::type; #endif //*************************************************************************** @@ -1207,7 +1207,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using make_unsigned_t = std::make_unsigned_t; + using make_unsigned_t = typename std::make_unsigned::type; #endif //*************************************************************************** @@ -1217,7 +1217,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using enable_if_t = std::enable_if_t; + using enable_if_t = typename std::enable_if::type; #endif //*************************************************************************** @@ -1238,7 +1238,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using remove_extent_t = std::remove_extent_t; + using remove_extent_t = typename std::remove_extent::type; #endif //*************************************************************************** @@ -1248,7 +1248,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using remove_all_extents_t = std::remove_all_extents_t; + using remove_all_extents_t = typename std::remove_all_extents::type; #endif //*************************************************************************** @@ -1268,7 +1268,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using decay_t = std::decay_t; + using decay_t = typename std::decay::type; #endif //*************************************************************************** @@ -1296,7 +1296,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using add_lvalue_reference_t = std::add_lvalue_reference_t; + using add_lvalue_reference_t = typename std::add_lvalue_reference::type; #endif //*************************************************************************** @@ -1307,7 +1307,7 @@ namespace etl #if ETL_CPP11_SUPPORTED template - using add_rvalue_reference_t = std::add_rvalue_reference_t; + using add_rvalue_reference_t = typename std::add_rvalue_reference::type; #endif //*************************************************************************** From 0070fc1aad4b9fa2b87f4383afe1bd9250d60440 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 5 Mar 2021 13:12:49 +0000 Subject: [PATCH 3/7] Fix C++14 only type aliases for STL --- include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- support/Release notes.txt | 4 ++++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/etl/version.h b/include/etl/version.h index 2370e15e..a7a55ed4 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -39,7 +39,7 @@ SOFTWARE. #define ETL_VERSION_MAJOR 20 #define ETL_VERSION_MINOR 5 -#define ETL_VERSION_PATCH 1 +#define ETL_VERSION_PATCH 2 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_U16 ETL_STRINGIFY(ETL_VERSION_MAJOR) u"." ETL_STRINGIFY(ETL_VERSION_MINOR) u"." ETL_STRINGIFY(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index 15538db4..36437966 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ETL Embedded Template Library", - "version": "20.5.1", + "version": "20.5.2", "author s": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 8d8e019d..182ede8c 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library ETL -version=20.5.1 +version=20.5.2 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index eca8bead..cf63ae22 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +20.5.2 +Fixed template aliases when using STL and below C++14 + =============================================================================== 20.5.1 Fixed ambiguous template error for etl::extent. From dbfa71944f33c44b3e410f74aa5b3bce482ed9bb Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 4 Mar 2021 18:59:40 +0000 Subject: [PATCH 4/7] Abstracted unit test framework header --- test/main.cpp | 2 +- test/test_algorithm.cpp | 2 +- test/test_alignment.cpp | 2 +- test/test_array.cpp | 2 +- test/test_array_view.cpp | 2 +- test/test_array_wrapper.cpp | 2 +- test/test_atomic_clang_sync.cpp | 2 +- test/test_atomic_std.cpp | 2 +- test/test_binary.cpp | 2 +- test/test_bit_stream.cpp | 2 +- test/test_bitset.cpp | 2 +- test/test_bloom_filter.cpp | 2 +- test/test_bresenham_line.cpp | 2 +- test/test_bsd_checksum.cpp | 2 +- test/test_buffer_descriptors.cpp | 2 +- test/test_callback_service.cpp | 2 +- test/test_callback_timer.cpp | 3 +- test/test_checksum.cpp | 2 +- test/test_circular_buffer.cpp | 2 +- test/test_circular_buffer_external_buffer.cpp | 2 +- test/test_compare.cpp | 2 +- test/test_compiler_settings.cpp | 2 +- test/test_constant.cpp | 2 +- test/test_container.cpp | 2 +- test/test_crc.cpp | 2 +- test/test_cumulative_moving_average.cpp | 2 +- test/test_cyclic_value.cpp | 2 +- test/test_debounce.cpp | 2 +- test/test_delegate.cpp | 3 +- test/test_delegate_service.cpp | 2 +- test/test_deque.cpp | 3 +- test/test_endian.cpp | 2 +- test/test_enum_type.cpp | 2 +- test/test_error_handler.cpp | 2 +- test/test_exception.cpp | 2 +- test/test_fixed_iterator.cpp | 2 +- ...est_fixed_sized_memory_block_allocator.cpp | 2 +- test/test_flags.cpp | 2 +- test/test_flat_map.cpp | 2 +- test/test_flat_multimap.cpp | 2 +- test/test_flat_multiset.cpp | 2 +- test/test_flat_set.cpp | 2 +- test/test_fnv_1.cpp | 2 +- test/test_format_spec.cpp | 2 +- test/test_forward_list.cpp | 3 +- test/test_forward_list_shared_pool.cpp | 3 +- test/test_fsm.cpp | 2 +- test/test_function.cpp | 2 +- test/test_functional.cpp | 2 +- test/test_hash.cpp | 2 +- test/test_indirect_vector.cpp | 2 +- test/test_indirect_vector_external_buffer.cpp | 2 +- test/test_instance_count.cpp | 2 +- test/test_integral_limits.cpp | 2 +- test/test_intrusive_forward_list.cpp | 3 +- test/test_intrusive_links.cpp | 3 +- test/test_intrusive_list.cpp | 3 +- test/test_intrusive_queue.cpp | 2 +- test/test_intrusive_stack.cpp | 2 +- test/test_io_port.cpp | 2 +- test/test_iterator.cpp | 2 +- test/test_jenkins.cpp | 2 +- test/test_largest.cpp | 2 +- test/test_limits.cpp | 2 +- test/test_list.cpp | 3 +- test/test_list_shared_pool.cpp | 3 +- test/test_make_string.cpp | 2 +- test/test_map.cpp | 2 +- test/test_maths.cpp | 2 +- test/test_memory.cpp | 2 +- test/test_message_bus.cpp | 3 +- test/test_message_packet.cpp | 3 +- test/test_message_router.cpp | 3 +- test/test_message_router_registry.cpp | 767 ++++++++++++++++++ test/test_message_timer.cpp | 3 +- test/test_multi_array.cpp | 2 +- test/test_multi_range.cpp | 2 +- test/test_multimap.cpp | 2 +- test/test_multiset.cpp | 2 +- test/test_murmur3.cpp | 2 +- test/test_numeric.cpp | 2 +- test/test_observer.cpp | 2 +- test/test_optional.cpp | 2 +- test/test_packet.cpp | 3 +- test/test_parameter_pack.cpp | 3 +- test/test_parameter_type.cpp | 2 +- test/test_parity_checksum.cpp | 2 +- test/test_pearson.cpp | 2 +- test/test_pool.cpp | 3 +- test/test_priority_queue.cpp | 2 +- test/test_queue.cpp | 2 +- test/test_queue_lockable.cpp | 2 +- test/test_queue_lockable_small.cpp | 2 +- test/test_queue_memory_model_small.cpp | 2 +- test/test_queue_mpmc_mutex.cpp | 2 +- test/test_queue_mpmc_mutex_small.cpp | 2 +- test/test_queue_spsc_atomic.cpp | 2 +- test/test_queue_spsc_atomic_small.cpp | 2 +- test/test_queue_spsc_isr.cpp | 2 +- test/test_queue_spsc_isr_small.cpp | 2 +- test/test_queue_spsc_locked.cpp | 2 +- test/test_queue_spsc_locked_small.cpp | 2 +- test/test_random.cpp | 2 +- test/test_reference_flat_map.cpp | 2 +- test/test_reference_flat_multimap.cpp | 2 +- test/test_reference_flat_multiset.cpp | 2 +- test/test_reference_flat_set.cpp | 2 +- test/test_scaled_rounding.cpp | 2 +- test/test_set.cpp | 2 +- test/test_shared_message.cpp | 2 +- test/test_smallest.cpp | 2 +- test/test_span.cpp | 2 +- test/test_stack.cpp | 2 +- test/test_state_chart.cpp | 2 +- test/test_state_chart_with_data_parameter.cpp | 2 +- ...state_chart_with_rvalue_data_parameter.cpp | 2 +- test/test_string_char.cpp | 2 +- test/test_string_char_external_buffer.cpp | 2 +- test/test_string_stream.cpp | 2 +- test/test_string_stream_u16.cpp | 2 +- test/test_string_stream_u32.cpp | 2 +- test/test_string_stream_wchar_t.cpp | 2 +- test/test_string_u16.cpp | 2 +- test/test_string_u16_external_buffer.cpp | 2 +- test/test_string_u32.cpp | 2 +- test/test_string_u32_external_buffer.cpp | 2 +- test/test_string_utilities.cpp | 2 +- test/test_string_utilities_std.cpp | 2 +- test/test_string_utilities_std_u16.cpp | 2 +- test/test_string_utilities_std_u32.cpp | 2 +- test/test_string_utilities_std_wchar_t.cpp | 2 +- test/test_string_utilities_u16.cpp | 2 +- test/test_string_utilities_u32.cpp | 2 +- test/test_string_utilities_wchar_t.cpp | 2 +- test/test_string_view.cpp | 2 +- test/test_string_wchar_t.cpp | 2 +- test/test_string_wchar_t_external_buffer.cpp | 2 +- test/test_task_scheduler.cpp | 2 +- test/test_to_string.cpp | 2 +- test/test_to_u16string.cpp | 2 +- test/test_to_u32string.cpp | 2 +- test/test_to_wstring.cpp | 2 +- test/test_type_def.cpp | 2 +- test/test_type_lookup.cpp | 3 +- test/test_type_select.cpp | 3 +- test/test_type_traits.cpp | 2 +- test/test_unordered_map.cpp | 2 +- test/test_unordered_multimap.cpp | 2 +- test/test_unordered_multiset.cpp | 2 +- test/test_unordered_set.cpp | 2 +- test/test_user_type.cpp | 2 +- test/test_utility.cpp | 2 +- test/test_variant.cpp | 3 +- test/test_variant_pool.cpp | 3 +- test/test_vector.cpp | 2 +- test/test_vector_external_buffer.cpp | 2 +- test/test_vector_non_trivial.cpp | 2 +- test/test_vector_pointer.cpp | 2 +- test/test_vector_pointer_external_buffer.cpp | 2 +- test/test_visitor.cpp | 2 +- test/test_xor_checksum.cpp | 2 +- test/test_xor_rotate_checksum.cpp | 2 +- test/unit_test_framework.h | 35 + test/vs2019/etl.vcxproj | 1 + test/vs2019/etl.vcxproj.filters | 3 + 165 files changed, 967 insertions(+), 182 deletions(-) create mode 100644 test/test_message_router_registry.cpp create mode 100644 test/unit_test_framework.h diff --git a/test/main.cpp b/test/main.cpp index 8ad99a3f..e813b0d9 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -25,7 +25,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" int main() { diff --git a/test/test_algorithm.cpp b/test/test_algorithm.cpp index 4cbefe85..c6febc62 100644 --- a/test/test_algorithm.cpp +++ b/test/test_algorithm.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/algorithm.h" #include "etl/container.h" diff --git a/test/test_alignment.cpp b/test/test_alignment.cpp index 4928554a..1f6d5c11 100644 --- a/test/test_alignment.cpp +++ b/test/test_alignment.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/alignment.h" #include "etl/type_traits.h" diff --git a/test/test_array.cpp b/test/test_array.cpp index 41fe82fb..67d32b0c 100644 --- a/test/test_array.cpp +++ b/test/test_array.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/array.h" diff --git a/test/test_array_view.cpp b/test/test_array_view.cpp index 7aafe9e6..01fa48b4 100644 --- a/test/test_array_view.cpp +++ b/test/test_array_view.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/array_view.h" #include "etl/array.h" diff --git a/test/test_array_wrapper.cpp b/test/test_array_wrapper.cpp index 9ba573e3..78cdf4eb 100644 --- a/test/test_array_wrapper.cpp +++ b/test/test_array_wrapper.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/array_wrapper.h" diff --git a/test/test_atomic_clang_sync.cpp b/test/test_atomic_clang_sync.cpp index b3d1e382..1a3a3ca5 100644 --- a/test/test_atomic_clang_sync.cpp +++ b/test/test_atomic_clang_sync.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/platform.h" diff --git a/test/test_atomic_std.cpp b/test/test_atomic_std.cpp index 3dbb24c6..1bae0c1c 100644 --- a/test/test_atomic_std.cpp +++ b/test/test_atomic_std.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/platform.h" #include "etl/atomic/atomic_std.h" diff --git a/test/test_binary.cpp b/test/test_binary.cpp index 67626da5..e58928ec 100644 --- a/test/test_binary.cpp +++ b/test/test_binary.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_bit_stream.cpp b/test/test_bit_stream.cpp index 77cc4753..26ba6110 100644 --- a/test/test_bit_stream.cpp +++ b/test/test_bit_stream.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/bit_stream.h" diff --git a/test/test_bitset.cpp b/test/test_bitset.cpp index b4186970..e9fda8c4 100644 --- a/test/test_bitset.cpp +++ b/test/test_bitset.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_bloom_filter.cpp b/test/test_bloom_filter.cpp index d7ae04d2..88516029 100644 --- a/test/test_bloom_filter.cpp +++ b/test/test_bloom_filter.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_bresenham_line.cpp b/test/test_bresenham_line.cpp index dacaaad3..1e5d43b3 100644 --- a/test/test_bresenham_line.cpp +++ b/test/test_bresenham_line.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/bresenham_line.h" diff --git a/test/test_bsd_checksum.cpp b/test/test_bsd_checksum.cpp index 0155975a..0c342cac 100644 --- a/test/test_bsd_checksum.cpp +++ b/test/test_bsd_checksum.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_buffer_descriptors.cpp b/test/test_buffer_descriptors.cpp index 8ca32ae1..4cf477a4 100644 --- a/test/test_buffer_descriptors.cpp +++ b/test/test_buffer_descriptors.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_callback_service.cpp b/test/test_callback_service.cpp index a2784e14..fa850690 100644 --- a/test/test_callback_service.cpp +++ b/test/test_callback_service.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/function.h" #include "etl/callback_service.h" diff --git a/test/test_callback_timer.cpp b/test/test_callback_timer.cpp index 8aeb924b..3c17d22b 100644 --- a/test/test_callback_timer.cpp +++ b/test/test_callback_timer.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "etl/callback_timer.h" #include "etl/function.h" diff --git a/test/test_checksum.cpp b/test/test_checksum.cpp index 4392e144..65d6350f 100644 --- a/test/test_checksum.cpp +++ b/test/test_checksum.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_circular_buffer.cpp b/test/test_circular_buffer.cpp index 4fb28b36..30ee06ff 100644 --- a/test/test_circular_buffer.cpp +++ b/test/test_circular_buffer.cpp @@ -26,7 +26,7 @@ //SOFTWARE. //******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/circular_buffer.h" #include "etl/integral_limits.h" diff --git a/test/test_circular_buffer_external_buffer.cpp b/test/test_circular_buffer_external_buffer.cpp index f85f14a5..eb9cc43e 100644 --- a/test/test_circular_buffer_external_buffer.cpp +++ b/test/test_circular_buffer_external_buffer.cpp @@ -26,7 +26,7 @@ //SOFTWARE. //******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/circular_buffer.h" #include "etl/integral_limits.h" diff --git a/test/test_compare.cpp b/test/test_compare.cpp index fec1eece..642b2ffc 100644 --- a/test/test_compare.cpp +++ b/test/test_compare.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/compare.h" diff --git a/test/test_compiler_settings.cpp b/test/test_compiler_settings.cpp index 4fb22f35..7b8d7efb 100644 --- a/test/test_compiler_settings.cpp +++ b/test/test_compiler_settings.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/platform.h" diff --git a/test/test_constant.cpp b/test/test_constant.cpp index 353f9d33..65f3fbe7 100644 --- a/test/test_constant.cpp +++ b/test/test_constant.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/constant.h" #include "etl/integral_limits.h" diff --git a/test/test_container.cpp b/test/test_container.cpp index 8b84ce9d..517da7ef 100644 --- a/test/test_container.cpp +++ b/test/test_container.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/container.h" diff --git a/test/test_crc.cpp b/test/test_crc.cpp index 7cb75db9..e6f9ebd2 100644 --- a/test/test_crc.cpp +++ b/test/test_crc.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_cumulative_moving_average.cpp b/test/test_cumulative_moving_average.cpp index 388f38eb..9971a56c 100644 --- a/test/test_cumulative_moving_average.cpp +++ b/test/test_cumulative_moving_average.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_cyclic_value.cpp b/test/test_cyclic_value.cpp index 67f080e8..12f4ae8e 100644 --- a/test/test_cyclic_value.cpp +++ b/test/test_cyclic_value.cpp @@ -28,7 +28,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/cyclic_value.h" diff --git a/test/test_debounce.cpp b/test/test_debounce.cpp index 565b27fb..b7a9cb3c 100644 --- a/test/test_debounce.cpp +++ b/test/test_debounce.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/debounce.h" diff --git a/test/test_delegate.cpp b/test/test_delegate.cpp index 73a6c043..917da8d0 100644 --- a/test/test_delegate.cpp +++ b/test/test_delegate.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "etl/delegate.h" diff --git a/test/test_delegate_service.cpp b/test/test_delegate_service.cpp index 7b0e69e2..8e20f10b 100644 --- a/test/test_delegate_service.cpp +++ b/test/test_delegate_service.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/delegate.h" #include "etl/delegate_service.h" diff --git a/test/test_deque.cpp b/test/test_deque.cpp index dd5fe9eb..9ffe7fe5 100644 --- a/test/test_deque.cpp +++ b/test/test_deque.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "etl/deque.h" diff --git a/test/test_endian.cpp b/test/test_endian.cpp index 0f9c4cc7..f2df970e 100644 --- a/test/test_endian.cpp +++ b/test/test_endian.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include "etl/endianness.h" diff --git a/test/test_enum_type.cpp b/test/test_enum_type.cpp index 90015f70..49712a53 100644 --- a/test/test_enum_type.cpp +++ b/test/test_enum_type.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include "etl/enum_type.h" diff --git a/test/test_error_handler.cpp b/test/test_error_handler.cpp index 80434acb..6369a74b 100644 --- a/test/test_error_handler.cpp +++ b/test/test_error_handler.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include #include diff --git a/test/test_exception.cpp b/test/test_exception.cpp index 568239e1..972a8ae0 100644 --- a/test/test_exception.cpp +++ b/test/test_exception.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include "etl/exception.h" diff --git a/test/test_fixed_iterator.cpp b/test/test_fixed_iterator.cpp index 85879716..5cf794b3 100644 --- a/test/test_fixed_iterator.cpp +++ b/test/test_fixed_iterator.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_fixed_sized_memory_block_allocator.cpp b/test/test_fixed_sized_memory_block_allocator.cpp index 4767d53b..70e19f97 100644 --- a/test/test_fixed_sized_memory_block_allocator.cpp +++ b/test/test_fixed_sized_memory_block_allocator.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/fixed_sized_memory_block_allocator.h" diff --git a/test/test_flags.cpp b/test/test_flags.cpp index 6a18074c..32ff98a5 100644 --- a/test/test_flags.cpp +++ b/test/test_flags.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/flags.h" #include "etl/binary.h" diff --git a/test/test_flat_map.cpp b/test/test_flat_map.cpp index 278cd00a..a809f9da 100644 --- a/test/test_flat_map.cpp +++ b/test/test_flat_map.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_flat_multimap.cpp b/test/test_flat_multimap.cpp index 35c22aea..bb186a7e 100644 --- a/test/test_flat_multimap.cpp +++ b/test/test_flat_multimap.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_flat_multiset.cpp b/test/test_flat_multiset.cpp index edf8ad76..3985153b 100644 --- a/test/test_flat_multiset.cpp +++ b/test/test_flat_multiset.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_flat_set.cpp b/test/test_flat_set.cpp index 7c33cc3f..4b5c4d00 100644 --- a/test/test_flat_set.cpp +++ b/test/test_flat_set.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_fnv_1.cpp b/test/test_fnv_1.cpp index 3a13b65d..ebddb4b0 100644 --- a/test/test_fnv_1.cpp +++ b/test/test_fnv_1.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_format_spec.cpp b/test/test_format_spec.cpp index 439b0013..dd2c40b7 100644 --- a/test/test_format_spec.cpp +++ b/test/test_format_spec.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_forward_list.cpp b/test/test_forward_list.cpp index 9c3295bc..052dfd63 100644 --- a/test/test_forward_list.cpp +++ b/test/test_forward_list.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "data.h" diff --git a/test/test_forward_list_shared_pool.cpp b/test/test_forward_list_shared_pool.cpp index 0107f3ac..a0933f51 100644 --- a/test/test_forward_list_shared_pool.cpp +++ b/test/test_forward_list_shared_pool.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "data.h" diff --git a/test/test_fsm.cpp b/test/test_fsm.cpp index 3127e51b..386f585d 100644 --- a/test/test_fsm.cpp +++ b/test/test_fsm.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/fsm.h" #include "etl/enum_type.h" diff --git a/test/test_function.cpp b/test/test_function.cpp index b3a4b9df..40b33508 100644 --- a/test/test_function.cpp +++ b/test/test_function.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/function.h" diff --git a/test/test_functional.cpp b/test/test_functional.cpp index 916d6fa2..53bc180e 100644 --- a/test/test_functional.cpp +++ b/test/test_functional.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/functional.h" diff --git a/test/test_hash.cpp b/test/test_hash.cpp index a42d1df3..987b4ddd 100644 --- a/test/test_hash.cpp +++ b/test/test_hash.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_indirect_vector.cpp b/test/test_indirect_vector.cpp index cfbaf30d..6f5bc07c 100644 --- a/test/test_indirect_vector.cpp +++ b/test/test_indirect_vector.cpp @@ -26,7 +26,7 @@ //SOFTWARE. //******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_indirect_vector_external_buffer.cpp b/test/test_indirect_vector_external_buffer.cpp index 9311d4a1..fc052f2b 100644 --- a/test/test_indirect_vector_external_buffer.cpp +++ b/test/test_indirect_vector_external_buffer.cpp @@ -26,7 +26,7 @@ //SOFTWARE. //******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_instance_count.cpp b/test/test_instance_count.cpp index 0ab50b46..4e5d2fc3 100644 --- a/test/test_instance_count.cpp +++ b/test/test_instance_count.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/instance_count.h" diff --git a/test/test_integral_limits.cpp b/test/test_integral_limits.cpp index b58926c2..123670a1 100644 --- a/test/test_integral_limits.cpp +++ b/test/test_integral_limits.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_intrusive_forward_list.cpp b/test/test_intrusive_forward_list.cpp index 4dd5e1f9..a58d4d77 100644 --- a/test/test_intrusive_forward_list.cpp +++ b/test/test_intrusive_forward_list.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "data.h" diff --git a/test/test_intrusive_links.cpp b/test/test_intrusive_links.cpp index d9de8cd1..3c3288bd 100644 --- a/test/test_intrusive_links.cpp +++ b/test/test_intrusive_links.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "data.h" diff --git a/test/test_intrusive_list.cpp b/test/test_intrusive_list.cpp index 587cac57..2307178e 100644 --- a/test/test_intrusive_list.cpp +++ b/test/test_intrusive_list.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "data.h" diff --git a/test/test_intrusive_queue.cpp b/test/test_intrusive_queue.cpp index 9407e3c2..b4a96d2e 100644 --- a/test/test_intrusive_queue.cpp +++ b/test/test_intrusive_queue.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/intrusive_queue.h" #include "etl/intrusive_links.h" diff --git a/test/test_intrusive_stack.cpp b/test/test_intrusive_stack.cpp index 886ef7c5..25094d27 100644 --- a/test/test_intrusive_stack.cpp +++ b/test/test_intrusive_stack.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/intrusive_stack.h" #include "etl/intrusive_links.h" diff --git a/test/test_io_port.cpp b/test/test_io_port.cpp index 58330a5e..54b38402 100644 --- a/test/test_io_port.cpp +++ b/test/test_io_port.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/io_port.h" diff --git a/test/test_iterator.cpp b/test/test_iterator.cpp index 8867df43..91c2039d 100644 --- a/test/test_iterator.cpp +++ b/test/test_iterator.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include diff --git a/test/test_jenkins.cpp b/test/test_jenkins.cpp index 1f0c2db7..c4055cd6 100644 --- a/test/test_jenkins.cpp +++ b/test/test_jenkins.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_largest.cpp b/test/test_largest.cpp index 8c9ca6bd..df4e4b96 100644 --- a/test/test_largest.cpp +++ b/test/test_largest.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/largest.h" diff --git a/test/test_limits.cpp b/test/test_limits.cpp index bc75b3b2..8e286914 100644 --- a/test/test_limits.cpp +++ b/test/test_limits.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/limits.h" #include diff --git a/test/test_list.cpp b/test/test_list.cpp index 17f81e4b..5f4dcfb0 100644 --- a/test/test_list.cpp +++ b/test/test_list.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "etl/list.h" diff --git a/test/test_list_shared_pool.cpp b/test/test_list_shared_pool.cpp index 67d95c04..54fbb238 100644 --- a/test/test_list_shared_pool.cpp +++ b/test/test_list_shared_pool.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "etl/list.h" #include "etl/pool.h" diff --git a/test/test_make_string.cpp b/test/test_make_string.cpp index bdd5acb1..9e02d373 100644 --- a/test/test_make_string.cpp +++ b/test/test_make_string.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include diff --git a/test/test_map.cpp b/test/test_map.cpp index dbf30145..e1ec4ef7 100755 --- a/test/test_map.cpp +++ b/test/test_map.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_maths.cpp b/test/test_maths.cpp index 8ca52bf1..fe56172d 100644 --- a/test/test_maths.cpp +++ b/test/test_maths.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/log.h" #include "etl/power.h" diff --git a/test/test_memory.cpp b/test/test_memory.cpp index 95645c03..a35f3223 100644 --- a/test/test_memory.cpp +++ b/test/test_memory.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/memory.h" #include "etl/debug_count.h" diff --git a/test/test_message_bus.cpp b/test/test_message_bus.cpp index d158ecf4..b81be5dd 100644 --- a/test/test_message_bus.cpp +++ b/test/test_message_bus.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "etl/message_router.h" #include "etl/message_bus.h" diff --git a/test/test_message_packet.cpp b/test/test_message_packet.cpp index 5a49f69e..f8ebc15f 100644 --- a/test/test_message_packet.cpp +++ b/test/test_message_packet.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "etl/message_packet.h" diff --git a/test/test_message_router.cpp b/test/test_message_router.cpp index 3bc2377c..dd5dbd9b 100644 --- a/test/test_message_router.cpp +++ b/test/test_message_router.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "etl/message_router.h" #include "etl/queue.h" diff --git a/test/test_message_router_registry.cpp b/test/test_message_router_registry.cpp new file mode 100644 index 00000000..e8967511 --- /dev/null +++ b/test/test_message_router_registry.cpp @@ -0,0 +1,767 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 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/message_router.h" + +//*************************************************************************** +// The set of messages. +//*************************************************************************** +namespace +{ + enum + { + MESSAGE1, + MESSAGE2, + MESSAGE3, + MESSAGE4, + MESSAGE5 + }; + + enum + { + ROUTER1 = 1, + ROUTER2 = 2, + ROUTER3 = 3, + ROUTER4 = 4, + ROUTER5 = 5 + }; + + struct Message1 : public etl::message + { + Message1(etl::imessage_router& callback_) + : callback(callback_) + { + } + + etl::imessage_router& callback; + }; + + struct Message2 : public etl::message + { + Message2(etl::imessage_router& callback_) + : callback(callback_) + { + } + + etl::imessage_router& callback; + }; + + struct Message3 : public etl::message + { + Message3(etl::imessage_router& callback_) + : callback(callback_) + { + } + + etl::imessage_router& callback; + int value[10]; + }; + + struct Message4 : public etl::message + { + Message4(etl::imessage_router& callback_) + : callback(callback_) + { + } + + etl::imessage_router& callback; + }; + + struct Response : public etl::message + { + }; + + Response response; + + int call_order; + + //*************************************************************************** + // Router that handles messages 1, 2, 3, 4, 5. + //*************************************************************************** + class RouterA : public etl::message_router + { + public: + + RouterA(etl::message_router_id_t id) + : message_router(id), + message1_count(0), + message2_count(0), + message3_count(0), + message4_count(0), + message5_count(0), + message_unknown_count(0) + { + + } + + void on_receive(const Message1& msg) + { + ++message1_count; + etl::send_message(msg.callback, response); + + order = call_order++; + } + + void on_receive(const Message2& msg) + { + ++message2_count; + etl::send_message(msg.callback, response); + } + + void on_receive(const Message3& msg) + { + ++message3_count; + etl::send_message(msg.callback, response); + } + + void on_receive(const Message4& msg) + { + ++message4_count; + etl::send_message(msg.callback, response); + } + + void on_receive(const Response&) + { + ++message5_count; + } + + void on_receive_unknown(const etl::imessage&) + { + ++message_unknown_count; + } + + int message1_count; + int message2_count; + int message3_count; + int message4_count; + int message5_count; + int message_unknown_count; + int order; + }; + + //*************************************************************************** + // Router that handles messages 1, 2, 4 and 5 and returns nothing. + //*************************************************************************** + class RouterB : public etl::message_router + { + public: + + RouterB(etl::message_router_id_t id) + : message_router(id), + message1_count(0), + message2_count(0), + message4_count(0), + message5_count(0), + message_unknown_count(0) + { + + } + + void on_receive(const Message1& msg) + { + ++message1_count; + etl::send_message(msg.callback, response); + } + + void on_receive(const Message2& msg) + { + ++message2_count; + etl::send_message(msg.callback, response); + } + + void on_receive(const Message4& msg) + { + ++message4_count; + etl::send_message(msg.callback, response); + } + + void on_receive(const Response&) + { + ++message5_count; + } + + void on_receive_unknown(const etl::imessage& msg) + { + ++message_unknown_count; + //etl::send_message(msg.callback, response); + } + + int message1_count; + int message2_count; + int message4_count; + int message5_count; + int message_unknown_count; + }; + + SUITE(test_message_router) + { + //************************************************************************* + TEST(message_bus_subscribe_unsubscribe) + { + etl::message_bus<2> bus1; + + RouterA router1(0); + RouterB router2(1); + RouterA router3(2); + + CHECK_EQUAL(0U, bus1.size()); + + CHECK_NO_THROW(bus1.subscribe(router1)); + CHECK_EQUAL(1U, bus1.size()); + + CHECK_NO_THROW(bus1.subscribe(router2)); + CHECK_EQUAL(2U, bus1.size()); + + CHECK_THROW(bus1.subscribe(router3), etl::message_bus_too_many_subscribers); + CHECK_EQUAL(2U, bus1.size()); + + bus1.unsubscribe(router1); + CHECK_EQUAL(1U, bus1.size()); + + // Erase router not in list. + bus1.unsubscribe(router3); + CHECK_EQUAL(1U, bus1.size()); + + // Erase using id. + bus1.unsubscribe(router2.get_message_router_id()); + CHECK_EQUAL(0U, bus1.size()); + + // Erase router from empty list. + bus1.unsubscribe(router2); + CHECK_EQUAL(0U, bus1.size()); + } + + //************************************************************************* + TEST(message_bus_subscribe_unsubscribe_sub_bus) + { + etl::message_bus<4> bus1; + etl::message_bus<2> bus2; + etl::message_bus<3> bus3; + + RouterA router1(ROUTER1); + RouterA router2(ROUTER2); + RouterA router3(ROUTER3); + RouterA router4(ROUTER4); + + bus1.subscribe(bus2); + bus1.subscribe(router1); + bus1.subscribe(bus3); + bus1.subscribe(router2); + + bus2.subscribe(router3); + bus3.subscribe(router4); + + CHECK_EQUAL(4U, bus1.size()); + + bus1.unsubscribe(etl::imessage_bus::MESSAGE_BUS); + CHECK_EQUAL(2U, bus1.size()); + + bus1.unsubscribe(etl::imessage_bus::ALL_MESSAGE_ROUTERS); + CHECK_EQUAL(0U, bus1.size()); + } + + //************************************************************************* + TEST(message_bus_broadcast) + { + etl::message_bus<2> bus1; + + RouterA router1(ROUTER1); + RouterB router2(ROUTER2); + RouterA callback(ROUTER3); + + bus1.subscribe(router1); + bus1.subscribe(router2); + + Message1 message1(callback); + Message2 message2(callback); + Message3 message3(callback); + Message4 message4(callback); + + bus1.receive(message1); + + CHECK_EQUAL(1, router1.message1_count); + CHECK_EQUAL(0, router1.message2_count); + CHECK_EQUAL(0, router1.message3_count); + CHECK_EQUAL(0, router1.message4_count); + CHECK_EQUAL(0, router1.message5_count); + CHECK_EQUAL(0, router1.message_unknown_count); + + CHECK_EQUAL(1, router2.message1_count); + CHECK_EQUAL(0, router2.message2_count); + CHECK_EQUAL(0, router2.message4_count); + CHECK_EQUAL(0, router2.message5_count); + CHECK_EQUAL(0, router2.message_unknown_count); + + CHECK_EQUAL(2, callback.message5_count); + + bus1.receive(message2); + + CHECK_EQUAL(1, router1.message1_count); + CHECK_EQUAL(1, router1.message2_count); + CHECK_EQUAL(0, router1.message3_count); + CHECK_EQUAL(0, router1.message4_count); + CHECK_EQUAL(0, router1.message5_count); + CHECK_EQUAL(0, router1.message_unknown_count); + + CHECK_EQUAL(1, router2.message1_count); + CHECK_EQUAL(1, router2.message2_count); + CHECK_EQUAL(0, router2.message4_count); + CHECK_EQUAL(0, router2.message5_count); + CHECK_EQUAL(0, router2.message_unknown_count); + + CHECK_EQUAL(4, callback.message5_count); + + bus1.receive(message3); + + CHECK_EQUAL(1, router1.message1_count); + CHECK_EQUAL(1, router1.message2_count); + CHECK_EQUAL(1, router1.message3_count); + CHECK_EQUAL(0, router1.message4_count); + CHECK_EQUAL(0, router1.message5_count); + CHECK_EQUAL(0, router1.message_unknown_count); + + CHECK_EQUAL(1, router2.message1_count); + CHECK_EQUAL(1, router2.message2_count); + CHECK_EQUAL(0, router2.message4_count); + CHECK_EQUAL(0, router2.message5_count); + CHECK_EQUAL(0, router2.message_unknown_count); + + CHECK_EQUAL(5, callback.message5_count); + + // Use global function. + etl::send_message(bus1, message4); + + CHECK_EQUAL(1, router1.message1_count); + CHECK_EQUAL(1, router1.message2_count); + CHECK_EQUAL(1, router1.message3_count); + CHECK_EQUAL(1, router1.message4_count); + CHECK_EQUAL(0, router1.message5_count); + CHECK_EQUAL(0, router1.message_unknown_count); + + CHECK_EQUAL(1, router2.message1_count); + CHECK_EQUAL(1, router2.message2_count); + CHECK_EQUAL(1, router2.message4_count); + CHECK_EQUAL(0, router2.message5_count); + CHECK_EQUAL(0, router2.message_unknown_count); + + CHECK_EQUAL(7, callback.message5_count); + } + + //************************************************************************* + TEST(message_bus_broadcast_as_router) + { + etl::message_bus<2> bus1; + + RouterA router1(ROUTER1); + RouterB router2(ROUTER2); + RouterA callback(ROUTER3); + + bus1.subscribe(router1); + bus1.subscribe(router2); + + Message1 message1(callback); + Message2 message2(callback); + Message3 message3(callback); + Message4 message4(callback); + + // Reference to router sub-type + etl::imessage_router& irouter = bus1; + + irouter.receive(message1); + + CHECK_EQUAL(1, router1.message1_count); + CHECK_EQUAL(0, router1.message2_count); + CHECK_EQUAL(0, router1.message3_count); + CHECK_EQUAL(0, router1.message4_count); + CHECK_EQUAL(0, router1.message5_count); + CHECK_EQUAL(0, router1.message_unknown_count); + + CHECK_EQUAL(1, router2.message1_count); + CHECK_EQUAL(0, router2.message2_count); + CHECK_EQUAL(0, router2.message4_count); + CHECK_EQUAL(0, router2.message5_count); + CHECK_EQUAL(0, router2.message_unknown_count); + + CHECK_EQUAL(2, callback.message5_count); + + irouter.receive(message2); + + CHECK_EQUAL(1, router1.message1_count); + CHECK_EQUAL(1, router1.message2_count); + CHECK_EQUAL(0, router1.message3_count); + CHECK_EQUAL(0, router1.message4_count); + CHECK_EQUAL(0, router1.message5_count); + CHECK_EQUAL(0, router1.message_unknown_count); + + CHECK_EQUAL(1, router2.message1_count); + CHECK_EQUAL(1, router2.message2_count); + CHECK_EQUAL(0, router2.message4_count); + CHECK_EQUAL(0, router2.message5_count); + CHECK_EQUAL(0, router2.message_unknown_count); + + CHECK_EQUAL(4, callback.message5_count); + + irouter.receive(message3); + + CHECK_EQUAL(1, router1.message1_count); + CHECK_EQUAL(1, router1.message2_count); + CHECK_EQUAL(1, router1.message3_count); + CHECK_EQUAL(0, router1.message4_count); + CHECK_EQUAL(0, router1.message5_count); + CHECK_EQUAL(0, router1.message_unknown_count); + + CHECK_EQUAL(1, router2.message1_count); + CHECK_EQUAL(1, router2.message2_count); + CHECK_EQUAL(0, router2.message4_count); + CHECK_EQUAL(0, router2.message5_count); + CHECK_EQUAL(0, router2.message_unknown_count); + + CHECK_EQUAL(5, callback.message5_count); + + // Use global function. + etl::send_message(irouter, message4); + + CHECK_EQUAL(1, router1.message1_count); + CHECK_EQUAL(1, router1.message2_count); + CHECK_EQUAL(1, router1.message3_count); + CHECK_EQUAL(1, router1.message4_count); + CHECK_EQUAL(0, router1.message5_count); + CHECK_EQUAL(0, router1.message_unknown_count); + + CHECK_EQUAL(1, router2.message1_count); + CHECK_EQUAL(1, router2.message2_count); + CHECK_EQUAL(1, router2.message4_count); + CHECK_EQUAL(0, router2.message5_count); + CHECK_EQUAL(0, router2.message_unknown_count); + + CHECK_EQUAL(7, callback.message5_count); + } + + //************************************************************************* + TEST(message_bus_addressed) + { + etl::message_bus<2> bus1; + + RouterA router1(ROUTER1); + RouterB router2(ROUTER2); + RouterA callback(ROUTER3); + + bus1.subscribe(router1); + bus1.subscribe(router2); + + Message1 message1(callback); + Message2 message2(callback); + Message3 message3(callback); + Message4 message4(callback); + + bus1.receive(ROUTER1, message1); + + CHECK_EQUAL(1, router1.message1_count); + CHECK_EQUAL(0, router1.message2_count); + CHECK_EQUAL(0, router1.message3_count); + CHECK_EQUAL(0, router1.message4_count); + CHECK_EQUAL(0, router1.message5_count); + CHECK_EQUAL(0, router1.message_unknown_count); + + CHECK_EQUAL(0, router2.message1_count); + CHECK_EQUAL(0, router2.message2_count); + CHECK_EQUAL(0, router2.message4_count); + CHECK_EQUAL(0, router2.message5_count); + CHECK_EQUAL(0, router2.message_unknown_count); + + CHECK_EQUAL(1, callback.message5_count); + + bus1.receive(ROUTER2, message2); + + CHECK_EQUAL(1, router1.message1_count); + CHECK_EQUAL(0, router1.message2_count); + CHECK_EQUAL(0, router1.message3_count); + CHECK_EQUAL(0, router1.message4_count); + CHECK_EQUAL(0, router1.message5_count); + CHECK_EQUAL(0, router1.message_unknown_count); + + CHECK_EQUAL(0, router2.message1_count); + CHECK_EQUAL(1, router2.message2_count); + CHECK_EQUAL(0, router2.message4_count); + CHECK_EQUAL(0, router2.message5_count); + CHECK_EQUAL(0, router2.message_unknown_count); + + CHECK_EQUAL(2, callback.message5_count); + + bus1.receive(ROUTER1, message3); + + CHECK_EQUAL(1, router1.message1_count); + CHECK_EQUAL(0, router1.message2_count); + CHECK_EQUAL(1, router1.message3_count); + CHECK_EQUAL(0, router1.message4_count); + CHECK_EQUAL(0, router1.message5_count); + CHECK_EQUAL(0, router1.message_unknown_count); + + CHECK_EQUAL(0, router2.message1_count); + CHECK_EQUAL(1, router2.message2_count); + CHECK_EQUAL(0, router2.message4_count); + CHECK_EQUAL(0, router2.message5_count); + CHECK_EQUAL(0, router2.message_unknown_count); + + CHECK_EQUAL(3, callback.message5_count); + + // Use global function. + etl::send_message(bus1, ROUTER2, message4); + + CHECK_EQUAL(1, router1.message1_count); + CHECK_EQUAL(0, router1.message2_count); + CHECK_EQUAL(1, router1.message3_count); + CHECK_EQUAL(0, router1.message4_count); + CHECK_EQUAL(0, router1.message5_count); + CHECK_EQUAL(0, router1.message_unknown_count); + + CHECK_EQUAL(0, router2.message1_count); + CHECK_EQUAL(1, router2.message2_count); + CHECK_EQUAL(1, router2.message4_count); + CHECK_EQUAL(0, router2.message5_count); + CHECK_EQUAL(0, router2.message_unknown_count); + + CHECK_EQUAL(4, callback.message5_count); + + // Send to a router not subscribed to the bus. + bus1.receive(ROUTER5, message1); + + CHECK_EQUAL(1, router1.message1_count); + CHECK_EQUAL(0, router1.message2_count); + CHECK_EQUAL(1, router1.message3_count); + CHECK_EQUAL(0, router1.message4_count); + CHECK_EQUAL(0, router1.message5_count); + CHECK_EQUAL(0, router1.message_unknown_count); + + CHECK_EQUAL(0, router2.message1_count); + CHECK_EQUAL(1, router2.message2_count); + CHECK_EQUAL(1, router2.message4_count); + CHECK_EQUAL(0, router2.message5_count); + CHECK_EQUAL(0, router2.message_unknown_count); + + CHECK_EQUAL(4, callback.message5_count); + } + + //************************************************************************* + TEST(message_bus_addressed_duplicate_router_id) + { + etl::message_bus<3> bus1; + + RouterA router1(ROUTER1); + RouterB router2(ROUTER1); + RouterB router3(ROUTER2); + RouterA callback(ROUTER3); + + bus1.subscribe(router1); + bus1.subscribe(router2); + bus1.subscribe(router3); + + Message1 message1(callback); + Message2 message2(callback); + Message3 message3(callback); + + bus1.receive(ROUTER1, message1); + + CHECK_EQUAL(1, router1.message1_count); + CHECK_EQUAL(0, router1.message2_count); + CHECK_EQUAL(0, router1.message3_count); + CHECK_EQUAL(0, router1.message4_count); + CHECK_EQUAL(0, router1.message5_count); + CHECK_EQUAL(0, router1.message_unknown_count); + + CHECK_EQUAL(1, router2.message1_count); + CHECK_EQUAL(0, router2.message2_count); + CHECK_EQUAL(0, router2.message4_count); + CHECK_EQUAL(0, router2.message5_count); + CHECK_EQUAL(0, router2.message_unknown_count); + + CHECK_EQUAL(0, router3.message1_count); + CHECK_EQUAL(0, router3.message2_count); + CHECK_EQUAL(0, router3.message4_count); + CHECK_EQUAL(0, router3.message5_count); + CHECK_EQUAL(0, router3.message_unknown_count); + + CHECK_EQUAL(2, callback.message5_count); + } + + //************************************************************************* + TEST(message_bus_broadcast_addressed_sub_bus) + { + etl::message_bus<3> bus1; + etl::message_bus<2> bus2; + + RouterA router1(ROUTER1); + RouterA router2(ROUTER2); + RouterA router3(ROUTER3); + RouterA router4(ROUTER4); + + RouterA callback(ROUTER5); + + bus1.subscribe(router1); + bus1.subscribe(router2); + bus1.subscribe(bus2); + + bus2.subscribe(router3); + bus2.subscribe(router4); + + Message1 message1(callback); + Message2 message2(callback); + Message3 message3(callback); + Message4 message4(callback); + + // Broadcast to bus1 + bus1.receive(message1); + + CHECK_EQUAL(1, router1.message1_count); + CHECK_EQUAL(0, router1.message2_count); + CHECK_EQUAL(0, router1.message3_count); + CHECK_EQUAL(0, router1.message4_count); + CHECK_EQUAL(0, router1.message5_count); + CHECK_EQUAL(0, router1.message_unknown_count); + + CHECK_EQUAL(1, router2.message1_count); + CHECK_EQUAL(0, router2.message2_count); + CHECK_EQUAL(0, router2.message4_count); + CHECK_EQUAL(0, router2.message5_count); + CHECK_EQUAL(0, router2.message_unknown_count); + + CHECK_EQUAL(1, router3.message1_count); + CHECK_EQUAL(0, router3.message2_count); + CHECK_EQUAL(0, router3.message4_count); + CHECK_EQUAL(0, router3.message5_count); + CHECK_EQUAL(0, router3.message_unknown_count); + + CHECK_EQUAL(1, router4.message1_count); + CHECK_EQUAL(0, router4.message2_count); + CHECK_EQUAL(0, router4.message4_count); + CHECK_EQUAL(0, router4.message5_count); + CHECK_EQUAL(0, router4.message_unknown_count); + + CHECK_EQUAL(4, callback.message5_count); + + // Addressed to ROUTER2 + bus1.receive(ROUTER2, message1); + + CHECK_EQUAL(1, router1.message1_count); + CHECK_EQUAL(0, router1.message2_count); + CHECK_EQUAL(0, router1.message3_count); + CHECK_EQUAL(0, router1.message4_count); + CHECK_EQUAL(0, router1.message5_count); + CHECK_EQUAL(0, router1.message_unknown_count); + + CHECK_EQUAL(2, router2.message1_count); + CHECK_EQUAL(0, router2.message2_count); + CHECK_EQUAL(0, router2.message4_count); + CHECK_EQUAL(0, router2.message5_count); + CHECK_EQUAL(0, router2.message_unknown_count); + + CHECK_EQUAL(1, router3.message1_count); + CHECK_EQUAL(0, router3.message2_count); + CHECK_EQUAL(0, router3.message4_count); + CHECK_EQUAL(0, router3.message5_count); + CHECK_EQUAL(0, router3.message_unknown_count); + + CHECK_EQUAL(1, router4.message1_count); + CHECK_EQUAL(0, router4.message2_count); + CHECK_EQUAL(0, router4.message4_count); + CHECK_EQUAL(0, router4.message5_count); + CHECK_EQUAL(0, router4.message_unknown_count); + + CHECK_EQUAL(5, callback.message5_count); + + // Addressed to ROUTER3 via bus2 + bus1.receive(ROUTER3, message1); + + CHECK_EQUAL(1, router1.message1_count); + CHECK_EQUAL(0, router1.message2_count); + CHECK_EQUAL(0, router1.message3_count); + CHECK_EQUAL(0, router1.message4_count); + CHECK_EQUAL(0, router1.message5_count); + CHECK_EQUAL(0, router1.message_unknown_count); + + CHECK_EQUAL(2, router2.message1_count); + CHECK_EQUAL(0, router2.message2_count); + CHECK_EQUAL(0, router2.message4_count); + CHECK_EQUAL(0, router2.message5_count); + CHECK_EQUAL(0, router2.message_unknown_count); + + CHECK_EQUAL(2, router3.message1_count); + CHECK_EQUAL(0, router3.message2_count); + CHECK_EQUAL(0, router3.message4_count); + CHECK_EQUAL(0, router3.message5_count); + CHECK_EQUAL(0, router3.message_unknown_count); + + CHECK_EQUAL(1, router4.message1_count); + CHECK_EQUAL(0, router4.message2_count); + CHECK_EQUAL(0, router4.message4_count); + CHECK_EQUAL(0, router4.message5_count); + CHECK_EQUAL(0, router4.message_unknown_count); + + CHECK_EQUAL(6, callback.message5_count); + } + + //************************************************************************* + TEST(message_bus_broadcast_order) + { + etl::message_bus<4> bus1; + etl::message_bus<2> bus2; + etl::message_bus<2> bus3; + + RouterA router1(ROUTER1); + RouterA router2(ROUTER2); + RouterA router3(ROUTER3); + RouterA router4a(ROUTER4); + RouterA router4b(ROUTER4); + + RouterA callback(ROUTER5); + + bus1.subscribe(router1); + bus1.subscribe(bus3); + bus1.subscribe(bus2); + bus1.subscribe(router2); + + bus2.subscribe(router3); + bus3.subscribe(router4b); + bus3.subscribe(router4a); + + Message1 message1(callback); + + call_order = 0; + + bus1.receive(message1); + + CHECK_EQUAL(0, router1.order); + CHECK_EQUAL(1, router2.order); + CHECK_EQUAL(2, router4b.order); + CHECK_EQUAL(3, router4a.order); + CHECK_EQUAL(4, router3.order); + } + }; +} diff --git a/test/test_message_timer.cpp b/test/test_message_timer.cpp index 179df367..c3f96448 100644 --- a/test/test_message_timer.cpp +++ b/test/test_message_timer.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "etl/message_router.h" #include "etl/message_bus.h" diff --git a/test/test_multi_array.cpp b/test/test_multi_array.cpp index 411fc7ba..318feb18 100644 --- a/test/test_multi_array.cpp +++ b/test/test_multi_array.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/array.h" #include "etl/multi_array.h" diff --git a/test/test_multi_range.cpp b/test/test_multi_range.cpp index 16646c4b..2fe1281e 100644 --- a/test/test_multi_range.cpp +++ b/test/test_multi_range.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/multi_range.h" #include "etl/functional.h" diff --git a/test/test_multimap.cpp b/test/test_multimap.cpp index d3b64a8d..0466f9e3 100755 --- a/test/test_multimap.cpp +++ b/test/test_multimap.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_multiset.cpp b/test/test_multiset.cpp index b952b605..8a8cdf9c 100755 --- a/test/test_multiset.cpp +++ b/test/test_multiset.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_murmur3.cpp b/test/test_murmur3.cpp index 41778fc4..7e380a93 100644 --- a/test/test_murmur3.cpp +++ b/test/test_murmur3.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "murmurhash3.h" // The 'C' reference implementation. diff --git a/test/test_numeric.cpp b/test/test_numeric.cpp index a3332f50..ea722cb3 100644 --- a/test/test_numeric.cpp +++ b/test/test_numeric.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/numeric.h" diff --git a/test/test_observer.cpp b/test/test_observer.cpp index c1aa27cb..3e705f07 100644 --- a/test/test_observer.cpp +++ b/test/test_observer.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/observer.h" diff --git a/test/test_optional.cpp b/test/test_optional.cpp index 3d996161..f216b6a0 100644 --- a/test/test_optional.cpp +++ b/test/test_optional.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_packet.cpp b/test/test_packet.cpp index 1b3ceeb4..fb761377 100644 --- a/test/test_packet.cpp +++ b/test/test_packet.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "etl/packet.h" #include "etl/largest.h" diff --git a/test/test_parameter_pack.cpp b/test/test_parameter_pack.cpp index 078a1cf7..1ab28fd5 100644 --- a/test/test_parameter_pack.cpp +++ b/test/test_parameter_pack.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "etl/parameter_pack.h" diff --git a/test/test_parameter_type.cpp b/test/test_parameter_type.cpp index db857f86..de7f29da 100644 --- a/test/test_parameter_type.cpp +++ b/test/test_parameter_type.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_parity_checksum.cpp b/test/test_parity_checksum.cpp index 5cca453b..618ee12b 100644 --- a/test/test_parity_checksum.cpp +++ b/test/test_parity_checksum.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_pearson.cpp b/test/test_pearson.cpp index 25d824ee..415c03da 100644 --- a/test/test_pearson.cpp +++ b/test/test_pearson.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_pool.cpp b/test/test_pool.cpp index b5c038b7..35f387c4 100644 --- a/test/test_pool.cpp +++ b/test/test_pool.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "data.h" diff --git a/test/test_priority_queue.cpp b/test/test_priority_queue.cpp index ebca6eaf..1c3d7790 100644 --- a/test/test_priority_queue.cpp +++ b/test/test_priority_queue.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include diff --git a/test/test_queue.cpp b/test/test_queue.cpp index 2cf4824c..1140a65d 100644 --- a/test/test_queue.cpp +++ b/test/test_queue.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include diff --git a/test/test_queue_lockable.cpp b/test/test_queue_lockable.cpp index 65edaa50..30b0eeae 100644 --- a/test/test_queue_lockable.cpp +++ b/test/test_queue_lockable.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/queue_lockable.h" diff --git a/test/test_queue_lockable_small.cpp b/test/test_queue_lockable_small.cpp index d4351e06..488afe0d 100644 --- a/test/test_queue_lockable_small.cpp +++ b/test/test_queue_lockable_small.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/queue_lockable.h" diff --git a/test/test_queue_memory_model_small.cpp b/test/test_queue_memory_model_small.cpp index 8e6dedd4..44b31c0e 100644 --- a/test/test_queue_memory_model_small.cpp +++ b/test/test_queue_memory_model_small.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include diff --git a/test/test_queue_mpmc_mutex.cpp b/test/test_queue_mpmc_mutex.cpp index ee2b4a54..7d92539b 100644 --- a/test/test_queue_mpmc_mutex.cpp +++ b/test/test_queue_mpmc_mutex.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_queue_mpmc_mutex_small.cpp b/test/test_queue_mpmc_mutex_small.cpp index fdf087ec..9cd9edde 100644 --- a/test/test_queue_mpmc_mutex_small.cpp +++ b/test/test_queue_mpmc_mutex_small.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_queue_spsc_atomic.cpp b/test/test_queue_spsc_atomic.cpp index a4e20694..08eb4d99 100644 --- a/test/test_queue_spsc_atomic.cpp +++ b/test/test_queue_spsc_atomic.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_queue_spsc_atomic_small.cpp b/test/test_queue_spsc_atomic_small.cpp index 1a50fdad..6ab6a7ef 100644 --- a/test/test_queue_spsc_atomic_small.cpp +++ b/test/test_queue_spsc_atomic_small.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_queue_spsc_isr.cpp b/test/test_queue_spsc_isr.cpp index 286f73d1..665c0c1b 100644 --- a/test/test_queue_spsc_isr.cpp +++ b/test/test_queue_spsc_isr.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/queue_spsc_isr.h" diff --git a/test/test_queue_spsc_isr_small.cpp b/test/test_queue_spsc_isr_small.cpp index 1ce8e8e7..212c5cab 100644 --- a/test/test_queue_spsc_isr_small.cpp +++ b/test/test_queue_spsc_isr_small.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/queue_spsc_isr.h" diff --git a/test/test_queue_spsc_locked.cpp b/test/test_queue_spsc_locked.cpp index 6abe7c92..6e82b0bb 100644 --- a/test/test_queue_spsc_locked.cpp +++ b/test/test_queue_spsc_locked.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/queue_spsc_locked.h" #include "etl/function.h" diff --git a/test/test_queue_spsc_locked_small.cpp b/test/test_queue_spsc_locked_small.cpp index 93cd822f..8dcee543 100644 --- a/test/test_queue_spsc_locked_small.cpp +++ b/test/test_queue_spsc_locked_small.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/queue_spsc_locked.h" diff --git a/test/test_random.cpp b/test/test_random.cpp index d98a7a9e..01113411 100644 --- a/test/test_random.cpp +++ b/test/test_random.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include diff --git a/test/test_reference_flat_map.cpp b/test/test_reference_flat_map.cpp index cecc8683..b54d7203 100644 --- a/test/test_reference_flat_map.cpp +++ b/test/test_reference_flat_map.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_reference_flat_multimap.cpp b/test/test_reference_flat_multimap.cpp index 0acbab79..c8b5cd5e 100644 --- a/test/test_reference_flat_multimap.cpp +++ b/test/test_reference_flat_multimap.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_reference_flat_multiset.cpp b/test/test_reference_flat_multiset.cpp index 8f3da5fb..d3ccae6c 100644 --- a/test/test_reference_flat_multiset.cpp +++ b/test/test_reference_flat_multiset.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_reference_flat_set.cpp b/test/test_reference_flat_set.cpp index ec956302..1be72de6 100644 --- a/test/test_reference_flat_set.cpp +++ b/test/test_reference_flat_set.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_scaled_rounding.cpp b/test/test_scaled_rounding.cpp index 54a0a148..c916126a 100644 --- a/test/test_scaled_rounding.cpp +++ b/test/test_scaled_rounding.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/scaled_rounding.h" diff --git a/test/test_set.cpp b/test/test_set.cpp index 6198fd2c..c3384bbe 100755 --- a/test/test_set.cpp +++ b/test/test_set.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_shared_message.cpp b/test/test_shared_message.cpp index 645f343b..7e2569ea 100644 --- a/test/test_shared_message.cpp +++ b/test/test_shared_message.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/shared_message.h" #include "etl/message.h" diff --git a/test/test_smallest.cpp b/test/test_smallest.cpp index 2e8591da..335c6c9e 100644 --- a/test/test_smallest.cpp +++ b/test/test_smallest.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/smallest.h" diff --git a/test/test_span.cpp b/test/test_span.cpp index b08342bc..618edaf9 100644 --- a/test/test_span.cpp +++ b/test/test_span.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/span.h" #include "etl/array.h" diff --git a/test/test_stack.cpp b/test/test_stack.cpp index c1b187fb..ace2e305 100644 --- a/test/test_stack.cpp +++ b/test/test_stack.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include diff --git a/test/test_state_chart.cpp b/test/test_state_chart.cpp index 37a9c601..821b921f 100644 --- a/test/test_state_chart.cpp +++ b/test/test_state_chart.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/state_chart.h" #include "etl/enum_type.h" diff --git a/test/test_state_chart_with_data_parameter.cpp b/test/test_state_chart_with_data_parameter.cpp index 6d021688..59857dac 100644 --- a/test/test_state_chart_with_data_parameter.cpp +++ b/test/test_state_chart_with_data_parameter.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/state_chart.h" #include "etl/enum_type.h" diff --git a/test/test_state_chart_with_rvalue_data_parameter.cpp b/test/test_state_chart_with_rvalue_data_parameter.cpp index 8aac63d2..f6c43b6d 100644 --- a/test/test_state_chart_with_rvalue_data_parameter.cpp +++ b/test/test_state_chart_with_rvalue_data_parameter.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/state_chart.h" #include "etl/enum_type.h" diff --git a/test/test_string_char.cpp b/test/test_string_char.cpp index 0298b76d..dab48f9b 100644 --- a/test/test_string_char.cpp +++ b/test/test_string_char.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_string_char_external_buffer.cpp b/test/test_string_char_external_buffer.cpp index 42b827e8..7fe729b1 100644 --- a/test/test_string_char_external_buffer.cpp +++ b/test/test_string_char_external_buffer.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_string_stream.cpp b/test/test_string_stream.cpp index 3aa81d03..71954033 100644 --- a/test/test_string_stream.cpp +++ b/test/test_string_stream.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_string_stream_u16.cpp b/test/test_string_stream_u16.cpp index dc12868e..658768ae 100644 --- a/test/test_string_stream_u16.cpp +++ b/test/test_string_stream_u16.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_string_stream_u32.cpp b/test/test_string_stream_u32.cpp index af26e830..d8e608b1 100644 --- a/test/test_string_stream_u32.cpp +++ b/test/test_string_stream_u32.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_string_stream_wchar_t.cpp b/test/test_string_stream_wchar_t.cpp index 1ca38a37..a142e3c8 100644 --- a/test/test_string_stream_wchar_t.cpp +++ b/test/test_string_stream_wchar_t.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_string_u16.cpp b/test/test_string_u16.cpp index cca9ec3f..15703e12 100644 --- a/test/test_string_u16.cpp +++ b/test/test_string_u16.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_string_u16_external_buffer.cpp b/test/test_string_u16_external_buffer.cpp index e7fbe32b..c62639cd 100644 --- a/test/test_string_u16_external_buffer.cpp +++ b/test/test_string_u16_external_buffer.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_string_u32.cpp b/test/test_string_u32.cpp index 52c3064b..f5c2dfb3 100644 --- a/test/test_string_u32.cpp +++ b/test/test_string_u32.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_string_u32_external_buffer.cpp b/test/test_string_u32_external_buffer.cpp index b4c9ec7d..b210efdd 100644 --- a/test/test_string_u32_external_buffer.cpp +++ b/test/test_string_u32_external_buffer.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_string_utilities.cpp b/test/test_string_utilities.cpp index 1ee0d6d7..e7b72b2b 100644 --- a/test/test_string_utilities.cpp +++ b/test/test_string_utilities.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/string.h" #include "etl/string_view.h" diff --git a/test/test_string_utilities_std.cpp b/test/test_string_utilities_std.cpp index 4a1d47c5..a5f7a8a7 100644 --- a/test/test_string_utilities_std.cpp +++ b/test/test_string_utilities_std.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_string_utilities_std_u16.cpp b/test/test_string_utilities_std_u16.cpp index 97cae45c..a92ae88e 100644 --- a/test/test_string_utilities_std_u16.cpp +++ b/test/test_string_utilities_std_u16.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_string_utilities_std_u32.cpp b/test/test_string_utilities_std_u32.cpp index 72c3674f..db00f4fc 100644 --- a/test/test_string_utilities_std_u32.cpp +++ b/test/test_string_utilities_std_u32.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_string_utilities_std_wchar_t.cpp b/test/test_string_utilities_std_wchar_t.cpp index 0f99fdb0..b2d3e81d 100644 --- a/test/test_string_utilities_std_wchar_t.cpp +++ b/test/test_string_utilities_std_wchar_t.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_string_utilities_u16.cpp b/test/test_string_utilities_u16.cpp index 086a2eeb..68db161f 100644 --- a/test/test_string_utilities_u16.cpp +++ b/test/test_string_utilities_u16.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/u16string.h" #include "etl/string_view.h" diff --git a/test/test_string_utilities_u32.cpp b/test/test_string_utilities_u32.cpp index b68f46f7..9b8968a7 100644 --- a/test/test_string_utilities_u32.cpp +++ b/test/test_string_utilities_u32.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/u32string.h" #include "etl/string_view.h" diff --git a/test/test_string_utilities_wchar_t.cpp b/test/test_string_utilities_wchar_t.cpp index 3a20e464..1bae082f 100644 --- a/test/test_string_utilities_wchar_t.cpp +++ b/test/test_string_utilities_wchar_t.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/wstring.h" #include "etl/string_view.h" diff --git a/test/test_string_view.cpp b/test/test_string_view.cpp index bb0cd5cb..ac84ed6a 100644 --- a/test/test_string_view.cpp +++ b/test/test_string_view.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/string_view.h" #include "etl/string.h" diff --git a/test/test_string_wchar_t.cpp b/test/test_string_wchar_t.cpp index 8b2794b4..a6d0b7fb 100644 --- a/test/test_string_wchar_t.cpp +++ b/test/test_string_wchar_t.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_string_wchar_t_external_buffer.cpp b/test/test_string_wchar_t_external_buffer.cpp index ee326750..f2fb7a70 100644 --- a/test/test_string_wchar_t_external_buffer.cpp +++ b/test/test_string_wchar_t_external_buffer.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_task_scheduler.cpp b/test/test_task_scheduler.cpp index 50e572c6..bb3e7cd6 100644 --- a/test/test_task_scheduler.cpp +++ b/test/test_task_scheduler.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_to_string.cpp b/test/test_to_string.cpp index e690fae1..5221884f 100644 --- a/test/test_to_string.cpp +++ b/test/test_to_string.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_to_u16string.cpp b/test/test_to_u16string.cpp index 215a44de..fff948be 100644 --- a/test/test_to_u16string.cpp +++ b/test/test_to_u16string.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/to_u16string.h" #include "etl/u16string.h" diff --git a/test/test_to_u32string.cpp b/test/test_to_u32string.cpp index 919a4153..e5928416 100644 --- a/test/test_to_u32string.cpp +++ b/test/test_to_u32string.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include diff --git a/test/test_to_wstring.cpp b/test/test_to_wstring.cpp index 1a99c62c..d213ab80 100644 --- a/test/test_to_wstring.cpp +++ b/test/test_to_wstring.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_type_def.cpp b/test/test_type_def.cpp index 78cb724c..2487c3da 100644 --- a/test/test_type_def.cpp +++ b/test/test_type_def.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include diff --git a/test/test_type_lookup.cpp b/test/test_type_lookup.cpp index 8c2118fb..8d16bd3c 100644 --- a/test/test_type_lookup.cpp +++ b/test/test_type_lookup.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "etl/type_lookup.h" diff --git a/test/test_type_select.cpp b/test/test_type_select.cpp index 7e37aeee..6659d9e7 100644 --- a/test/test_type_select.cpp +++ b/test/test_type_select.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "etl/type_select.h" #include "etl/null_type.h" diff --git a/test/test_type_traits.cpp b/test/test_type_traits.cpp index 9fd73520..8230581f 100644 --- a/test/test_type_traits.cpp +++ b/test/test_type_traits.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/type_traits.h" #include diff --git a/test/test_unordered_map.cpp b/test/test_unordered_map.cpp index 8fc0701d..5d4edeab 100644 --- a/test/test_unordered_map.cpp +++ b/test/test_unordered_map.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include diff --git a/test/test_unordered_multimap.cpp b/test/test_unordered_multimap.cpp index efea060e..063cbaea 100644 --- a/test/test_unordered_multimap.cpp +++ b/test/test_unordered_multimap.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_unordered_multiset.cpp b/test/test_unordered_multiset.cpp index d60fe472..a8f80b86 100644 --- a/test/test_unordered_multiset.cpp +++ b/test/test_unordered_multiset.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_unordered_set.cpp b/test/test_unordered_set.cpp index cb6c7f19..e9d6393d 100644 --- a/test/test_unordered_set.cpp +++ b/test/test_unordered_set.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_user_type.cpp b/test/test_user_type.cpp index fed7bd63..12561373 100644 --- a/test/test_user_type.cpp +++ b/test/test_user_type.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include "etl/user_type.h" diff --git a/test/test_utility.cpp b/test/test_utility.cpp index e46e984a..bb9098c1 100644 --- a/test/test_utility.cpp +++ b/test/test_utility.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/utility.h" diff --git a/test/test_variant.cpp b/test/test_variant.cpp index 95b88901..1d6a40b2 100644 --- a/test/test_variant.cpp +++ b/test/test_variant.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "etl/variant.h" diff --git a/test/test_variant_pool.cpp b/test/test_variant_pool.cpp index 8634cca9..bc4c14c9 100644 --- a/test/test_variant_pool.cpp +++ b/test/test_variant_pool.cpp @@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" -#include "ExtraCheckMacros.h" +#include "unit_test_framework.h" #include "etl/variant_pool.h" diff --git a/test/test_vector.cpp b/test/test_vector.cpp index cdf37e98..64981d2a 100644 --- a/test/test_vector.cpp +++ b/test/test_vector.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_vector_external_buffer.cpp b/test/test_vector_external_buffer.cpp index 144a05b5..eb827c7d 100644 --- a/test/test_vector_external_buffer.cpp +++ b/test/test_vector_external_buffer.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_vector_non_trivial.cpp b/test/test_vector_non_trivial.cpp index 71bcc327..d7723df0 100644 --- a/test/test_vector_non_trivial.cpp +++ b/test/test_vector_non_trivial.cpp @@ -26,7 +26,7 @@ //SOFTWARE. //******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_vector_pointer.cpp b/test/test_vector_pointer.cpp index 5d9727dc..a6278329 100644 --- a/test/test_vector_pointer.cpp +++ b/test/test_vector_pointer.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_vector_pointer_external_buffer.cpp b/test/test_vector_pointer_external_buffer.cpp index 8deeff3a..6576e422 100644 --- a/test/test_vector_pointer_external_buffer.cpp +++ b/test/test_vector_pointer_external_buffer.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_visitor.cpp b/test/test_visitor.cpp index 1f4d9d45..491b01f9 100644 --- a/test/test_visitor.cpp +++ b/test/test_visitor.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include "etl/visitor.h" diff --git a/test/test_xor_checksum.cpp b/test/test_xor_checksum.cpp index ef4e4eb2..c060dffe 100644 --- a/test/test_xor_checksum.cpp +++ b/test/test_xor_checksum.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/test_xor_rotate_checksum.cpp b/test/test_xor_rotate_checksum.cpp index bbfc9936..f59ca67a 100644 --- a/test/test_xor_rotate_checksum.cpp +++ b/test/test_xor_rotate_checksum.cpp @@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "UnitTest++/UnitTest++.h" +#include "unit_test_framework.h" #include #include diff --git a/test/unit_test_framework.h b/test/unit_test_framework.h new file mode 100644 index 00000000..1e42f91a --- /dev/null +++ b/test/unit_test_framework.h @@ -0,0 +1,35 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 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. +******************************************************************************/ + +#ifndef ETL_UNIT_TEST_FRAMEWORK_INCLUDED +#define ETL_UNIT_TEST_FRAMEWORK_INCLUDED + +#include "UnitTest++/UnitTest++.h" +#include "ExtraCheckMacros.h" + +#endif \ No newline at end of file diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 12d35c56..b45b8b42 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -1495,6 +1495,7 @@ + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 084ce1d2..f17fb5d1 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -951,6 +951,9 @@ ETL\Frameworks + + Source Files + From 11d0005f1ba3ca8f0f21443c87910f74a4459fe6 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 5 Mar 2021 09:58:57 +0000 Subject: [PATCH 5/7] Initial commit --- include/etl/file_error_numbers.h | 1 + include/etl/message_router_registry.h | 145 +++-- test/test_message_router_registry.cpp | 753 +++----------------------- test/vs2019/etl.vcxproj | 1 + test/vs2019/etl.vcxproj.filters | 3 + 5 files changed, 185 insertions(+), 718 deletions(-) diff --git a/include/etl/file_error_numbers.h b/include/etl/file_error_numbers.h index 6ca6d4c3..a894f04b 100644 --- a/include/etl/file_error_numbers.h +++ b/include/etl/file_error_numbers.h @@ -90,5 +90,6 @@ SOFTWARE. #define ETL_MULTI_LOOP_ID "57" #define ETL_REFERENCE_COUNTER_MESSAGE_POOL_ID "58" #define ETL_QUEUE_SPSC_LOCKABLE "59" +#define ETL_MESSAGE_ROUTER_REGISTRY "60" #endif diff --git a/include/etl/message_router_registry.h b/include/etl/message_router_registry.h index 88480a47..b5c6bbe6 100644 --- a/include/etl/message_router_registry.h +++ b/include/etl/message_router_registry.h @@ -43,31 +43,31 @@ SOFTWARE. namespace etl { - ////*************************************************************************** - ///// Base exception class for message router - ////*************************************************************************** - //class message_router_registry_exception : public etl::exception - //{ - //public: + //*************************************************************************** + /// Base exception class for message router registry. + //*************************************************************************** + class message_router_registry_exception : public etl::exception + { + public: - // message_router_exception(string_type reason_, string_type file_name_, numeric_type line_number_) - // : etl::exception(reason_, file_name_, line_number_) - // { - // } - //}; + message_router_registry_exception(string_type reason_, string_type file_name_, numeric_type line_number_) + : etl::exception(reason_, file_name_, line_number_) + { + } + }; - ////*************************************************************************** - ///// Router id is out of the legal range. - ////*************************************************************************** - //class message_router_illegal_id : public etl::message_router_registry_exception - //{ - //public: + //*************************************************************************** + /// The registry is full. + //*************************************************************************** + class message_router_registry_full : public etl::message_router_registry_exception + { + public: - // message_router_illegal_id(string_type file_name_, numeric_type line_number_) - // : message_router_exception(ETL_ERROR_TEXT("message router:illegal id", ETL_FILE"A"), file_name_, line_number_) - // { - // } - //}; + message_router_registry_full(string_type file_name_, numeric_type line_number_) + : message_router_registry_exception(ETL_ERROR_TEXT("message router registry:full", ETL_FILE"A"), file_name_, line_number_) + { + } + }; //*************************************************************************** /// This is the base of all message router registries. @@ -76,6 +76,35 @@ namespace etl { public: + //******************************************** + /// Registers a router. + /// If the resgitry is full then an ETL assert is called. + //******************************************** + void register_message_router(etl::imessage_router& router) + { + if (!registry.full()) + { + typename IRegistry::value_type element(router.get_message_router_id(), &router); + + registry.insert(element); + } + else + { + ETL_ALWAYS_ASSERT(ETL_ERROR(etl::message_router_registry_full)); + } + } + + //******************************************** + /// Unregisters a router. + //******************************************** + void unregister_message_router(etl::message_router_id_t id) + { + registry.erase(id); + } + + //******************************************** + /// Get a pointer to a router that has the specified ID. + /// Returns ETL_NULLPTR if not found. //******************************************** etl::imessage_router* get_message_router(etl::message_router_id_t id) const { @@ -92,31 +121,75 @@ namespace etl } //******************************************** - bool contains(etl::message_router_id_t id) const + /// Returns true if the registry contains a router that has the specified ID. + /// Returns false if not found. + //******************************************** + bool contains(const etl::message_router_id_t id) const { return registry.find(id) != registry.end(); } //******************************************** - bool register_message_router(etl::imessage_router& router) + /// Returns true if the registry contains the router. + /// Returns false if not found. + //******************************************** + bool contains(const etl::imessage_router* const p_router) const { - if (!registry.full()) - { - typename IRegistry::value_type element(router.get_message_router_id(), &router); - - registry.insert(element); - return true; - } - else + if (p_router == ETL_NULLPTR) { return false; } + + return registry.find(p_router->get_message_router_id()) != registry.end(); } //******************************************** - void unregister_message_router(etl::message_router_id_t id) + /// Returns true if the registry contains the router. + /// Returns false if not found. + //******************************************** + bool contains(const etl::imessage_router& router) const { - registry.erase(id); + return registry.find(router.get_message_router_id()) != registry.end(); + } + + //******************************************** + /// Returns true if the registry is empty, otherwise false. + //******************************************** + bool empty() const + { + return registry.empty(); + } + + //******************************************** + /// Returns true if the registry is full, otherwise false. + //******************************************** + bool full() const + { + return registry.full(); + } + + //******************************************** + /// Returns the size of the registry. + //******************************************** + size_t size() const + { + return registry.size(); + } + + //******************************************** + /// Returns the available size of the registry. + //******************************************** + size_t available() const + { + return registry.available(); + } + + //******************************************** + /// Returns the maximum size of the registry. + //******************************************** + size_t max_size() const + { + return registry.max_size(); } protected: @@ -129,7 +202,7 @@ namespace etl { } - private: + private: IRegistry& registry; }; @@ -144,7 +217,7 @@ namespace etl //******************************************** message_router_registry() - : message_router_registry(registry) + : imessage_router_registry(registry) { } diff --git a/test/test_message_router_registry.cpp b/test/test_message_router_registry.cpp index e8967511..ae8dad30 100644 --- a/test/test_message_router_registry.cpp +++ b/test/test_message_router_registry.cpp @@ -29,6 +29,7 @@ SOFTWARE. #include "unit_test_framework.h" #include "etl/message_router.h" +#include "etl/message_router_registry.h" //*************************************************************************** // The set of messages. @@ -37,731 +38,119 @@ namespace { enum { - MESSAGE1, - MESSAGE2, - MESSAGE3, - MESSAGE4, - MESSAGE5 + ROUTER1 = 10, + ROUTER2 = 20, + ROUTER3 = 30, + ROUTER4 = 40 }; - enum - { - ROUTER1 = 1, - ROUTER2 = 2, - ROUTER3 = 3, - ROUTER4 = 4, - ROUTER5 = 5 - }; + constexpr size_t Registry_Size = 4U; - struct Message1 : public etl::message - { - Message1(etl::imessage_router& callback_) - : callback(callback_) - { - } - - etl::imessage_router& callback; - }; - - struct Message2 : public etl::message - { - Message2(etl::imessage_router& callback_) - : callback(callback_) - { - } - - etl::imessage_router& callback; - }; - - struct Message3 : public etl::message - { - Message3(etl::imessage_router& callback_) - : callback(callback_) - { - } - - etl::imessage_router& callback; - int value[10]; - }; - - struct Message4 : public etl::message - { - Message4(etl::imessage_router& callback_) - : callback(callback_) - { - } - - etl::imessage_router& callback; - }; - - struct Response : public etl::message + struct Message1 : public etl::message<1> { }; - Response response; - - int call_order; - //*************************************************************************** - // Router that handles messages 1, 2, 3, 4, 5. + // Router1 //*************************************************************************** - class RouterA : public etl::message_router + class Router1 : public etl::message_router { public: - RouterA(etl::message_router_id_t id) - : message_router(id), - message1_count(0), - message2_count(0), - message3_count(0), - message4_count(0), - message5_count(0), - message_unknown_count(0) + Router1() + : message_router(ROUTER1) { - } void on_receive(const Message1& msg) { - ++message1_count; - etl::send_message(msg.callback, response); - - order = call_order++; - } - - void on_receive(const Message2& msg) - { - ++message2_count; - etl::send_message(msg.callback, response); - } - - void on_receive(const Message3& msg) - { - ++message3_count; - etl::send_message(msg.callback, response); - } - - void on_receive(const Message4& msg) - { - ++message4_count; - etl::send_message(msg.callback, response); - } - - void on_receive(const Response&) - { - ++message5_count; } void on_receive_unknown(const etl::imessage&) { - ++message_unknown_count; } - - int message1_count; - int message2_count; - int message3_count; - int message4_count; - int message5_count; - int message_unknown_count; - int order; }; //*************************************************************************** - // Router that handles messages 1, 2, 4 and 5 and returns nothing. + // Router2 //*************************************************************************** - class RouterB : public etl::message_router + class Router2 : public etl::message_router { public: - RouterB(etl::message_router_id_t id) - : message_router(id), - message1_count(0), - message2_count(0), - message4_count(0), - message5_count(0), - message_unknown_count(0) + Router2() + : message_router(ROUTER2) { - } void on_receive(const Message1& msg) { - ++message1_count; - etl::send_message(msg.callback, response); } - void on_receive(const Message2& msg) + void on_receive_unknown(const etl::imessage&) { - ++message2_count; - etl::send_message(msg.callback, response); } - - void on_receive(const Message4& msg) - { - ++message4_count; - etl::send_message(msg.callback, response); - } - - void on_receive(const Response&) - { - ++message5_count; - } - - void on_receive_unknown(const etl::imessage& msg) - { - ++message_unknown_count; - //etl::send_message(msg.callback, response); - } - - int message1_count; - int message2_count; - int message4_count; - int message5_count; - int message_unknown_count; }; - SUITE(test_message_router) + //*************************************************************************** + // Router3 + //*************************************************************************** + class Router3 : public etl::message_router + { + public: + + Router3() + : message_router(ROUTER3) + { + } + + void on_receive(const Message1& msg) + { + } + + void on_receive_unknown(const etl::imessage&) + { + } + }; + + //*************************************************************************** + // Router4 + //*************************************************************************** + class Router4 : public etl::message_router + { + public: + + Router4() + : message_router(ROUTER4) + { + } + + void on_receive(const Message1& msg) + { + } + + void on_receive_unknown(const etl::imessage&) + { + } + }; + + Router1 router1; + Router2 router2; + Router3 router3; + Router4 router4; + + SUITE(test_message_router_registry) { //************************************************************************* - TEST(message_bus_subscribe_unsubscribe) + TEST(test_default_construction) { - etl::message_bus<2> bus1; + etl::message_router_registry registry; - RouterA router1(0); - RouterB router2(1); - RouterA router3(2); - - CHECK_EQUAL(0U, bus1.size()); - - CHECK_NO_THROW(bus1.subscribe(router1)); - CHECK_EQUAL(1U, bus1.size()); - - CHECK_NO_THROW(bus1.subscribe(router2)); - CHECK_EQUAL(2U, bus1.size()); - - CHECK_THROW(bus1.subscribe(router3), etl::message_bus_too_many_subscribers); - CHECK_EQUAL(2U, bus1.size()); - - bus1.unsubscribe(router1); - CHECK_EQUAL(1U, bus1.size()); - - // Erase router not in list. - bus1.unsubscribe(router3); - CHECK_EQUAL(1U, bus1.size()); - - // Erase using id. - bus1.unsubscribe(router2.get_message_router_id()); - CHECK_EQUAL(0U, bus1.size()); - - // Erase router from empty list. - bus1.unsubscribe(router2); - CHECK_EQUAL(0U, bus1.size()); - } - - //************************************************************************* - TEST(message_bus_subscribe_unsubscribe_sub_bus) - { - etl::message_bus<4> bus1; - etl::message_bus<2> bus2; - etl::message_bus<3> bus3; - - RouterA router1(ROUTER1); - RouterA router2(ROUTER2); - RouterA router3(ROUTER3); - RouterA router4(ROUTER4); - - bus1.subscribe(bus2); - bus1.subscribe(router1); - bus1.subscribe(bus3); - bus1.subscribe(router2); - - bus2.subscribe(router3); - bus3.subscribe(router4); - - CHECK_EQUAL(4U, bus1.size()); - - bus1.unsubscribe(etl::imessage_bus::MESSAGE_BUS); - CHECK_EQUAL(2U, bus1.size()); - - bus1.unsubscribe(etl::imessage_bus::ALL_MESSAGE_ROUTERS); - CHECK_EQUAL(0U, bus1.size()); - } - - //************************************************************************* - TEST(message_bus_broadcast) - { - etl::message_bus<2> bus1; - - RouterA router1(ROUTER1); - RouterB router2(ROUTER2); - RouterA callback(ROUTER3); - - bus1.subscribe(router1); - bus1.subscribe(router2); - - Message1 message1(callback); - Message2 message2(callback); - Message3 message3(callback); - Message4 message4(callback); - - bus1.receive(message1); - - CHECK_EQUAL(1, router1.message1_count); - CHECK_EQUAL(0, router1.message2_count); - CHECK_EQUAL(0, router1.message3_count); - CHECK_EQUAL(0, router1.message4_count); - CHECK_EQUAL(0, router1.message5_count); - CHECK_EQUAL(0, router1.message_unknown_count); - - CHECK_EQUAL(1, router2.message1_count); - CHECK_EQUAL(0, router2.message2_count); - CHECK_EQUAL(0, router2.message4_count); - CHECK_EQUAL(0, router2.message5_count); - CHECK_EQUAL(0, router2.message_unknown_count); - - CHECK_EQUAL(2, callback.message5_count); - - bus1.receive(message2); - - CHECK_EQUAL(1, router1.message1_count); - CHECK_EQUAL(1, router1.message2_count); - CHECK_EQUAL(0, router1.message3_count); - CHECK_EQUAL(0, router1.message4_count); - CHECK_EQUAL(0, router1.message5_count); - CHECK_EQUAL(0, router1.message_unknown_count); - - CHECK_EQUAL(1, router2.message1_count); - CHECK_EQUAL(1, router2.message2_count); - CHECK_EQUAL(0, router2.message4_count); - CHECK_EQUAL(0, router2.message5_count); - CHECK_EQUAL(0, router2.message_unknown_count); - - CHECK_EQUAL(4, callback.message5_count); - - bus1.receive(message3); - - CHECK_EQUAL(1, router1.message1_count); - CHECK_EQUAL(1, router1.message2_count); - CHECK_EQUAL(1, router1.message3_count); - CHECK_EQUAL(0, router1.message4_count); - CHECK_EQUAL(0, router1.message5_count); - CHECK_EQUAL(0, router1.message_unknown_count); - - CHECK_EQUAL(1, router2.message1_count); - CHECK_EQUAL(1, router2.message2_count); - CHECK_EQUAL(0, router2.message4_count); - CHECK_EQUAL(0, router2.message5_count); - CHECK_EQUAL(0, router2.message_unknown_count); - - CHECK_EQUAL(5, callback.message5_count); - - // Use global function. - etl::send_message(bus1, message4); - - CHECK_EQUAL(1, router1.message1_count); - CHECK_EQUAL(1, router1.message2_count); - CHECK_EQUAL(1, router1.message3_count); - CHECK_EQUAL(1, router1.message4_count); - CHECK_EQUAL(0, router1.message5_count); - CHECK_EQUAL(0, router1.message_unknown_count); - - CHECK_EQUAL(1, router2.message1_count); - CHECK_EQUAL(1, router2.message2_count); - CHECK_EQUAL(1, router2.message4_count); - CHECK_EQUAL(0, router2.message5_count); - CHECK_EQUAL(0, router2.message_unknown_count); - - CHECK_EQUAL(7, callback.message5_count); - } - - //************************************************************************* - TEST(message_bus_broadcast_as_router) - { - etl::message_bus<2> bus1; - - RouterA router1(ROUTER1); - RouterB router2(ROUTER2); - RouterA callback(ROUTER3); - - bus1.subscribe(router1); - bus1.subscribe(router2); - - Message1 message1(callback); - Message2 message2(callback); - Message3 message3(callback); - Message4 message4(callback); - - // Reference to router sub-type - etl::imessage_router& irouter = bus1; - - irouter.receive(message1); - - CHECK_EQUAL(1, router1.message1_count); - CHECK_EQUAL(0, router1.message2_count); - CHECK_EQUAL(0, router1.message3_count); - CHECK_EQUAL(0, router1.message4_count); - CHECK_EQUAL(0, router1.message5_count); - CHECK_EQUAL(0, router1.message_unknown_count); - - CHECK_EQUAL(1, router2.message1_count); - CHECK_EQUAL(0, router2.message2_count); - CHECK_EQUAL(0, router2.message4_count); - CHECK_EQUAL(0, router2.message5_count); - CHECK_EQUAL(0, router2.message_unknown_count); - - CHECK_EQUAL(2, callback.message5_count); - - irouter.receive(message2); - - CHECK_EQUAL(1, router1.message1_count); - CHECK_EQUAL(1, router1.message2_count); - CHECK_EQUAL(0, router1.message3_count); - CHECK_EQUAL(0, router1.message4_count); - CHECK_EQUAL(0, router1.message5_count); - CHECK_EQUAL(0, router1.message_unknown_count); - - CHECK_EQUAL(1, router2.message1_count); - CHECK_EQUAL(1, router2.message2_count); - CHECK_EQUAL(0, router2.message4_count); - CHECK_EQUAL(0, router2.message5_count); - CHECK_EQUAL(0, router2.message_unknown_count); - - CHECK_EQUAL(4, callback.message5_count); - - irouter.receive(message3); - - CHECK_EQUAL(1, router1.message1_count); - CHECK_EQUAL(1, router1.message2_count); - CHECK_EQUAL(1, router1.message3_count); - CHECK_EQUAL(0, router1.message4_count); - CHECK_EQUAL(0, router1.message5_count); - CHECK_EQUAL(0, router1.message_unknown_count); - - CHECK_EQUAL(1, router2.message1_count); - CHECK_EQUAL(1, router2.message2_count); - CHECK_EQUAL(0, router2.message4_count); - CHECK_EQUAL(0, router2.message5_count); - CHECK_EQUAL(0, router2.message_unknown_count); - - CHECK_EQUAL(5, callback.message5_count); - - // Use global function. - etl::send_message(irouter, message4); - - CHECK_EQUAL(1, router1.message1_count); - CHECK_EQUAL(1, router1.message2_count); - CHECK_EQUAL(1, router1.message3_count); - CHECK_EQUAL(1, router1.message4_count); - CHECK_EQUAL(0, router1.message5_count); - CHECK_EQUAL(0, router1.message_unknown_count); - - CHECK_EQUAL(1, router2.message1_count); - CHECK_EQUAL(1, router2.message2_count); - CHECK_EQUAL(1, router2.message4_count); - CHECK_EQUAL(0, router2.message5_count); - CHECK_EQUAL(0, router2.message_unknown_count); - - CHECK_EQUAL(7, callback.message5_count); - } - - //************************************************************************* - TEST(message_bus_addressed) - { - etl::message_bus<2> bus1; - - RouterA router1(ROUTER1); - RouterB router2(ROUTER2); - RouterA callback(ROUTER3); - - bus1.subscribe(router1); - bus1.subscribe(router2); - - Message1 message1(callback); - Message2 message2(callback); - Message3 message3(callback); - Message4 message4(callback); - - bus1.receive(ROUTER1, message1); - - CHECK_EQUAL(1, router1.message1_count); - CHECK_EQUAL(0, router1.message2_count); - CHECK_EQUAL(0, router1.message3_count); - CHECK_EQUAL(0, router1.message4_count); - CHECK_EQUAL(0, router1.message5_count); - CHECK_EQUAL(0, router1.message_unknown_count); - - CHECK_EQUAL(0, router2.message1_count); - CHECK_EQUAL(0, router2.message2_count); - CHECK_EQUAL(0, router2.message4_count); - CHECK_EQUAL(0, router2.message5_count); - CHECK_EQUAL(0, router2.message_unknown_count); - - CHECK_EQUAL(1, callback.message5_count); - - bus1.receive(ROUTER2, message2); - - CHECK_EQUAL(1, router1.message1_count); - CHECK_EQUAL(0, router1.message2_count); - CHECK_EQUAL(0, router1.message3_count); - CHECK_EQUAL(0, router1.message4_count); - CHECK_EQUAL(0, router1.message5_count); - CHECK_EQUAL(0, router1.message_unknown_count); - - CHECK_EQUAL(0, router2.message1_count); - CHECK_EQUAL(1, router2.message2_count); - CHECK_EQUAL(0, router2.message4_count); - CHECK_EQUAL(0, router2.message5_count); - CHECK_EQUAL(0, router2.message_unknown_count); - - CHECK_EQUAL(2, callback.message5_count); - - bus1.receive(ROUTER1, message3); - - CHECK_EQUAL(1, router1.message1_count); - CHECK_EQUAL(0, router1.message2_count); - CHECK_EQUAL(1, router1.message3_count); - CHECK_EQUAL(0, router1.message4_count); - CHECK_EQUAL(0, router1.message5_count); - CHECK_EQUAL(0, router1.message_unknown_count); - - CHECK_EQUAL(0, router2.message1_count); - CHECK_EQUAL(1, router2.message2_count); - CHECK_EQUAL(0, router2.message4_count); - CHECK_EQUAL(0, router2.message5_count); - CHECK_EQUAL(0, router2.message_unknown_count); - - CHECK_EQUAL(3, callback.message5_count); - - // Use global function. - etl::send_message(bus1, ROUTER2, message4); - - CHECK_EQUAL(1, router1.message1_count); - CHECK_EQUAL(0, router1.message2_count); - CHECK_EQUAL(1, router1.message3_count); - CHECK_EQUAL(0, router1.message4_count); - CHECK_EQUAL(0, router1.message5_count); - CHECK_EQUAL(0, router1.message_unknown_count); - - CHECK_EQUAL(0, router2.message1_count); - CHECK_EQUAL(1, router2.message2_count); - CHECK_EQUAL(1, router2.message4_count); - CHECK_EQUAL(0, router2.message5_count); - CHECK_EQUAL(0, router2.message_unknown_count); - - CHECK_EQUAL(4, callback.message5_count); - - // Send to a router not subscribed to the bus. - bus1.receive(ROUTER5, message1); - - CHECK_EQUAL(1, router1.message1_count); - CHECK_EQUAL(0, router1.message2_count); - CHECK_EQUAL(1, router1.message3_count); - CHECK_EQUAL(0, router1.message4_count); - CHECK_EQUAL(0, router1.message5_count); - CHECK_EQUAL(0, router1.message_unknown_count); - - CHECK_EQUAL(0, router2.message1_count); - CHECK_EQUAL(1, router2.message2_count); - CHECK_EQUAL(1, router2.message4_count); - CHECK_EQUAL(0, router2.message5_count); - CHECK_EQUAL(0, router2.message_unknown_count); - - CHECK_EQUAL(4, callback.message5_count); - } - - //************************************************************************* - TEST(message_bus_addressed_duplicate_router_id) - { - etl::message_bus<3> bus1; - - RouterA router1(ROUTER1); - RouterB router2(ROUTER1); - RouterB router3(ROUTER2); - RouterA callback(ROUTER3); - - bus1.subscribe(router1); - bus1.subscribe(router2); - bus1.subscribe(router3); - - Message1 message1(callback); - Message2 message2(callback); - Message3 message3(callback); - - bus1.receive(ROUTER1, message1); - - CHECK_EQUAL(1, router1.message1_count); - CHECK_EQUAL(0, router1.message2_count); - CHECK_EQUAL(0, router1.message3_count); - CHECK_EQUAL(0, router1.message4_count); - CHECK_EQUAL(0, router1.message5_count); - CHECK_EQUAL(0, router1.message_unknown_count); - - CHECK_EQUAL(1, router2.message1_count); - CHECK_EQUAL(0, router2.message2_count); - CHECK_EQUAL(0, router2.message4_count); - CHECK_EQUAL(0, router2.message5_count); - CHECK_EQUAL(0, router2.message_unknown_count); - - CHECK_EQUAL(0, router3.message1_count); - CHECK_EQUAL(0, router3.message2_count); - CHECK_EQUAL(0, router3.message4_count); - CHECK_EQUAL(0, router3.message5_count); - CHECK_EQUAL(0, router3.message_unknown_count); - - CHECK_EQUAL(2, callback.message5_count); - } - - //************************************************************************* - TEST(message_bus_broadcast_addressed_sub_bus) - { - etl::message_bus<3> bus1; - etl::message_bus<2> bus2; - - RouterA router1(ROUTER1); - RouterA router2(ROUTER2); - RouterA router3(ROUTER3); - RouterA router4(ROUTER4); - - RouterA callback(ROUTER5); - - bus1.subscribe(router1); - bus1.subscribe(router2); - bus1.subscribe(bus2); - - bus2.subscribe(router3); - bus2.subscribe(router4); - - Message1 message1(callback); - Message2 message2(callback); - Message3 message3(callback); - Message4 message4(callback); - - // Broadcast to bus1 - bus1.receive(message1); - - CHECK_EQUAL(1, router1.message1_count); - CHECK_EQUAL(0, router1.message2_count); - CHECK_EQUAL(0, router1.message3_count); - CHECK_EQUAL(0, router1.message4_count); - CHECK_EQUAL(0, router1.message5_count); - CHECK_EQUAL(0, router1.message_unknown_count); - - CHECK_EQUAL(1, router2.message1_count); - CHECK_EQUAL(0, router2.message2_count); - CHECK_EQUAL(0, router2.message4_count); - CHECK_EQUAL(0, router2.message5_count); - CHECK_EQUAL(0, router2.message_unknown_count); - - CHECK_EQUAL(1, router3.message1_count); - CHECK_EQUAL(0, router3.message2_count); - CHECK_EQUAL(0, router3.message4_count); - CHECK_EQUAL(0, router3.message5_count); - CHECK_EQUAL(0, router3.message_unknown_count); - - CHECK_EQUAL(1, router4.message1_count); - CHECK_EQUAL(0, router4.message2_count); - CHECK_EQUAL(0, router4.message4_count); - CHECK_EQUAL(0, router4.message5_count); - CHECK_EQUAL(0, router4.message_unknown_count); - - CHECK_EQUAL(4, callback.message5_count); - - // Addressed to ROUTER2 - bus1.receive(ROUTER2, message1); - - CHECK_EQUAL(1, router1.message1_count); - CHECK_EQUAL(0, router1.message2_count); - CHECK_EQUAL(0, router1.message3_count); - CHECK_EQUAL(0, router1.message4_count); - CHECK_EQUAL(0, router1.message5_count); - CHECK_EQUAL(0, router1.message_unknown_count); - - CHECK_EQUAL(2, router2.message1_count); - CHECK_EQUAL(0, router2.message2_count); - CHECK_EQUAL(0, router2.message4_count); - CHECK_EQUAL(0, router2.message5_count); - CHECK_EQUAL(0, router2.message_unknown_count); - - CHECK_EQUAL(1, router3.message1_count); - CHECK_EQUAL(0, router3.message2_count); - CHECK_EQUAL(0, router3.message4_count); - CHECK_EQUAL(0, router3.message5_count); - CHECK_EQUAL(0, router3.message_unknown_count); - - CHECK_EQUAL(1, router4.message1_count); - CHECK_EQUAL(0, router4.message2_count); - CHECK_EQUAL(0, router4.message4_count); - CHECK_EQUAL(0, router4.message5_count); - CHECK_EQUAL(0, router4.message_unknown_count); - - CHECK_EQUAL(5, callback.message5_count); - - // Addressed to ROUTER3 via bus2 - bus1.receive(ROUTER3, message1); - - CHECK_EQUAL(1, router1.message1_count); - CHECK_EQUAL(0, router1.message2_count); - CHECK_EQUAL(0, router1.message3_count); - CHECK_EQUAL(0, router1.message4_count); - CHECK_EQUAL(0, router1.message5_count); - CHECK_EQUAL(0, router1.message_unknown_count); - - CHECK_EQUAL(2, router2.message1_count); - CHECK_EQUAL(0, router2.message2_count); - CHECK_EQUAL(0, router2.message4_count); - CHECK_EQUAL(0, router2.message5_count); - CHECK_EQUAL(0, router2.message_unknown_count); - - CHECK_EQUAL(2, router3.message1_count); - CHECK_EQUAL(0, router3.message2_count); - CHECK_EQUAL(0, router3.message4_count); - CHECK_EQUAL(0, router3.message5_count); - CHECK_EQUAL(0, router3.message_unknown_count); - - CHECK_EQUAL(1, router4.message1_count); - CHECK_EQUAL(0, router4.message2_count); - CHECK_EQUAL(0, router4.message4_count); - CHECK_EQUAL(0, router4.message5_count); - CHECK_EQUAL(0, router4.message_unknown_count); - - CHECK_EQUAL(6, callback.message5_count); - } - - //************************************************************************* - TEST(message_bus_broadcast_order) - { - etl::message_bus<4> bus1; - etl::message_bus<2> bus2; - etl::message_bus<2> bus3; - - RouterA router1(ROUTER1); - RouterA router2(ROUTER2); - RouterA router3(ROUTER3); - RouterA router4a(ROUTER4); - RouterA router4b(ROUTER4); - - RouterA callback(ROUTER5); - - bus1.subscribe(router1); - bus1.subscribe(bus3); - bus1.subscribe(bus2); - bus1.subscribe(router2); - - bus2.subscribe(router3); - bus3.subscribe(router4b); - bus3.subscribe(router4a); - - Message1 message1(callback); - - call_order = 0; - - bus1.receive(message1); - - CHECK_EQUAL(0, router1.order); - CHECK_EQUAL(1, router2.order); - CHECK_EQUAL(2, router4b.order); - CHECK_EQUAL(3, router4a.order); - CHECK_EQUAL(4, router3.order); + CHECK(registry.empty()); + CHECK(!registry.full()); + CHECK_EQUAL(0U, registry.size()); + CHECK_EQUAL(Registry_Size, registry.available()); + CHECK_EQUAL(Registry_Size, registry.max_size()); } }; } diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index b45b8b42..1a39b444 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -1544,6 +1544,7 @@ + ../../../unittest-cpp diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index f17fb5d1..9e7dcceb 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1508,6 +1508,9 @@ Source Files + + Source Files + From 563fc0718668b7901f22497e3486ffc6d2a4c07e Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 5 Mar 2021 20:19:18 +0000 Subject: [PATCH 6/7] Added message_router_registry --- include/etl/message_router_registry.h | 63 ++++++++++++- test/test_message_router_registry.cpp | 129 +++++++++++++++++++++++++- 2 files changed, 187 insertions(+), 5 deletions(-) diff --git a/include/etl/message_router_registry.h b/include/etl/message_router_registry.h index b5c6bbe6..44e9b192 100644 --- a/include/etl/message_router_registry.h +++ b/include/etl/message_router_registry.h @@ -78,9 +78,9 @@ namespace etl //******************************************** /// Registers a router. - /// If the resgitry is full then an ETL assert is called. + /// If the registry is full then an ETL assert is called. //******************************************** - void register_message_router(etl::imessage_router& router) + void add(etl::imessage_router& router) { if (!registry.full()) { @@ -94,10 +94,35 @@ namespace etl } } + //******************************************** + /// Registers a router. + /// If the registry is full then an ETL assert is called. + //******************************************** + void add(etl::imessage_router* p_router) + { + if (p_router != ETL_NULLPTR) + { + add(*p_router); + } + } + + //******************************************** + /// Registers a list of routers. + /// If the registry is full then an ETL assert is called. + //******************************************** + template + void add(TIterator first, const TIterator& last) + { + while (first != last) + { + this->add(*first++); + } + } + //******************************************** /// Unregisters a router. //******************************************** - void unregister_message_router(etl::message_router_id_t id) + void remove(etl::message_router_id_t id) { registry.erase(id); } @@ -215,12 +240,44 @@ namespace etl { public: + //******************************************** + // Default constructor. //******************************************** message_router_registry() : imessage_router_registry(registry) { } + //************************************************************************* + /// Constructor. + /// Constructs from an iterator range. + //************************************************************************* + template + message_router_registry(TIterator first, const TIterator& last) + : imessage_router_registry(registry) + { + while (first != last) + { + this->add(*first++); + } + } + +#if ETL_CPP11_SUPPORTED && ETL_USING_STL + //******************************************** + // Initializer_list constructor. + //******************************************** + message_router_registry(std::initializer_list init) + : imessage_router_registry(registry) + { + std::initializer_list::const_iterator itr = init.begin(); + + while (itr != init.end()) + { + this->add(*itr++); + } + } +#endif + private: typedef etl::flat_map Registry; diff --git a/test/test_message_router_registry.cpp b/test/test_message_router_registry.cpp index ae8dad30..046ee900 100644 --- a/test/test_message_router_registry.cpp +++ b/test/test_message_router_registry.cpp @@ -30,6 +30,7 @@ SOFTWARE. #include "etl/message_router.h" #include "etl/message_router_registry.h" +#include "etl/array.h" //*************************************************************************** // The set of messages. @@ -41,7 +42,8 @@ namespace ROUTER1 = 10, ROUTER2 = 20, ROUTER3 = 30, - ROUTER4 = 40 + ROUTER4 = 40, + ROUTER5 = 50 }; constexpr size_t Registry_Size = 4U; @@ -134,10 +136,32 @@ namespace } }; + //*************************************************************************** + // Router5 + //*************************************************************************** + class Router5 : public etl::message_router + { + public: + + Router5() + : message_router(ROUTER5) + { + } + + void on_receive(const Message1& msg) + { + } + + void on_receive_unknown(const etl::imessage&) + { + } + }; + Router1 router1; Router2 router2; Router3 router3; Router4 router4; + Router5 router5; SUITE(test_message_router_registry) { @@ -148,9 +172,110 @@ namespace CHECK(registry.empty()); CHECK(!registry.full()); - CHECK_EQUAL(0U, registry.size()); + CHECK_EQUAL(0U, registry.size()); CHECK_EQUAL(Registry_Size, registry.available()); CHECK_EQUAL(Registry_Size, registry.max_size()); } + + //************************************************************************* + TEST(test_iterator_construction) + { + etl::array routers{ &router1, &router2, &router3, &router4 }; + + etl::message_router_registry registry(routers.begin(), routers.end()); + + CHECK(!registry.empty()); + CHECK(registry.full()); + CHECK_EQUAL(Registry_Size, registry.size()); + CHECK_EQUAL(0U, registry.available()); + CHECK_EQUAL(Registry_Size, registry.max_size()); + } + + //************************************************************************* + TEST(test_iterator_construction_excess) + { + etl::array routers{ &router1, &router2, &router3, &router4, &router5 }; + + etl::message_router_registry registry; + + CHECK_THROW((registry.add(routers.begin(), routers.end())), etl::message_router_registry_full); + + CHECK(!registry.empty()); + CHECK(registry.full()); + CHECK_EQUAL(Registry_Size, registry.size()); + CHECK_EQUAL(0U, registry.available()); + CHECK_EQUAL(Registry_Size, registry.max_size()); + } + + //************************************************************************* + TEST(test_initializer_list_construction) + { + etl::message_router_registry registry = { &router1, &router2, &router3, &router4 }; + + CHECK(!registry.empty()); + CHECK(registry.full()); + CHECK_EQUAL(Registry_Size, registry.size()); + CHECK_EQUAL(0U, registry.available()); + CHECK_EQUAL(Registry_Size, registry.max_size()); + } + + //************************************************************************* + TEST(test_initializer_list_construction_part_full) + { + etl::message_router_registry registry = { &router1, &router2, &router3 }; + + CHECK(!registry.empty()); + CHECK(!registry.full()); + CHECK_EQUAL(Registry_Size - 1U, registry.size()); + CHECK_EQUAL(1U, registry.available()); + CHECK_EQUAL(Registry_Size, registry.max_size()); + } + + //************************************************************************* + TEST(test_registery_contains) + { + etl::message_router_registry registry = { &router1, &router2, &router3 }; + + CHECK(registry.contains(ROUTER1)); + CHECK(registry.contains(ROUTER2)); + CHECK(registry.contains(ROUTER3)); + CHECK(!registry.contains(ROUTER4)); + + CHECK(registry.contains(router1)); + CHECK(registry.contains(router2)); + CHECK(registry.contains(router3)); + CHECK(!registry.contains(router4)); + + CHECK(registry.contains(&router1)); + CHECK(registry.contains(&router2)); + CHECK(registry.contains(&router3)); + CHECK(!registry.contains(&router4)); + } + + //************************************************************************* + TEST(test_get_message_router) + { + etl::message_router_registry registry = { &router1, &router2, &router3 }; + + CHECK_EQUAL(&router1, registry.get_message_router(ROUTER1)); + CHECK_EQUAL(&router2, registry.get_message_router(ROUTER2)); + CHECK_EQUAL(&router3, registry.get_message_router(ROUTER3)); + CHECK_EQUAL(nullptr, registry.get_message_router(ROUTER4)); + } + + //************************************************************************* + TEST(test_unregister_message_router) + { + etl::message_router_registry registry = { &router1, &router2, &router3, &router4 }; + + registry.remove(ROUTER3); + + CHECK(!registry.contains(router3)); + + CHECK_EQUAL(&router1, registry.get_message_router(ROUTER1)); + CHECK_EQUAL(&router2, registry.get_message_router(ROUTER2)); + CHECK_EQUAL(nullptr, registry.get_message_router(ROUTER3)); + CHECK_EQUAL(&router4, registry.get_message_router(ROUTER4)); + } }; } From 03f6299d631ef9e40f08ee8d10fa87a27d13cf31 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 5 Mar 2021 20:34:14 +0000 Subject: [PATCH 7/7] Added message_router_registry --- include/etl/message_router_registry.h | 29 +++++++++++++++--- test/test_message_router_registry.cpp | 44 ++++++++++++++++++++++----- 2 files changed, 61 insertions(+), 12 deletions(-) diff --git a/include/etl/message_router_registry.h b/include/etl/message_router_registry.h index 44e9b192..455e4916 100644 --- a/include/etl/message_router_registry.h +++ b/include/etl/message_router_registry.h @@ -115,7 +115,7 @@ namespace etl { while (first != last) { - this->add(*first++); + add(*first++); } } @@ -131,7 +131,7 @@ namespace etl /// Get a pointer to a router that has the specified ID. /// Returns ETL_NULLPTR if not found. //******************************************** - etl::imessage_router* get_message_router(etl::message_router_id_t id) const + etl::imessage_router* get(etl::message_router_id_t id) const { IRegistry::const_iterator itr = registry.find(id); @@ -221,6 +221,8 @@ namespace etl typedef etl::iflat_map IRegistry; + //******************************************** + // Constructor. //******************************************** imessage_router_registry(IRegistry& registry_) : registry(registry_) @@ -248,10 +250,10 @@ namespace etl { } - //************************************************************************* + //******************************************** /// Constructor. /// Constructs from an iterator range. - //************************************************************************* + //******************************************** template message_router_registry(TIterator first, const TIterator& last) : imessage_router_registry(registry) @@ -278,6 +280,25 @@ namespace etl } #endif + //******************************************** + // Copy constructor. + //******************************************** + message_router_registry(const message_router_registry& rhs) + : imessage_router_registry(registry) + { + registry = rhs.registry; + } + + //******************************************** + // Assignment operator. + //******************************************** + message_router_registry& operator =(const message_router_registry& rhs) + { + registry = rhs.registry; + + return *this; + } + private: typedef etl::flat_map Registry; diff --git a/test/test_message_router_registry.cpp b/test/test_message_router_registry.cpp index 046ee900..5ffef069 100644 --- a/test/test_message_router_registry.cpp +++ b/test/test_message_router_registry.cpp @@ -231,6 +231,34 @@ namespace CHECK_EQUAL(Registry_Size, registry.max_size()); } + //************************************************************************* + TEST(test_copy_construction) + { + etl::message_router_registry registry = { &router1, &router2, &router3, &router4 }; + etl::message_router_registry registry2(registry); + + CHECK(!registry2.empty()); + CHECK(registry2.full()); + CHECK_EQUAL(Registry_Size, registry2.size()); + CHECK_EQUAL(0U, registry2.available()); + CHECK_EQUAL(Registry_Size, registry2.max_size()); + } + + //************************************************************************* + TEST(test_assignment) + { + etl::message_router_registry registry = { &router1, &router2, &router3, &router4 }; + etl::message_router_registry registry2; + + registry2 = registry; + + CHECK(!registry2.empty()); + CHECK(registry2.full()); + CHECK_EQUAL(Registry_Size, registry2.size()); + CHECK_EQUAL(0U, registry2.available()); + CHECK_EQUAL(Registry_Size, registry2.max_size()); + } + //************************************************************************* TEST(test_registery_contains) { @@ -257,10 +285,10 @@ namespace { etl::message_router_registry registry = { &router1, &router2, &router3 }; - CHECK_EQUAL(&router1, registry.get_message_router(ROUTER1)); - CHECK_EQUAL(&router2, registry.get_message_router(ROUTER2)); - CHECK_EQUAL(&router3, registry.get_message_router(ROUTER3)); - CHECK_EQUAL(nullptr, registry.get_message_router(ROUTER4)); + CHECK_EQUAL(&router1, registry.get(ROUTER1)); + CHECK_EQUAL(&router2, registry.get(ROUTER2)); + CHECK_EQUAL(&router3, registry.get(ROUTER3)); + CHECK_EQUAL(nullptr, registry.get(ROUTER4)); } //************************************************************************* @@ -272,10 +300,10 @@ namespace CHECK(!registry.contains(router3)); - CHECK_EQUAL(&router1, registry.get_message_router(ROUTER1)); - CHECK_EQUAL(&router2, registry.get_message_router(ROUTER2)); - CHECK_EQUAL(nullptr, registry.get_message_router(ROUTER3)); - CHECK_EQUAL(&router4, registry.get_message_router(ROUTER4)); + CHECK_EQUAL(&router1, registry.get(ROUTER1)); + CHECK_EQUAL(&router2, registry.get(ROUTER2)); + CHECK_EQUAL(nullptr, registry.get(ROUTER3)); + CHECK_EQUAL(&router4, registry.get(ROUTER4)); } }; }