Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapted policies_logging.cpp tests to correctly handle statemachine start #612

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading