From de6e6ab13cdf3abc86b94eae2647f5a12ff2a98d Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 24 Feb 2024 10:46:24 +0000 Subject: [PATCH] Added tests for message base_type --- include/etl/message.h | 4 ++-- test/test_message.cpp | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/etl/message.h b/include/etl/message.h index efd87210b..6d3bb4c4c 100644 --- a/include/etl/message.h +++ b/include/etl/message.h @@ -209,7 +209,7 @@ namespace etl }; //*************************************************************************** - /// Is T derived from etl::message<> + /// Is T an etl::message<> or derived from etl::message<> //*************************************************************************** template struct is_message_type : public etl::bool_constant::type>::value> @@ -225,7 +225,7 @@ namespace etl }; //*************************************************************************** - /// Is T a user defined base of etl::message + /// Is T a user defined base of etl::message and not an etl::imessage //*************************************************************************** template struct is_user_message_base : public etl::bool_constant::value && !is_imessage::value> diff --git a/test/test_message.cpp b/test/test_message.cpp index 8ce9afa86..14d40418f 100644 --- a/test/test_message.cpp +++ b/test/test_message.cpp @@ -114,4 +114,19 @@ SUITE(test_message) CHECK_FALSE(etl::is_user_message_base::value); #endif } + + //************************************************************************* + TEST(test_message_base_type) + { + struct Message1 : public etl::message<1> {}; + + struct MessageBase : public etl::imessage {}; + struct Message2 : public etl::message<2, MessageBase> {}; + + CHECK_TRUE((std::is_same_v)); + CHECK_TRUE((std::is_same_v)); + + CHECK_FALSE((std::is_same_v)); + CHECK_FALSE((std::is_same_v)); + } };