Add type-safe Rust EventLoop APIs
Change-Id: I8c4ac13dec513fd03fe534f8f9449585962b970c
Signed-off-by: Brian Silverman <bsilver16384@gmail.com>
diff --git a/aos/events/event_loop_runtime_test.cc b/aos/events/event_loop_runtime_test.cc
index c27a27f..81f3be3 100644
--- a/aos/events/event_loop_runtime_test.cc
+++ b/aos/events/event_loop_runtime_test.cc
@@ -9,7 +9,8 @@
namespace aos::events::testing {
namespace {
-void MakeAndTestApplication(int value) {
+template <typename F>
+void MakeAndTestApplication(int value, F constructor) {
const int32_t starting_count = completed_test_count();
const aos::FlatbufferDetachedBuffer<aos::Configuration> config =
aos::configuration::ReadConfig(
@@ -20,7 +21,7 @@
auto pong_fetcher = ping_event_loop->MakeFetcher<examples::Pong>("/test");
const auto rust_event_loop = factory.MakeEventLoop("pong");
{
- auto test_application = make_test_application(rust_event_loop.get());
+ auto test_application = constructor(rust_event_loop.get());
int iteration = 0;
ping_event_loop
->AddTimer([&]() {
@@ -51,11 +52,18 @@
} // namespace
-TEST(EventLoopRustTest, TestApplicationOnce) { MakeAndTestApplication(971); }
+TEST(EventLoopRustTest, TestApplicationOnce) {
+ MakeAndTestApplication(971, &make_test_application);
+}
TEST(EventLoopRustTest, TestApplicationTwice) {
- MakeAndTestApplication(971);
- MakeAndTestApplication(254);
+ MakeAndTestApplication(971, &make_test_application);
+ MakeAndTestApplication(254, &make_test_application);
+}
+
+TEST(EventLoopRustTest, TestTypedApplicationTwice) {
+ MakeAndTestApplication(971, &make_typed_test_application);
+ MakeAndTestApplication(254, &make_typed_test_application);
}
} // namespace aos::events::testing