From 80848377db0910833a2732c5dfb1701073136699 Mon Sep 17 00:00:00 2001 From: Sebastian Michel Date: Mon, 4 Mar 2024 20:52:42 +0100 Subject: [PATCH] Adapted policies_logging tests to correctly handle statemachine start Re-enabled policies_logging tests --- test/ft/CMakeLists.txt | 4 ++-- test/ft/policies_logging.cpp | 26 +++++++++++++++++--------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/test/ft/CMakeLists.txt b/test/ft/CMakeLists.txt index 88aeb197..267a0c89 100644 --- a/test/ft/CMakeLists.txt +++ b/test/ft/CMakeLists.txt @@ -54,8 +54,8 @@ add_test(test_guards test_guards) add_executable(test_orthogonal_regions orthogonal_regions.cpp) add_test(test_orthogonal_regions test_orthogonal_regions) -# add_executable(test_policies_logging policies_logging.cpp) -# add_test(test_policies_logging test_policies_logging) +add_executable(test_policies_logging policies_logging.cpp) +add_test(test_policies_logging test_policies_logging) add_executable(test_policies_testing policies_testing.cpp) add_test(test_policies_testing test_policies_testing) diff --git a/test/ft/policies_logging.cpp b/test/ft/policies_logging.cpp index 5dc8760d..30995c31 100644 --- a/test/ft/policies_logging.cpp +++ b/test/ft/policies_logging.cpp @@ -21,7 +21,8 @@ struct my_logger { void log_process_event(const TEvent& evt) { std::stringstream sstr; sstr << "[" << sml::aux::get_type_name() << "] " << evt.c_str(); - messages_out.push_back(sstr.str()); + const auto str = sstr.str(); + messages_out.push_back(str); } template @@ -29,15 +30,16 @@ struct my_logger { std::stringstream sstr; sstr << "[" << sml::aux::get_type_name() << "] " << sml::aux::get_type_name() << "[" << sml::aux::get_type_name() << "]: " << std::boolalpha << result; - messages_out.push_back(sstr.str()); + const auto str = sstr.str(); + messages_out.push_back(str); } template void log_action(const TAction&, const TEvent&) { std::stringstream sstr; - sstr << "[" << sml::aux::get_type_name() << "] " - << "/ " << sml::aux::get_type_name(); - messages_out.push_back(sstr.str()); + sstr << "[" << sml::aux::get_type_name() << "] " << "/ " << sml::aux::get_type_name(); + const auto str = sstr.str(); + messages_out.push_back(str); } template @@ -48,7 +50,8 @@ struct my_logger { std::string dst_state = dst.c_str(); remove_spaces(dst_state); sstr << "[" << sml::aux::get_type_name() << "] " << src_state << " -> " << dst_state; - messages_out.push_back(sstr.str()); + const auto str = sstr.str(); + messages_out.push_back(str); } std::vector messages_out; @@ -90,7 +93,8 @@ struct c_log_sm { test log_sm = [] { // clang-format off std::vector messages_expected = { - "[c_log_sm] e1" + "[c_log_sm] on_entry" + , "[c_log_sm] e1" , "[c_log_sm] idle -> s1_label" , "[c_log_sm] e2" , "[c_log_sm] s1_label -> terminate" @@ -179,7 +183,9 @@ struct c_log_sub_sm { test log_sub_sm = [] { // clang-format off std::vector messages_expected = { - "[c_log_sub_sm] e1" + "[c_log_sub_sm] on_entry" + , "[sub] on_entry" + , "[c_log_sub_sm] e1" , "[c_log_sub_sm] sub(a) -> sub(b)" , "[c_log_sub_sm] e2" , "[sub] e2" @@ -217,7 +223,9 @@ struct c_log_sub_sm_mix { test log_sub_sm_mix = [] { // clang-format off std::vector messages_expected = { - "[c_log_sub_sm_mix] e1" + "[c_log_sub_sm_mix] on_entry" + , "[sub] on_entry" + , "[c_log_sub_sm_mix] e1" , "[c_log_sub_sm_mix] sub(a) -> sub" , "[c_log_sub_sm_mix] e2" , "[sub] e2"