Commit a16dffe6 authored by Dominik Charousset's avatar Dominik Charousset

Fix lambda captures in broker unit test

parent facce03e
...@@ -34,13 +34,13 @@ using namespace std; ...@@ -34,13 +34,13 @@ using namespace std;
using namespace caf; using namespace caf;
using namespace caf::io; using namespace caf::io;
namespace {
using ping_atom = caf::atom_constant<caf::atom("ping")>; using ping_atom = caf::atom_constant<caf::atom("ping")>;
using pong_atom = caf::atom_constant<caf::atom("pong")>; using pong_atom = caf::atom_constant<caf::atom("pong")>;
using publish_atom = caf::atom_constant<caf::atom("publish")>; using publish_atom = caf::atom_constant<caf::atom("publish")>;
using kickoff_atom = caf::atom_constant<caf::atom("kickoff")>; using kickoff_atom = caf::atom_constant<caf::atom("kickoff")>;
namespace {
void ping(event_based_actor* self, size_t num_pings) { void ping(event_based_actor* self, size_t num_pings) {
CAF_MESSAGE("num_pings: " << num_pings); CAF_MESSAGE("num_pings: " << num_pings);
auto count = std::make_shared<size_t>(0); auto count = std::make_shared<size_t>(0);
...@@ -57,12 +57,12 @@ void ping(event_based_actor* self, size_t num_pings) { ...@@ -57,12 +57,12 @@ void ping(event_based_actor* self, size_t num_pings) {
} }
return std::make_tuple(ping_atom::value, value + 1); return std::make_tuple(ping_atom::value, value + 1);
}, },
others >> [&] { others >> [=] {
CAF_TEST_ERROR("Unexpected message: " CAF_TEST_ERROR("Unexpected message: "
<< to_string(self->current_message())); << to_string(self->current_message()));
}); });
}, },
others >> [&] { others >> [=] {
CAF_TEST_ERROR("Unexpected message: " CAF_TEST_ERROR("Unexpected message: "
<< to_string(self->current_message())); << to_string(self->current_message()));
} }
...@@ -84,7 +84,7 @@ void pong(event_based_actor* self) { ...@@ -84,7 +84,7 @@ void pong(event_based_actor* self) {
CAF_MESSAGE("received down_msg{" << dm.reason << "}"); CAF_MESSAGE("received down_msg{" << dm.reason << "}");
self->quit(dm.reason); self->quit(dm.reason);
}, },
others >> [&] { others >> [=] {
CAF_TEST_ERROR("Unexpected message: " CAF_TEST_ERROR("Unexpected message: "
<< to_string(self->current_message())); << to_string(self->current_message()));
} }
...@@ -92,15 +92,13 @@ void pong(event_based_actor* self) { ...@@ -92,15 +92,13 @@ void pong(event_based_actor* self) {
// reply to 'ping' // reply to 'ping'
return std::make_tuple(pong_atom::value, value); return std::make_tuple(pong_atom::value, value);
}, },
others >> [&] { others >> [=] {
CAF_TEST_ERROR("Unexpected message: " CAF_TEST_ERROR("Unexpected message: "
<< to_string(self->current_message())); << to_string(self->current_message()));
} }
); );
} }
}
void peer_fun(broker* self, connection_handle hdl, const actor& buddy) { void peer_fun(broker* self, connection_handle hdl, const actor& buddy) {
CAF_MESSAGE("peer_fun called"); CAF_MESSAGE("peer_fun called");
CAF_CHECK(self != nullptr); CAF_CHECK(self != nullptr);
...@@ -150,7 +148,7 @@ void peer_fun(broker* self, connection_handle hdl, const actor& buddy) { ...@@ -150,7 +148,7 @@ void peer_fun(broker* self, connection_handle hdl, const actor& buddy) {
self->quit(dm.reason); self->quit(dm.reason);
} }
}, },
others >> [&] { others >> [=] {
CAF_TEST_ERROR("Unexpected message: " CAF_TEST_ERROR("Unexpected message: "
<< to_string(self->current_message())); << to_string(self->current_message()));
} }
...@@ -175,8 +173,6 @@ behavior peer_acceptor_fun(broker* self, const actor& buddy) { ...@@ -175,8 +173,6 @@ behavior peer_acceptor_fun(broker* self, const actor& buddy) {
}; };
} }
namespace {
void run_server(bool spawn_client, const char* bin_path) { void run_server(bool spawn_client, const char* bin_path) {
scoped_actor self; scoped_actor self;
auto serv = io::spawn_io(peer_acceptor_fun, spawn(pong)); auto serv = io::spawn_io(peer_acceptor_fun, spawn(pong));
...@@ -200,7 +196,7 @@ void run_server(bool spawn_client, const char* bin_path) { ...@@ -200,7 +196,7 @@ void run_server(bool spawn_client, const char* bin_path) {
); );
} }
} } // namespace <anonymous>
CAF_TEST(test_broker) { CAF_TEST(test_broker) {
auto argv = caf::test::engine::argv(); auto argv = caf::test::engine::argv();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment