Skip to content

Commit

Permalink
Fix missing include, add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluescarni committed Dec 8, 2023
1 parent 8fe3e85 commit b910836
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/detail/empty_callable_s11n.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

#include <heyoka/callable.hpp>
#include <heyoka/config.hpp>
#include <heyoka/detail/fwd_decl.hpp>
#include <heyoka/step_callback.hpp>
#include <heyoka/taylor.hpp>

#if defined(HEYOKA_HAVE_REAL128)

Expand Down
58 changes: 43 additions & 15 deletions test/taylor_t_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1113,29 +1113,57 @@ TEST_CASE("t s11n")

auto [x, v] = make_vars("x", "v");

t_event<fp_t> ev(v, kw::callback = s11n_callback{}, kw::direction = event_direction::positive,
kw::cooldown = fp_t(100));
{
t_event<fp_t> ev(v, kw::callback = s11n_callback{}, kw::direction = event_direction::positive,
kw::cooldown = fp_t(100));

std::stringstream ss;
std::stringstream ss;

{
boost::archive::binary_oarchive oa(ss);
{
boost::archive::binary_oarchive oa(ss);

oa << ev;
}
oa << ev;
}

ev = t_event<fp_t>(v + x);
ev = t_event<fp_t>(v + x);

{
boost::archive::binary_iarchive ia(ss);
{
boost::archive::binary_iarchive ia(ss);

ia >> ev;
ia >> ev;
}

REQUIRE(ev.get_expression() == v);
REQUIRE(ev.get_direction() == event_direction::positive);
REQUIRE(ev.get_callback().get_type_index() == typeid(s11n_callback));
REQUIRE(ev.get_cooldown() == fp_t(100));
}

REQUIRE(ev.get_expression() == v);
REQUIRE(ev.get_direction() == event_direction::positive);
REQUIRE(ev.get_callback().get_type_index() == typeid(s11n_callback));
REQUIRE(ev.get_cooldown() == fp_t(100));
// Try also a terminal event with empty callback.
{
t_event<fp_t> ev(v, kw::direction = event_direction::positive, kw::cooldown = fp_t(100));

std::stringstream ss;

{
boost::archive::binary_oarchive oa(ss);

oa << ev;
}

ev = t_event<fp_t>(v + x);

{
boost::archive::binary_iarchive ia(ss);

ia >> ev;
}

REQUIRE(ev.get_expression() == v);
REQUIRE(ev.get_direction() == event_direction::positive);
REQUIRE(!ev.get_callback());
REQUIRE(ev.get_cooldown() == fp_t(100));
}
};

tuple_for_each(fp_types, tester);
Expand Down

0 comments on commit b910836

Please sign in to comment.