Skip to content

Commit

Permalink
Adapted policies_logging tests to correctly handle statemachine start
Browse files Browse the repository at this point in the history
Re-enabled policies_logging tests
  • Loading branch information
devzeb authored and kris-jusiak committed Mar 4, 2024
1 parent b885766 commit 78e0640
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions test/ft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 17 additions & 9 deletions test/ft/policies_logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,25 @@ struct my_logger {
void log_process_event(const TEvent& evt) {
std::stringstream sstr;
sstr << "[" << sml::aux::get_type_name<SM>() << "] " << evt.c_str();
messages_out.push_back(sstr.str());
const auto str = sstr.str();
messages_out.push_back(str);
}

template <class SM, class TGuard, class TEvent>
void log_guard(const TGuard&, const TEvent&, bool result) {
std::stringstream sstr;
sstr << "[" << sml::aux::get_type_name<SM>() << "] " << sml::aux::get_type_name<TEvent>() << "["
<< sml::aux::get_type_name<TGuard>() << "]: " << std::boolalpha << result;
messages_out.push_back(sstr.str());
const auto str = sstr.str();
messages_out.push_back(str);
}

template <class SM, class TAction, class TEvent>
void log_action(const TAction&, const TEvent&) {
std::stringstream sstr;
sstr << "[" << sml::aux::get_type_name<SM>() << "] "
<< "/ " << sml::aux::get_type_name<TAction>();
messages_out.push_back(sstr.str());
sstr << "[" << sml::aux::get_type_name<SM>() << "] " << "/ " << sml::aux::get_type_name<TAction>();
const auto str = sstr.str();
messages_out.push_back(str);
}

template <class SM, class TSrcState, class TDstState>
Expand All @@ -48,7 +50,8 @@ struct my_logger {
std::string dst_state = dst.c_str();
remove_spaces(dst_state);
sstr << "[" << sml::aux::get_type_name<SM>() << "] " << src_state << " -> " << dst_state;
messages_out.push_back(sstr.str());
const auto str = sstr.str();
messages_out.push_back(str);
}

std::vector<std::string> messages_out;
Expand Down Expand Up @@ -90,7 +93,8 @@ struct c_log_sm {
test log_sm = [] {
// clang-format off
std::vector<std::string> 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"
Expand Down Expand Up @@ -179,7 +183,9 @@ struct c_log_sub_sm {
test log_sub_sm = [] {
// clang-format off
std::vector<std::string> 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"
Expand Down Expand Up @@ -217,7 +223,9 @@ struct c_log_sub_sm_mix {
test log_sub_sm_mix = [] {
// clang-format off
std::vector<std::string> 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"
Expand Down

0 comments on commit 78e0640

Please sign in to comment.