From e59f995289f1064cb93c6d18596fbbad2d516fb0 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 11 Apr 2022 12:35:47 +0200 Subject: [PATCH] #531 Fixed: Compilation of etl::reference_counted_message_pool with ETL_LOG_ERROR enabled due to non-public inheritance. --- test/test_shared_message.cpp | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/test/test_shared_message.cpp b/test/test_shared_message.cpp index 7e2569ea..b0fac5ea 100644 --- a/test/test_shared_message.cpp +++ b/test/test_shared_message.cpp @@ -249,5 +249,43 @@ namespace CHECK_EQUAL(0, router2.count_message2); CHECK_EQUAL(0, router2.count_unknown_message); } + + TEST(test_reference_counted_pool_exceptions) + { + using pool_message_parameters = etl::atomic_counted_message_pool::pool_message_parameters; + + etl::fixed_sized_memory_block_allocator memory_allocator; + + etl::atomic_counted_message_pool message_pool(memory_allocator); + + etl::reference_counted_message* prcm; + CHECK_NO_THROW(prcm = message_pool.allocate(1)); + CHECK_NO_THROW(prcm = message_pool.allocate(2)); + CHECK_NO_THROW(prcm = message_pool.allocate(3)); + CHECK_NO_THROW(prcm = message_pool.allocate(4)); + + try + { + prcm = message_pool.allocate(5); + } + catch (etl::exception e) + { + CHECK_EQUAL(std::string("reference_counted_message_pool:allocation failure"), std::string(e.what())); + } + + Message1 message1(6); + etl::reference_counted_message temp(message1, message_pool); + + try + { + message_pool.release(temp); + } + catch (etl::exception e) + { + CHECK_EQUAL(std::string("reference_counted_message_pool:release failure"), std::string(e.what())); + } + } } }