Skip to content

Commit

Permalink
add test for invalid alarm set
Browse files Browse the repository at this point in the history
  • Loading branch information
jbbjarnason committed Jun 24, 2024
1 parent ddd844b commit 86c2c13
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions exes/themis/tests/themis_integration_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,18 @@ int main(int argc, char** argv) {
expect(t.ran[2]);
expect(t.ran[3]);
};

"alarm with declared params but no params provided"_test = [] {
test_setup t;
info<"desc {foo}", "details {bar} {foo}"> i(t.connection, "first_test");
try {
i.set();
expect(false) << "Should have thrown";
}
catch (std::exception&) {
expect(true);
}
};

return 0;
}
2 changes: 1 addition & 1 deletion libs/snitch/inc/public/tfc/snitch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class alarm {
alarm(std::shared_ptr<sdbusplus::asio::connection> conn, std::string_view unique_id, named_arg auto&&... default_args)
: impl_{ conn, unique_id, description, details, var.resettable, var.lvl, { std::make_pair(default_args.name, fmt::format("{}", default_args.value))... } }
{
static_assert(detail::check_all_arguments_named(description), "All arguments must be named");
static_assert(detail::check_all_arguments_named(description), "All arguments must be named, e.g. {name}");
static_assert(detail::check_all_arguments_no_format(description), "All arguments may not have format specifiers");
[[maybe_unused]] static constexpr int num_args = sizeof...(default_args);
static_assert(num_args <= keys_count, "Too many default arguments");
Expand Down

0 comments on commit 86c2c13

Please sign in to comment.