Commit e7dffe87 authored by Dominik Charousset's avatar Dominik Charousset

Use CAF_CHECK_EQUAL to improve unit test output

parent 15a32f2f
...@@ -55,7 +55,7 @@ struct fixture { ...@@ -55,7 +55,7 @@ struct fixture {
self->monitor(aut); self->monitor(aut);
self->receive( self->receive(
[](const down_msg& dm) { [](const down_msg& dm) {
CAF_CHECK(dm.reason == exit_reason::normal); CAF_CHECK_EQUAL(dm.reason, exit_reason::normal);
} }
); );
} }
......
...@@ -74,7 +74,7 @@ behavior tester(event_based_actor* self, const actor& aut) { ...@@ -74,7 +74,7 @@ behavior tester(event_based_actor* self, const actor& aut) {
CAF_CHECK_EQUAL(s_testees.load(), 1); CAF_CHECK_EQUAL(s_testees.load(), 1);
CAF_CHECK_EQUAL(msg.reason, exit_reason::user_shutdown); CAF_CHECK_EQUAL(msg.reason, exit_reason::user_shutdown);
CAF_CHECK_EQUAL(self->current_message().vals()->get_reference_count(), 1u); CAF_CHECK_EQUAL(self->current_message().vals()->get_reference_count(), 1u);
CAF_CHECK(&msg == self->current_message().at(0)); CAF_CHECK_EQUAL(&msg, self->current_message().at(0));
// testee might be still running its cleanup code in // testee might be still running its cleanup code in
// another worker thread; by waiting some milliseconds, we make sure // another worker thread; by waiting some milliseconds, we make sure
// testee had enough time to return control to the scheduler // testee had enough time to return control to the scheduler
......
...@@ -93,7 +93,7 @@ CAF_TEST(round_robin_actor_pool) { ...@@ -93,7 +93,7 @@ CAF_TEST(round_robin_actor_pool) {
} }
); );
} }
CAF_CHECK(workers.size() == 6); CAF_CHECK_EQUAL(workers.size(), 6u);
CAF_CHECK(std::unique(workers.begin(), workers.end()) == workers.end()); CAF_CHECK(std::unique(workers.begin(), workers.end()) == workers.end());
auto is_invalid = [](const actor_addr& addr) { auto is_invalid = [](const actor_addr& addr) {
return addr == invalid_actor_addr; return addr == invalid_actor_addr;
...@@ -103,21 +103,21 @@ CAF_TEST(round_robin_actor_pool) { ...@@ -103,21 +103,21 @@ CAF_TEST(round_robin_actor_pool) {
[&](std::vector<actor>& ws) { [&](std::vector<actor>& ws) {
std::sort(workers.begin(), workers.end()); std::sort(workers.begin(), workers.end());
std::sort(ws.begin(), ws.end()); std::sort(ws.begin(), ws.end());
CAF_CHECK(workers.size() == ws.size() CAF_REQUIRE_EQUAL(workers.size(), ws.size());
&& std::equal(workers.begin(), workers.end(), ws.begin())); CAF_CHECK(std::equal(workers.begin(), workers.end(), ws.begin()));
} }
); );
anon_send_exit(workers.back(), exit_reason::user_shutdown); anon_send_exit(workers.back(), exit_reason::user_shutdown);
self->receive( self->receive(
[&](const down_msg& dm) { [&](const down_msg& dm) {
CAF_CHECK(dm.source == workers.back()); CAF_CHECK_EQUAL(dm.source, workers.back());
workers.pop_back(); workers.pop_back();
// check whether actor pool removed failed worker // check whether actor pool removed failed worker
self->request(w, infinite, sys_atom::value, get_atom::value).receive( self->request(w, infinite, sys_atom::value, get_atom::value).receive(
[&](std::vector<actor>& ws) { [&](std::vector<actor>& ws) {
std::sort(ws.begin(), ws.end()); std::sort(ws.begin(), ws.end());
CAF_CHECK(workers.size() == ws.size() CAF_REQUIRE_EQUAL(workers.size(), ws.size());
&& std::equal(workers.begin(), workers.end(), ws.begin())); CAF_CHECK(std::equal(workers.begin(), workers.end(), ws.begin()));
} }
); );
}, },
...@@ -132,7 +132,7 @@ CAF_TEST(round_robin_actor_pool) { ...@@ -132,7 +132,7 @@ CAF_TEST(round_robin_actor_pool) {
[&](const down_msg& dm) { [&](const down_msg& dm) {
auto last = workers.end(); auto last = workers.end();
auto src = dm.source; auto src = dm.source;
CAF_CHECK(src != invalid_actor_addr); CAF_CHECK_NOT_EQUAL(src, invalid_actor_addr);
auto pos = std::find(workers.begin(), last, src); auto pos = std::find(workers.begin(), last, src);
if (pos != last) if (pos != last)
workers.erase(pos); workers.erase(pos);
......
...@@ -43,7 +43,7 @@ struct fixture { ...@@ -43,7 +43,7 @@ struct fixture {
void wait_until_exited() { void wait_until_exited() {
self->receive( self->receive(
[](const down_msg&) { [](const down_msg&) {
CAF_CHECK(true); // nop
} }
); );
} }
...@@ -66,13 +66,13 @@ CAF_TEST_FIXTURE_SCOPE(adapter_tests, fixture) ...@@ -66,13 +66,13 @@ CAF_TEST_FIXTURE_SCOPE(adapter_tests, fixture)
CAF_TEST(identity) { CAF_TEST(identity) {
auto dbl = system.spawn(testee); auto dbl = system.spawn(testee);
CAF_CHECK(system.registry().running() == 1); CAF_CHECK_EQUAL(system.registry().running(), 1u);
auto bound = dbl.bind(1); auto bound = dbl.bind(1);
CAF_CHECK(system.registry().running() == 1); CAF_CHECK_EQUAL(system.registry().running(), 1u);
CAF_CHECK(&bound->home_system() == &dbl->home_system()); CAF_CHECK_EQUAL(&bound->home_system(), &dbl->home_system());
CAF_CHECK(bound->node() == dbl->node()); CAF_CHECK_EQUAL(bound->node(), dbl->node());
CAF_CHECK(bound != dbl); CAF_CHECK_NOT_EQUAL(bound, dbl);
CAF_CHECK(bound->id() != dbl->id()); CAF_CHECK_NOT_EQUAL(bound->id(), dbl->id());
//anon_send_exit(bound, exit_reason::kill); //anon_send_exit(bound, exit_reason::kill);
anon_send_exit(dbl, exit_reason::kill); anon_send_exit(dbl, exit_reason::kill);
// killing dbl triggers a down message to bound, which becomes unreachable // killing dbl triggers a down message to bound, which becomes unreachable
...@@ -115,10 +115,7 @@ CAF_TEST(lifetime_3) { ...@@ -115,10 +115,7 @@ CAF_TEST(lifetime_3) {
wait_until_exited(); wait_until_exited();
self->request(dbl, infinite, 1).receive( self->request(dbl, infinite, 1).receive(
[](int v) { [](int v) {
CAF_CHECK(v == 2); CAF_CHECK_EQUAL(v, 2);
},
[](error) {
CAF_CHECK(false);
} }
); );
anon_send_exit(dbl, exit_reason::kill); anon_send_exit(dbl, exit_reason::kill);
...@@ -131,10 +128,11 @@ CAF_TEST(request_response_promise) { ...@@ -131,10 +128,11 @@ CAF_TEST(request_response_promise) {
CAF_CHECK(exited(bound)); CAF_CHECK(exited(bound));
self->request(bound, infinite, message{}).receive( self->request(bound, infinite, message{}).receive(
[](int) { [](int) {
CAF_CHECK(false); throw std::runtime_error("received unexpected integer");
}, },
[](error err) { [](error err) {
CAF_CHECK(err.code() == static_cast<uint8_t>(sec::request_receiver_down)); CAF_CHECK_EQUAL(err.code(),
static_cast<uint8_t>(sec::request_receiver_down));
} }
); );
anon_send_exit(dbl, exit_reason::kill); anon_send_exit(dbl, exit_reason::kill);
...@@ -153,20 +151,20 @@ CAF_TEST(partial_currying) { ...@@ -153,20 +151,20 @@ CAF_TEST(partial_currying) {
}; };
}; };
auto aut = system.spawn(impl); auto aut = system.spawn(impl);
CAF_CHECK(system.registry().running() == 1); CAF_CHECK_EQUAL(system.registry().running(), 1u);
auto bound = aut.bind(ok_atom::value, _1); auto bound = aut.bind(ok_atom::value, _1);
CAF_CHECK(aut.id() != bound.id()); CAF_CHECK_NOT_EQUAL(aut.id(), bound.id());
CAF_CHECK(aut.node() == bound.node()); CAF_CHECK_NOT_EQUAL(aut, bound);
CAF_CHECK(aut != bound); CAF_CHECK_EQUAL(aut.node(), bound.node());
CAF_CHECK(system.registry().running() == 1); CAF_CHECK_EQUAL(system.registry().running(), 1u);
self->request(bound, infinite, 2.0).receive( self->request(bound, infinite, 2.0).receive(
[](double y) { [](double y) {
CAF_CHECK(y == 2.0); CAF_CHECK_EQUAL(y, 2.0);
} }
); );
self->request(bound, infinite, 10).receive( self->request(bound, infinite, 10).receive(
[](int y) { [](int y) {
CAF_CHECK(y == 10); CAF_CHECK_EQUAL(y, 10);
} }
); );
self->send_exit(aut, exit_reason::kill); self->send_exit(aut, exit_reason::kill);
...@@ -177,10 +175,7 @@ CAF_TEST(full_currying) { ...@@ -177,10 +175,7 @@ CAF_TEST(full_currying) {
auto bound = dbl_actor.bind(1); auto bound = dbl_actor.bind(1);
self->request(bound, infinite, message{}).receive( self->request(bound, infinite, message{}).receive(
[](int v) { [](int v) {
CAF_CHECK(v == 2); CAF_CHECK_EQUAL(v, 2);
},
[](error) {
CAF_CHECK(false);
} }
); );
anon_send_exit(bound, exit_reason::kill); anon_send_exit(bound, exit_reason::kill);
...@@ -202,22 +197,22 @@ CAF_TEST(type_safe_currying) { ...@@ -202,22 +197,22 @@ CAF_TEST(type_safe_currying) {
}; };
}; };
auto aut = system.spawn(impl); auto aut = system.spawn(impl);
CAF_CHECK(system.registry().running() == 1); CAF_CHECK_EQUAL(system.registry().running(), 1u);
using curried_signature = typed_actor<replies_to<int>::with<int>, using curried_signature = typed_actor<replies_to<int>::with<int>,
replies_to<double>::with<double>>; replies_to<double>::with<double>>;
auto bound = aut.bind(ok_atom::value, _1); auto bound = aut.bind(ok_atom::value, _1);
CAF_CHECK(aut != bound); CAF_CHECK_NOT_EQUAL(aut.address(), bound.address());
CAF_CHECK(system.registry().running() == 1); CAF_CHECK_EQUAL(system.registry().running(), 1u);
static_assert(std::is_same<decltype(bound), curried_signature>::value, static_assert(std::is_same<decltype(bound), curried_signature>::value,
"bind returned wrong actor handle"); "bind returned wrong actor handle");
self->request(bound, infinite, 2.0).receive( self->request(bound, infinite, 2.0).receive(
[](double y) { [](double y) {
CAF_CHECK(y == 2.0); CAF_CHECK_EQUAL(y, 2.0);
} }
); );
self->request(bound, infinite, 10).receive( self->request(bound, infinite, 10).receive(
[](int y) { [](int y) {
CAF_CHECK(y == 10); CAF_CHECK_EQUAL(y, 10);
} }
); );
self->send_exit(aut, exit_reason::kill); self->send_exit(aut, exit_reason::kill);
...@@ -232,14 +227,14 @@ CAF_TEST(reordering) { ...@@ -232,14 +227,14 @@ CAF_TEST(reordering) {
}; };
}; };
auto aut = system.spawn(impl); auto aut = system.spawn(impl);
CAF_CHECK(system.registry().running() == 1); CAF_CHECK_EQUAL(system.registry().running(), 1u);
using namespace std::placeholders; using namespace std::placeholders;
auto bound = aut.bind(_2, _1); auto bound = aut.bind(_2, _1);
CAF_CHECK(aut != bound); CAF_CHECK_NOT_EQUAL(aut, bound);
CAF_CHECK(system.registry().running() == 1); CAF_CHECK_EQUAL(system.registry().running(), 1u);
self->request(bound, infinite, 2.0, 10).receive( self->request(bound, infinite, 2.0, 10).receive(
[](double y) { [](double y) {
CAF_CHECK(y == 20.0); CAF_CHECK_EQUAL(y, 20.0);
} }
); );
self->send_exit(aut, exit_reason::kill); self->send_exit(aut, exit_reason::kill);
...@@ -255,17 +250,17 @@ CAF_TEST(type_safe_reordering) { ...@@ -255,17 +250,17 @@ CAF_TEST(type_safe_reordering) {
}; };
}; };
auto aut = system.spawn(impl); auto aut = system.spawn(impl);
CAF_CHECK(system.registry().running() == 1); CAF_CHECK_EQUAL(system.registry().running(), 1u);
using namespace std::placeholders; using namespace std::placeholders;
using swapped_signature = typed_actor<replies_to<double, int>::with<double>>; using swapped_signature = typed_actor<replies_to<double, int>::with<double>>;
auto bound = aut.bind(_2, _1); auto bound = aut.bind(_2, _1);
CAF_CHECK(aut != bound); CAF_CHECK_NOT_EQUAL(aut.address(), bound.address());
CAF_CHECK(system.registry().running() == 1); CAF_CHECK_EQUAL(system.registry().running(), 1u);
static_assert(std::is_same<decltype(bound), swapped_signature>::value, static_assert(std::is_same<decltype(bound), swapped_signature>::value,
"bind returned wrong actor handle"); "bind returned wrong actor handle");
self->request(bound, infinite, 2.0, 10).receive( self->request(bound, infinite, 2.0, 10).receive(
[](double y) { [](double y) {
CAF_CHECK(y == 20.0); CAF_CHECK_EQUAL(y, 20.0);
} }
); );
self->send_exit(aut, exit_reason::kill); self->send_exit(aut, exit_reason::kill);
......
...@@ -49,11 +49,11 @@ CAF_TEST_FIXTURE_SCOPE(atom_tests, fixture) ...@@ -49,11 +49,11 @@ CAF_TEST_FIXTURE_SCOPE(atom_tests, fixture)
CAF_TEST(basics) { CAF_TEST(basics) {
// check if there are leading bits that distinguish "zzz" and "000 " // check if there are leading bits that distinguish "zzz" and "000 "
CAF_CHECK(atom("zzz") != atom("000 ")); CAF_CHECK_NOT_EQUAL(atom("zzz"), atom("000 "));
// check if there are leading bits that distinguish "abc" and " abc" // check if there are leading bits that distinguish "abc" and " abc"
CAF_CHECK(atom("abc") != atom(" abc")); CAF_CHECK_NOT_EQUAL(atom("abc"), atom(" abc"));
// 'illegal' characters are mapped to whitespaces // 'illegal' characters are mapped to whitespaces
CAF_CHECK(atom(" ") == atom("@!?")); CAF_CHECK_EQUAL(atom(" "), atom("@!?"));
// check to_string impl // check to_string impl
CAF_CHECK_EQUAL(to_string(s_foo), "FooBar"); CAF_CHECK_EQUAL(to_string(s_foo), "FooBar");
} }
...@@ -102,7 +102,7 @@ CAF_TEST(receive_atoms) { ...@@ -102,7 +102,7 @@ CAF_TEST(receive_atoms) {
); );
atom_value x = atom("abc"); atom_value x = atom("abc");
atom_value y = abc_atom::value; atom_value y = abc_atom::value;
CAF_CHECK(x == y); CAF_CHECK_EQUAL(x, y);
auto msg = make_message(atom("abc")); auto msg = make_message(atom("abc"));
self->send(self, msg); self->send(self, msg);
self->receive( self->receive(
......
...@@ -142,7 +142,7 @@ CAF_TEST(composable_behaviors) { ...@@ -142,7 +142,7 @@ CAF_TEST(composable_behaviors) {
scoped_actor self{sys}; scoped_actor self{sys};
self->request(x1, infinite, 1, 2, 4).receive( self->request(x1, infinite, 1, 2, 4).receive(
[](int y) { [](int y) {
CAF_CHECK(y == 7); CAF_CHECK_EQUAL(y, 7);
} }
); );
self->send_exit(x1, exit_reason::kill); self->send_exit(x1, exit_reason::kill);
...@@ -150,13 +150,13 @@ CAF_TEST(composable_behaviors) { ...@@ -150,13 +150,13 @@ CAF_TEST(composable_behaviors) {
auto x2 = sys.spawn<composed_behavior<i3_actor_state, d_actor_state>>(); auto x2 = sys.spawn<composed_behavior<i3_actor_state, d_actor_state>>();
self->request(x2, infinite, 1, 2, 4).receive( self->request(x2, infinite, 1, 2, 4).receive(
[](int y) { [](int y) {
CAF_CHECK(y == 7); CAF_CHECK_EQUAL(y, 7);
} }
); );
self->request(x2, infinite, 1.0).receive( self->request(x2, infinite, 1.0).receive(
[](double y1, double y2) { [](double y1, double y2) {
CAF_CHECK(y1 == 1.0); CAF_CHECK_EQUAL(y1, 1.0);
CAF_CHECK(y1 == y2); CAF_CHECK_EQUAL(y1, y2);
} }
); );
self->send_exit(x2, exit_reason::kill); self->send_exit(x2, exit_reason::kill);
...@@ -164,7 +164,7 @@ CAF_TEST(composable_behaviors) { ...@@ -164,7 +164,7 @@ CAF_TEST(composable_behaviors) {
auto x3 = sys.spawn<foo_actor_state2>(); auto x3 = sys.spawn<foo_actor_state2>();
self->request(x3, infinite, 1, 2, 4).receive( self->request(x3, infinite, 1, 2, 4).receive(
[](int y) { [](int y) {
CAF_CHECK(y == -5); CAF_CHECK_EQUAL(y, -5);
} }
); );
self->send_exit(x3, exit_reason::kill); self->send_exit(x3, exit_reason::kill);
...@@ -172,7 +172,7 @@ CAF_TEST(composable_behaviors) { ...@@ -172,7 +172,7 @@ CAF_TEST(composable_behaviors) {
auto x4 = sys.spawn<dict_calc_state>(); auto x4 = sys.spawn<dict_calc_state>();
self->request(x4, infinite, add_atom::value, 10, 20).receive( self->request(x4, infinite, add_atom::value, 10, 20).receive(
[](int y) { [](int y) {
CAF_CHECK(y == 30); CAF_CHECK_EQUAL(y, 30);
} }
); );
self->send_exit(x4, exit_reason::kill); self->send_exit(x4, exit_reason::kill);
......
...@@ -61,7 +61,7 @@ CAF_TEST(constructor_attach) { ...@@ -61,7 +61,7 @@ CAF_TEST(constructor_attach) {
return { return {
[=](const down_msg& msg) { [=](const down_msg& msg) {
CAF_CHECK_EQUAL(msg.reason, exit_reason::user_shutdown); CAF_CHECK_EQUAL(msg.reason, exit_reason::user_shutdown);
CAF_CHECK(msg.source == testee_); CAF_CHECK_EQUAL(msg.source, testee_.address());
if (++downs_ == 2) { if (++downs_ == 2) {
quit(msg.reason); quit(msg.reason);
} }
......
...@@ -87,7 +87,7 @@ CAF_TEST(test_custom_exception_handler) { ...@@ -87,7 +87,7 @@ CAF_TEST(test_custom_exception_handler) {
CAF_CHECK_EQUAL(dm.reason, exit_reason::remote_link_unreachable); CAF_CHECK_EQUAL(dm.reason, exit_reason::remote_link_unreachable);
} }
else { else {
CAF_CHECK(false); // report error throw std::runtime_error("received message from unexpected source");
} }
} }
); );
......
...@@ -648,7 +648,7 @@ CAF_TEST(custom_exception_handler) { ...@@ -648,7 +648,7 @@ CAF_TEST(custom_exception_handler) {
CAF_CHECK_EQUAL(dm.reason, exit_reason::unhandled_exception); CAF_CHECK_EQUAL(dm.reason, exit_reason::unhandled_exception);
} }
else { else {
CAF_CHECK(false); // report error throw std::runtime_error("received message from unexpected source");
} }
} }
); );
...@@ -668,8 +668,8 @@ CAF_TEST(kill_the_immortal) { ...@@ -668,8 +668,8 @@ CAF_TEST(kill_the_immortal) {
self->send_exit(wannabe_immortal, exit_reason::kill); self->send_exit(wannabe_immortal, exit_reason::kill);
self->receive( self->receive(
[&](const down_msg& dm) { [&](const down_msg& dm) {
CAF_CHECK(dm.reason == exit_reason::kill); CAF_CHECK_EQUAL(dm.reason, exit_reason::kill);
CAF_CHECK(dm.source == wannabe_immortal); CAF_CHECK_EQUAL(dm.source, wannabe_immortal.address());
} }
); );
} }
...@@ -702,7 +702,7 @@ CAF_TEST(move_only_argument) { ...@@ -702,7 +702,7 @@ CAF_TEST(move_only_argument) {
scoped_actor self{system}; scoped_actor self{system};
self->request(testee, infinite, 1.f).receive( self->request(testee, infinite, 1.f).receive(
[](int i) { [](int i) {
CAF_CHECK(i == 42); CAF_CHECK_EQUAL(i, 42);
} }
); );
} }
......
...@@ -103,13 +103,13 @@ CAF_TEST(empty_function_fiew) { ...@@ -103,13 +103,13 @@ CAF_TEST(empty_function_fiew) {
CAF_ERROR("line must be unreachable"); CAF_ERROR("line must be unreachable");
} }
catch (std::bad_function_call&) { catch (std::bad_function_call&) {
CAF_CHECK(true); // nop
} }
} }
CAF_TEST(single_res_function_view) { CAF_TEST(single_res_function_view) {
auto f = make_function_view(system.spawn(adder)); auto f = make_function_view(system.spawn(adder));
CAF_CHECK(f(3, 4) == 7); CAF_CHECK_EQUAL(f(3, 4), 7);
CAF_CHECK(f != nullptr); CAF_CHECK(f != nullptr);
CAF_CHECK(nullptr != f); CAF_CHECK(nullptr != f);
function_view<calculator> g; function_view<calculator> g;
...@@ -118,32 +118,32 @@ CAF_TEST(single_res_function_view) { ...@@ -118,32 +118,32 @@ CAF_TEST(single_res_function_view) {
CAF_CHECK(nullptr == f); CAF_CHECK(nullptr == f);
CAF_CHECK(g != nullptr); CAF_CHECK(g != nullptr);
CAF_CHECK(nullptr != g); CAF_CHECK(nullptr != g);
CAF_CHECK(g(10, 20) == 30); CAF_CHECK_EQUAL(g(10, 20), 30);
g.assign(system.spawn(multiplier)); g.assign(system.spawn(multiplier));
CAF_CHECK(g(10, 20) == 200); CAF_CHECK_EQUAL(g(10, 20), 200);
g.assign(system.spawn(divider)); g.assign(system.spawn(divider));
try { try {
g(1, 0); g(1, 0);
CAF_ERROR("expected exception"); CAF_ERROR("expected exception");
} }
catch (actor_exited&) { catch (actor_exited&) {
CAF_CHECK(true); // nop
} }
CAF_CHECK(g == nullptr); CAF_CHECK(g == nullptr);
g.assign(system.spawn(divider)); g.assign(system.spawn(divider));
CAF_CHECK(g(4, 2) == 2); CAF_CHECK_EQUAL(g(4, 2), 2);
} }
CAF_TEST(tuple_res_function_view) { CAF_TEST(tuple_res_function_view) {
auto f = make_function_view(system.spawn(simple_doubler)); auto f = make_function_view(system.spawn(simple_doubler));
CAF_CHECK(f(10) == std::make_tuple(10, 10)); CAF_CHECK_EQUAL(f(10), std::make_tuple(10, 10));
} }
CAF_TEST(cell_function_view) { CAF_TEST(cell_function_view) {
auto f = make_function_view(system.spawn(simple_cell)); auto f = make_function_view(system.spawn(simple_cell));
CAF_CHECK(f(get_atom::value) == 0); CAF_CHECK_EQUAL(f(get_atom::value), 0);
f(put_atom::value, 1024); f(put_atom::value, 1024);
CAF_CHECK(f(get_atom::value) == 1024); CAF_CHECK_EQUAL(f(get_atom::value), 1024);
} }
CAF_TEST_FIXTURE_SCOPE_END() CAF_TEST_FIXTURE_SCOPE_END()
...@@ -151,7 +151,7 @@ CAF_TEST(full_test) { ...@@ -151,7 +151,7 @@ CAF_TEST(full_test) {
CAF_CHECK_EQUAL(p1->unique(), false); CAF_CHECK_EQUAL(p1->unique(), false);
CAF_CHECK_EQUAL(class0_instances, 0); CAF_CHECK_EQUAL(class0_instances, 0);
CAF_CHECK_EQUAL(class1_instances, 1); CAF_CHECK_EQUAL(class1_instances, 1);
CAF_CHECK(p1 == p2); CAF_CHECK_EQUAL(p1, static_cast<class0*>(p2.get()));
} }
CAF_TEST_FIXTURE_SCOPE_END() CAF_TEST_FIXTURE_SCOPE_END()
...@@ -45,7 +45,7 @@ void testee(event_based_actor* self) { ...@@ -45,7 +45,7 @@ void testee(event_based_actor* self) {
}, },
[=](timeout_atom) { [=](timeout_atom) {
// this actor should receive only 1 message // this actor should receive only 1 message
CAF_CHECK(*counter == 1); CAF_CHECK_EQUAL(*counter, 1);
self->quit(); self->quit();
} }
); );
......
...@@ -63,14 +63,14 @@ CAF_TEST(drop) { ...@@ -63,14 +63,14 @@ CAF_TEST(drop) {
message{} message{}
}; };
for (size_t i = 0; i < messages.size(); ++i) { for (size_t i = 0; i < messages.size(); ++i) {
CAF_CHECK(to_string(m1.drop(i)) == to_string(messages[i])); CAF_CHECK_EQUAL(to_string(m1.drop(i)), to_string(messages[i]));
} }
} }
CAF_TEST(slice) { CAF_TEST(slice) {
auto m1 = make_message(1, 2, 3, 4, 5); auto m1 = make_message(1, 2, 3, 4, 5);
auto m2 = m1.slice(2, 2); auto m2 = m1.slice(2, 2);
CAF_CHECK(to_string(m2) == to_string(make_message(3, 4))); CAF_CHECK_EQUAL(to_string(m2), to_string(make_message(3, 4)));
} }
CAF_TEST(extract1) { CAF_TEST(extract1) {
...@@ -86,12 +86,12 @@ CAF_TEST(extract1) { ...@@ -86,12 +86,12 @@ CAF_TEST(extract1) {
[](float, float) { } [](float, float) { }
}; };
auto m1s = to_string(m1); auto m1s = to_string(m1);
CAF_CHECK(to_string(m2.extract(f)) == m1s); CAF_CHECK_EQUAL(to_string(m2.extract(f)), m1s);
CAF_CHECK(to_string(m3.extract(f)) == m1s); CAF_CHECK_EQUAL(to_string(m3.extract(f)), m1s);
CAF_CHECK(to_string(m4.extract(f)) == m1s); CAF_CHECK_EQUAL(to_string(m4.extract(f)), m1s);
CAF_CHECK(to_string(m5.extract(f)) == m1s); CAF_CHECK_EQUAL(to_string(m5.extract(f)), m1s);
CAF_CHECK(to_string(m6.extract(f)) == m1s); CAF_CHECK_EQUAL(to_string(m6.extract(f)), m1s);
CAF_CHECK(to_string(m7.extract(f)) == m1s); CAF_CHECK_EQUAL(to_string(m7.extract(f)), m1s);
} }
CAF_TEST(extract2) { CAF_TEST(extract2) {
...@@ -103,7 +103,7 @@ CAF_TEST(extract2) { ...@@ -103,7 +103,7 @@ CAF_TEST(extract2) {
[](double, double) { } [](double, double) { }
}); });
// check for false positives through collapsing // check for false positives through collapsing
CAF_CHECK(to_string(m3) == to_string(make_message(1.0, 4.0))); CAF_CHECK_EQUAL(to_string(m3), to_string(make_message(1.0, 4.0)));
} }
CAF_TEST(extract_opts) { CAF_TEST(extract_opts) {
...@@ -135,8 +135,8 @@ CAF_TEST(extract_opts) { ...@@ -135,8 +135,8 @@ CAF_TEST(extract_opts) {
{"foo,f", "foo desc", foo} {"foo,f", "foo desc", foo}
}); });
CAF_CHECK(r.opts.count("foo") > 0); CAF_CHECK(r.opts.count("foo") > 0);
CAF_CHECK(foo == 42); CAF_CHECK_EQUAL(foo, 42);
CAF_CHECK(bar == 0); CAF_CHECK_EQUAL(bar, 0);
CAF_CHECK(! r.error.empty()); // -b is an unknown option CAF_CHECK(! r.error.empty()); // -b is an unknown option
CAF_CHECK(! r.remainder.empty() CAF_CHECK(! r.remainder.empty()
&& to_string(r.remainder) == to_string(make_message("-b", "1337"))); && to_string(r.remainder) == to_string(make_message("-b", "1337")));
...@@ -144,7 +144,7 @@ CAF_TEST(extract_opts) { ...@@ -144,7 +144,7 @@ CAF_TEST(extract_opts) {
{"bar,b", "bar desc", bar} {"bar,b", "bar desc", bar}
}); });
CAF_CHECK(r.opts.count("bar") > 0); CAF_CHECK(r.opts.count("bar") > 0);
CAF_CHECK(bar == 1337); CAF_CHECK_EQUAL(bar, 1337);
CAF_CHECK(r.error.empty()); CAF_CHECK(r.error.empty());
} }
...@@ -157,11 +157,11 @@ CAF_TEST(concat) { ...@@ -157,11 +157,11 @@ CAF_TEST(concat) {
auto m1 = make_message(get_atom::value); auto m1 = make_message(get_atom::value);
auto m2 = make_message(uint32_t{1}); auto m2 = make_message(uint32_t{1});
auto m3 = message::concat(m1, m2); auto m3 = message::concat(m1, m2);
CAF_CHECK(to_string(m3) == to_string(m1 + m2)); CAF_CHECK_EQUAL(to_string(m3), to_string(m1 + m2));
CAF_CHECK(to_string(m3) == "('get', 1)"); CAF_CHECK_EQUAL(to_string(m3), "('get', 1)");
auto m4 = make_message(get_atom::value, uint32_t{1}, auto m4 = make_message(get_atom::value, uint32_t{1},
get_atom::value, uint32_t{1}); get_atom::value, uint32_t{1});
CAF_CHECK(to_string(message::concat(m3, message{}, m1, m2)) == to_string(m4)); CAF_CHECK_EQUAL(to_string(message::concat(m3, message{}, m1, m2)), to_string(m4));
} }
namespace { namespace {
...@@ -237,35 +237,35 @@ CAF_TEST(integers_to_string) { ...@@ -237,35 +237,35 @@ CAF_TEST(integers_to_string) {
CAF_TEST(strings_to_string) { CAF_TEST(strings_to_string) {
using svec = vector<string>; using svec = vector<string>;
auto msg1 = make_message("one", "two", "three"); auto msg1 = make_message("one", "two", "three");
CAF_CHECK(to_string(msg1) == R"__(("one", "two", "three"))__"); CAF_CHECK_EQUAL(to_string(msg1), R"__(("one", "two", "three"))__");
auto msg2 = make_message(svec{"one", "two", "three"}); auto msg2 = make_message(svec{"one", "two", "three"});
CAF_CHECK(to_string(msg2) == R"__((["one", "two", "three"]))__"); CAF_CHECK_EQUAL(to_string(msg2), R"__((["one", "two", "three"]))__");
auto msg3 = make_message(svec{"one", "two"}, "three", "four", auto msg3 = make_message(svec{"one", "two"}, "three", "four",
svec{"five", "six", "seven"}); svec{"five", "six", "seven"});
CAF_CHECK(to_string(msg3) == CAF_CHECK(to_string(msg3) ==
R"__((["one", "two"], "three", "four", ["five", "six", "seven"]))__"); R"__((["one", "two"], "three", "four", ["five", "six", "seven"]))__");
auto msg4 = make_message("this is a \"test\""); auto msg4 = make_message("this is a \"test\"");
CAF_CHECK(to_string(msg4) == R"__(("this is a \"test\""))__"); CAF_CHECK_EQUAL(to_string(msg4), R"__(("this is a \"test\""))__");
} }
CAF_TEST(maps_to_string) { CAF_TEST(maps_to_string) {
map<int, int> m1{{1, 10}, {2, 20}, {3, 30}}; map<int, int> m1{{1, 10}, {2, 20}, {3, 30}};
auto msg1 = make_message(move(m1)); auto msg1 = make_message(move(m1));
CAF_CHECK(to_string(msg1) == "([(1, 10), (2, 20), (3, 30)])"); CAF_CHECK_EQUAL(to_string(msg1), "([(1, 10), (2, 20), (3, 30)])");
} }
CAF_TEST(tuples_to_string) { CAF_TEST(tuples_to_string) {
auto msg1 = make_message(make_tuple(1, 2, 3), 4, 5); auto msg1 = make_message(make_tuple(1, 2, 3), 4, 5);
CAF_CHECK(to_string(msg1) == "((1, 2, 3), 4, 5)"); CAF_CHECK_EQUAL(to_string(msg1), "((1, 2, 3), 4, 5)");
auto msg2 = make_message(make_tuple(string{"one"}, 2, uint32_t{3}), 4, true); auto msg2 = make_message(make_tuple(string{"one"}, 2, uint32_t{3}), 4, true);
CAF_CHECK(to_string(msg2) == "((\"one\", 2, 3), 4, true)"); CAF_CHECK_EQUAL(to_string(msg2), "((\"one\", 2, 3), 4, true)");
} }
CAF_TEST(arrays_to_string) { CAF_TEST(arrays_to_string) {
CAF_CHECK(msg_as_string(s1{}) == "((10, 20, 30))"); CAF_CHECK_EQUAL(msg_as_string(s1{}), "((10, 20, 30))");
auto msg2 = make_message(s2{}); auto msg2 = make_message(s2{});
s2 tmp; s2 tmp;
tmp.value[0][1] = 100; tmp.value[0][1] = 100;
CAF_CHECK(to_string(msg2) == "(((1, 10), (2, 20), (3, 30), (4, 40)))"); CAF_CHECK_EQUAL(to_string(msg2), "(((1, 10), (2, 20), (3, 30), (4, 40)))");
CAF_CHECK(msg_as_string(s3{}) == "((1, 2, 3, 4))"); CAF_CHECK_EQUAL(msg_as_string(s3{}), "((1, 2, 3, 4))");
} }
...@@ -81,13 +81,13 @@ behavior tester::make_behavior() { ...@@ -81,13 +81,13 @@ behavior tester::make_behavior() {
CAF_CHECK_EQUAL(a, 1); CAF_CHECK_EQUAL(a, 1);
CAF_CHECK_EQUAL(b, 2); CAF_CHECK_EQUAL(b, 2);
CAF_CHECK_EQUAL(c, 3); CAF_CHECK_EQUAL(c, 3);
CAF_CHECK(current_message().cvals()->get_reference_count() == 2 CAF_CHECK_EQUAL(current_message().cvals()->get_reference_count(), 2u);
&& current_message().cvals().get() == msg_.cvals().get()); CAF_CHECK_EQUAL(current_message().cvals().get(), msg_.cvals().get());
}, },
[=](const down_msg& dm) { [=](const down_msg& dm) {
CAF_CHECK(dm.source == aut_ CAF_CHECK_EQUAL(dm.reason, exit_reason::normal);
&& dm.reason == exit_reason::normal CAF_CHECK_EQUAL(current_message().cvals()->get_reference_count(), 1u);
&& current_message().cvals()->get_reference_count() == 1); CAF_CHECK_EQUAL(dm.source, aut_.address());
quit(); quit();
} }
}; };
...@@ -119,7 +119,7 @@ CAF_TEST(message_lifetime_in_scoped_actor) { ...@@ -119,7 +119,7 @@ CAF_TEST(message_lifetime_in_scoped_actor) {
CAF_CHECK_EQUAL(c, 3); CAF_CHECK_EQUAL(c, 3);
CAF_CHECK_EQUAL(msg.cvals()->get_reference_count(), 2u); CAF_CHECK_EQUAL(msg.cvals()->get_reference_count(), 2u);
CAF_CHECK_EQUAL(self->current_message().cvals()->get_reference_count(), 2u); CAF_CHECK_EQUAL(self->current_message().cvals()->get_reference_count(), 2u);
CAF_CHECK(self->current_message().cvals().get() == msg.cvals().get()); CAF_CHECK_EQUAL(self->current_message().cvals().get(), msg.cvals().get());
} }
); );
CAF_CHECK_EQUAL(msg.cvals()->get_reference_count(), 1u); CAF_CHECK_EQUAL(msg.cvals()->get_reference_count(), 1u);
...@@ -129,7 +129,8 @@ CAF_TEST(message_lifetime_in_scoped_actor) { ...@@ -129,7 +129,8 @@ CAF_TEST(message_lifetime_in_scoped_actor) {
[&](int& value) { [&](int& value) {
CAF_CHECK_EQUAL(msg.cvals()->get_reference_count(), 1u); CAF_CHECK_EQUAL(msg.cvals()->get_reference_count(), 1u);
CAF_CHECK_EQUAL(self->current_message().cvals()->get_reference_count(), 1u); CAF_CHECK_EQUAL(self->current_message().cvals()->get_reference_count(), 1u);
CAF_CHECK(self->current_message().cvals().get() != msg.cvals().get()); CAF_CHECK_NOT_EQUAL(self->current_message().cvals().get(),
msg.cvals().get());
value = 10; value = 10;
} }
); );
......
...@@ -51,11 +51,11 @@ CAF_TEST(metaprogramming) { ...@@ -51,11 +51,11 @@ CAF_TEST(metaprogramming) {
using if3 = type_list<replies_to<int, double>::with<void>>; using if3 = type_list<replies_to<int, double>::with<void>>;
using if4 = type_list<replies_to<int>::with<skip_message_t>, using if4 = type_list<replies_to<int>::with<skip_message_t>,
replies_to<int, double>::with<void>>; replies_to<int, double>::with<void>>;
CAF_CHECK((ctm<if1, if2>::value) == -1); CAF_CHECK_EQUAL((ctm<if1, if2>::value), -1);
CAF_CHECK((ctm<if1, if3>::value) != -1); CAF_CHECK_NOT_EQUAL((ctm<if1, if3>::value), -1);
CAF_CHECK((ctm<if2, if3>::value) != -1); CAF_CHECK_NOT_EQUAL((ctm<if2, if3>::value), -1);
CAF_CHECK((ctm<if1, if4>::value) == -1); CAF_CHECK_EQUAL((ctm<if1, if4>::value), -1);
CAF_CHECK((ctm<if2, if4>::value) == -1); CAF_CHECK_EQUAL((ctm<if2, if4>::value), -1);
using l1 = type_list<int, float, std::string>; using l1 = type_list<int, float, std::string>;
using r1 = tl_reverse<l1>::type; using r1 = tl_reverse<l1>::type;
......
...@@ -274,7 +274,7 @@ CAF_TEST(pending_quit) { ...@@ -274,7 +274,7 @@ CAF_TEST(pending_quit) {
CAF_ERROR("received result, should've been terminated already"); CAF_ERROR("received result, should've been terminated already");
}, },
[](const error& err) { [](const error& err) {
CAF_CHECK(err == sec::request_receiver_down); CAF_CHECK_EQUAL(err, sec::request_receiver_down);
} }
); );
self->quit(); self->quit();
...@@ -319,7 +319,7 @@ CAF_TEST(request_float_or_int) { ...@@ -319,7 +319,7 @@ CAF_TEST(request_float_or_int) {
}, },
[&](const error& err) { [&](const error& err) {
CAF_MESSAGE("error received"); CAF_MESSAGE("error received");
CAF_CHECK(err == sec::unexpected_response); CAF_CHECK_EQUAL(err, sec::unexpected_response);
error_handler_called = true; error_handler_called = true;
} }
); );
...@@ -391,7 +391,7 @@ CAF_TEST(client_server_worker_user_case) { ...@@ -391,7 +391,7 @@ CAF_TEST(client_server_worker_user_case) {
self->request(serv, infinite, request_atom::value).receive( self->request(serv, infinite, request_atom::value).receive(
[&](response_atom) { [&](response_atom) {
CAF_MESSAGE("received 'response'"); CAF_MESSAGE("received 'response'");
CAF_CHECK(self->current_sender() == work); CAF_CHECK_EQUAL(self->current_sender(), work.address());
}, },
[&](const error& err) { [&](const error& err) {
CAF_ERROR("error: " << self->system().render(err)); CAF_ERROR("error: " << self->system().render(err));
...@@ -402,7 +402,7 @@ CAF_TEST(client_server_worker_user_case) { ...@@ -402,7 +402,7 @@ CAF_TEST(client_server_worker_user_case) {
send_as(work, serv, idle_atom::value, work); send_as(work, serv, idle_atom::value, work);
handle.receive( handle.receive(
[&](response_atom) { [&](response_atom) {
CAF_CHECK(self->current_sender() == work); CAF_CHECK_EQUAL(self->current_sender(), work.address());
}, },
[&](const error& err) { [&](const error& err) {
CAF_ERROR("error: " << self->system().render(err)); CAF_ERROR("error: " << self->system().render(err));
......
...@@ -84,14 +84,14 @@ CAF_TEST(identity) { ...@@ -84,14 +84,14 @@ CAF_TEST(identity) {
actor_system system_of_f; actor_system system_of_f;
auto g = system_of_g.spawn(typed_first_stage); auto g = system_of_g.spawn(typed_first_stage);
auto f = system_of_f.spawn(typed_second_stage); auto f = system_of_f.spawn(typed_second_stage);
CAF_CHECK(system_of_g.registry().running() == 1); CAF_CHECK_EQUAL(system_of_g.registry().running(), 1u);
auto h = f * g; auto h = f * g;
CAF_CHECK(system_of_g.registry().running() == 1); CAF_CHECK_EQUAL(system_of_g.registry().running(), 1u);
CAF_CHECK(&h->home_system() == &g->home_system()); CAF_CHECK_EQUAL(&h->home_system(), &g->home_system());
CAF_CHECK(h->node() == g->node()); CAF_CHECK_EQUAL(h->node(), g->node());
CAF_CHECK(h->id() != g->id()); CAF_CHECK_NOT_EQUAL(h->id(), g->id());
CAF_CHECK(h != g); CAF_CHECK_NOT_EQUAL(h.address(), g.address());
CAF_CHECK(h->message_types() == g->home_system().message_types(h)); CAF_CHECK_EQUAL(h->message_types(), g->home_system().message_types(h));
anon_send_exit(f, exit_reason::kill); anon_send_exit(f, exit_reason::kill);
anon_send_exit(g, exit_reason::kill); anon_send_exit(g, exit_reason::kill);
// killing both f and g triggers down messages to h, // killing both f and g triggers down messages to h,
...@@ -160,7 +160,7 @@ CAF_TEST(lifetime_3) { ...@@ -160,7 +160,7 @@ CAF_TEST(lifetime_3) {
wait_until_exited(); wait_until_exited();
self->request(f, infinite, 1).receive( self->request(f, infinite, 1).receive(
[](int v) { [](int v) {
CAF_CHECK(v == 2); CAF_CHECK_EQUAL(v, 2);
}, },
[](error) { [](error) {
CAF_CHECK(false); CAF_CHECK(false);
...@@ -168,7 +168,7 @@ CAF_TEST(lifetime_3) { ...@@ -168,7 +168,7 @@ CAF_TEST(lifetime_3) {
); );
self->request(g, infinite, 1).receive( self->request(g, infinite, 1).receive(
[](int v) { [](int v) {
CAF_CHECK(v == 2); CAF_CHECK_EQUAL(v, 2);
}, },
[](error) { [](error) {
CAF_CHECK(false); CAF_CHECK(false);
...@@ -189,7 +189,7 @@ CAF_TEST(request_response_promise) { ...@@ -189,7 +189,7 @@ CAF_TEST(request_response_promise) {
CAF_CHECK(false); CAF_CHECK(false);
}, },
[](error err) { [](error err) {
CAF_CHECK(err.code() == static_cast<uint8_t>(sec::request_receiver_down)); CAF_CHECK_EQUAL(err.code(), static_cast<uint8_t>(sec::request_receiver_down));
} }
); );
anon_send_exit(f, exit_reason::kill); anon_send_exit(f, exit_reason::kill);
...@@ -203,7 +203,7 @@ CAF_TEST(dot_composition_1) { ...@@ -203,7 +203,7 @@ CAF_TEST(dot_composition_1) {
auto first_then_second = second * first; auto first_then_second = second * first;
self->request(first_then_second, infinite, 42).receive( self->request(first_then_second, infinite, 42).receive(
[](double res) { [](double res) {
CAF_CHECK(res == (42 * 2.0) * (42 * 4.0)); CAF_CHECK_EQUAL(res, (42 * 2.0) * (42 * 4.0));
} }
); );
anon_send_exit(first, exit_reason::kill); anon_send_exit(first, exit_reason::kill);
...@@ -217,7 +217,7 @@ CAF_TEST(dot_composition_2) { ...@@ -217,7 +217,7 @@ CAF_TEST(dot_composition_2) {
* dbl_actor * dbl_actor; * dbl_actor * dbl_actor;
self->request(dbl_x4_actor, infinite, 1).receive( self->request(dbl_x4_actor, infinite, 1).receive(
[](int v) { [](int v) {
CAF_CHECK(v == 16); CAF_CHECK_EQUAL(v, 16);
}, },
[](error) { [](error) {
CAF_CHECK(false); CAF_CHECK(false);
......
...@@ -119,9 +119,6 @@ struct test_empty_non_pod { ...@@ -119,9 +119,6 @@ struct test_empty_non_pod {
virtual ~test_empty_non_pod() { virtual ~test_empty_non_pod() {
// nop // nop
} }
bool operator==(const test_empty_non_pod&) const {
return false;
}
}; };
template <class Processor> template <class Processor>
...@@ -271,7 +268,7 @@ CAF_TEST(enum_classes) { ...@@ -271,7 +268,7 @@ CAF_TEST(enum_classes) {
auto buf = serialize(te); auto buf = serialize(te);
test_enum x; test_enum x;
deserialize(buf, x); deserialize(buf, x);
CAF_CHECK(te == x); CAF_CHECK_EQUAL(te, x);
} }
CAF_TEST(strings) { CAF_TEST(strings) {
...@@ -285,16 +282,16 @@ CAF_TEST(custom_struct) { ...@@ -285,16 +282,16 @@ CAF_TEST(custom_struct) {
auto buf = serialize(rs); auto buf = serialize(rs);
raw_struct x; raw_struct x;
deserialize(buf, x); deserialize(buf, x);
CAF_CHECK(rs == x); CAF_CHECK_EQUAL(rs, x);
} }
CAF_TEST(atoms) { CAF_TEST(atoms) {
auto foo = atom("foo"); auto foo = atom("foo");
CAF_CHECK(foo == roundtrip(foo)); CAF_CHECK_EQUAL(foo, roundtrip(foo));
CAF_CHECK(foo == msg_roundtrip(foo)); CAF_CHECK_EQUAL(foo, msg_roundtrip(foo));
using bar_atom = atom_constant<atom("bar")>; using bar_atom = atom_constant<atom("bar")>;
CAF_CHECK(bar_atom::value == roundtrip(atom("bar"))); CAF_CHECK_EQUAL(bar_atom::value, roundtrip(atom("bar")));
CAF_CHECK(bar_atom::value == msg_roundtrip(atom("bar"))); CAF_CHECK_EQUAL(bar_atom::value, msg_roundtrip(atom("bar")));
} }
CAF_TEST(raw_arrays) { CAF_TEST(raw_arrays) {
...@@ -302,7 +299,7 @@ CAF_TEST(raw_arrays) { ...@@ -302,7 +299,7 @@ CAF_TEST(raw_arrays) {
int x[3]; int x[3];
deserialize(buf, x); deserialize(buf, x);
for (auto i = 0; i < 3; ++i) for (auto i = 0; i < 3; ++i)
CAF_CHECK(ra[i] == x[i]); CAF_CHECK_EQUAL(ra[i], x[i]);
} }
CAF_TEST(arrays) { CAF_TEST(arrays) {
...@@ -310,10 +307,10 @@ CAF_TEST(arrays) { ...@@ -310,10 +307,10 @@ CAF_TEST(arrays) {
test_array x; test_array x;
deserialize(buf, x); deserialize(buf, x);
for (auto i = 0; i < 4; ++i) for (auto i = 0; i < 4; ++i)
CAF_CHECK(ta.value[i] == x.value[i]); CAF_CHECK_EQUAL(ta.value[i], x.value[i]);
for (auto i = 0; i < 2; ++i) for (auto i = 0; i < 2; ++i)
for (auto j = 0; j < 4; ++j) for (auto j = 0; j < 4; ++j)
CAF_CHECK(ta.value2[i][j] == x.value2[i][j]); CAF_CHECK_EQUAL(ta.value2[i][j], x.value2[i][j]);
} }
CAF_TEST(empty_non_pods) { CAF_TEST(empty_non_pods) {
...@@ -341,14 +338,14 @@ CAF_TEST(messages) { ...@@ -341,14 +338,14 @@ CAF_TEST(messages) {
message x; message x;
auto buf1 = serialize(msg); auto buf1 = serialize(msg);
deserialize(buf1, x); deserialize(buf1, x);
CAF_CHECK(to_string(msg) == to_string(x)); CAF_CHECK_EQUAL(to_string(msg), to_string(x));
CAF_CHECK(is_message(x).equal(i32, te, str, rs)); CAF_CHECK(is_message(x).equal(i32, te, str, rs));
// serialize fully dynamic message again (do another roundtrip) // serialize fully dynamic message again (do another roundtrip)
message y; message y;
auto buf2 = serialize(x); auto buf2 = serialize(x);
CAF_CHECK(buf1 == buf2); CAF_CHECK_EQUAL(buf1, buf2);
deserialize(buf2, y); deserialize(buf2, y);
CAF_CHECK(to_string(msg) == to_string(y)); CAF_CHECK_EQUAL(to_string(msg), to_string(y));
CAF_CHECK(is_message(y).equal(i32, te, str, rs)); CAF_CHECK(is_message(y).equal(i32, te, str, rs));
} }
...@@ -361,12 +358,12 @@ CAF_TEST(actor_addr_via_message) { ...@@ -361,12 +358,12 @@ CAF_TEST(actor_addr_via_message) {
// deserialize into a message which uses message builder // deserialize into a message which uses message builder
message x; message x;
deserialize(serialize(addr_msg), x); deserialize(serialize(addr_msg), x);
CAF_CHECK(to_string(addr_msg) == to_string(x)); CAF_CHECK_EQUAL(to_string(addr_msg), to_string(x));
CAF_CHECK(is_message(x).equal(addr)); CAF_CHECK(is_message(x).equal(addr));
// serialize fully dynamic message again (do another roundtrip) // serialize fully dynamic message again (do another roundtrip)
message y; message y;
deserialize(serialize(x), y); deserialize(serialize(x), y);
CAF_CHECK(to_string(addr_msg) == to_string(y)); CAF_CHECK_EQUAL(to_string(addr_msg), to_string(y));
CAF_CHECK(is_message(y).equal(addr)); CAF_CHECK(is_message(y).equal(addr));
} }
*/ */
...@@ -389,7 +386,7 @@ CAF_TEST(type_erased_value) { ...@@ -389,7 +386,7 @@ CAF_TEST(type_erased_value) {
type_erased_value_ptr ptr{new type_erased_value_impl<std::string>}; type_erased_value_ptr ptr{new type_erased_value_impl<std::string>};
binary_deserializer bd{&context, buf.data(), buf.size()}; binary_deserializer bd{&context, buf.data(), buf.size()};
ptr->load(bd); ptr->load(bd);
CAF_CHECK(str == *reinterpret_cast<const std::string*>(ptr->get())); CAF_CHECK_EQUAL(str, *reinterpret_cast<const std::string*>(ptr->get()));
} }
CAF_TEST(type_erased_view) { CAF_TEST(type_erased_view) {
...@@ -397,21 +394,21 @@ CAF_TEST(type_erased_view) { ...@@ -397,21 +394,21 @@ CAF_TEST(type_erased_view) {
auto buf = serialize(str_view); auto buf = serialize(str_view);
std::string res; std::string res;
deserialize(buf, res); deserialize(buf, res);
CAF_CHECK(str == res); CAF_CHECK_EQUAL(str, res);
} }
CAF_TEST(type_erased_tuple) { CAF_TEST(type_erased_tuple) {
auto tview = make_type_erased_tuple_view(str, i32); auto tview = make_type_erased_tuple_view(str, i32);
CAF_CHECK(to_string(tview) == deep_to_string(std::make_tuple(str, i32))); CAF_CHECK_EQUAL(to_string(tview), deep_to_string(std::make_tuple(str, i32)));
auto buf = serialize(tview); auto buf = serialize(tview);
CAF_REQUIRE(buf.size() > 0); CAF_REQUIRE(buf.size() > 0);
std::string tmp1; std::string tmp1;
int32_t tmp2; int32_t tmp2;
deserialize(buf, tmp1, tmp2); deserialize(buf, tmp1, tmp2);
CAF_CHECK(tmp1 == str); CAF_CHECK_EQUAL(tmp1, str);
CAF_CHECK(tmp2 == i32); CAF_CHECK_EQUAL(tmp2, i32);
deserialize(buf, tview); deserialize(buf, tview);
CAF_CHECK(to_string(tview) == deep_to_string(std::make_tuple(str, i32))); CAF_CHECK_EQUAL(to_string(tview), deep_to_string(std::make_tuple(str, i32)));
} }
CAF_TEST_FIXTURE_SCOPE_END() CAF_TEST_FIXTURE_SCOPE_END()
...@@ -89,9 +89,9 @@ CAF_TEST_FIXTURE_SCOPE(sequencer_tests, fixture) ...@@ -89,9 +89,9 @@ CAF_TEST_FIXTURE_SCOPE(sequencer_tests, fixture)
CAF_TEST(identity) { CAF_TEST(identity) {
init_untyped(); init_untyped();
CAF_CHECK(first != second); CAF_CHECK_NOT_EQUAL(first, second);
CAF_CHECK(first != first_and_second); CAF_CHECK_NOT_EQUAL(first, first_and_second);
CAF_CHECK(second != first_and_second); CAF_CHECK_NOT_EQUAL(second, first_and_second);
} }
CAF_TEST(kill_first) { CAF_TEST(kill_first) {
...@@ -110,9 +110,9 @@ CAF_TEST(untyped_splicing) { ...@@ -110,9 +110,9 @@ CAF_TEST(untyped_splicing) {
init_untyped(); init_untyped();
self->request(first_and_second, infinite, 42.0).receive( self->request(first_and_second, infinite, 42.0).receive(
[](double x, double y, double z) { [](double x, double y, double z) {
CAF_CHECK(x == (42.0 * 2.0)); CAF_CHECK_EQUAL(x, (42.0 * 2.0));
CAF_CHECK(y == (42.0 * 4.0)); CAF_CHECK_EQUAL(y, (42.0 * 4.0));
CAF_CHECK(z == (23.0 * 42.0)); CAF_CHECK_EQUAL(z, (23.0 * 42.0));
} }
); );
} }
...@@ -128,9 +128,9 @@ CAF_TEST(typed_splicing) { ...@@ -128,9 +128,9 @@ CAF_TEST(typed_splicing) {
"splice() did not compute the correct result"); "splice() did not compute the correct result");
self->request(x_and_y, infinite, 42.0).receive( self->request(x_and_y, infinite, 42.0).receive(
[](double x, double y, double z) { [](double x, double y, double z) {
CAF_CHECK(x == (42.0 * 2.0)); CAF_CHECK_EQUAL(x, (42.0 * 2.0));
CAF_CHECK(y == (42.0 * 4.0)); CAF_CHECK_EQUAL(y, (42.0 * 4.0));
CAF_CHECK(z == (23.0 * 42.0)); CAF_CHECK_EQUAL(z, (23.0 * 42.0));
} }
); );
anon_send_exit(x, exit_reason::kill); anon_send_exit(x, exit_reason::kill);
......
...@@ -424,7 +424,7 @@ CAF_TEST(string_delegator_chain) { ...@@ -424,7 +424,7 @@ CAF_TEST(string_delegator_chain) {
system.spawn(string_reverter), system.spawn(string_reverter),
true); true);
set<string> iface{"caf::replies_to<@str>::with<@str>"}; set<string> iface{"caf::replies_to<@str>::with<@str>"};
CAF_CHECK(aut->message_types() == iface); CAF_CHECK_EQUAL(aut->message_types(), iface);
self->request(aut, infinite, "Hello World!").receive( self->request(aut, infinite, "Hello World!").receive(
[](const string& answer) { [](const string& answer) {
CAF_CHECK_EQUAL(answer, "!dlroW olleH"); CAF_CHECK_EQUAL(answer, "!dlroW olleH");
...@@ -444,7 +444,7 @@ CAF_TEST(maybe_string_delegator_chain) { ...@@ -444,7 +444,7 @@ CAF_TEST(maybe_string_delegator_chain) {
throw std::logic_error("unexpected result!"); throw std::logic_error("unexpected result!");
}, },
[](const error& err) { [](const error& err) {
CAF_CHECK(err.category() == atom("mock")); CAF_CHECK_EQUAL(err.category(), atom("mock"));
CAF_CHECK_EQUAL(err.code(), CAF_CHECK_EQUAL(err.code(),
static_cast<uint8_t>(mock_errc::cannot_revert_empty)); static_cast<uint8_t>(mock_errc::cannot_revert_empty));
} }
......
...@@ -306,8 +306,8 @@ public: ...@@ -306,8 +306,8 @@ public:
// routing table upon receiving client handshakes // routing table upon receiving client handshakes
auto path = tbl().lookup(remote_node(i)); auto path = tbl().lookup(remote_node(i));
CAF_REQUIRE(path); CAF_REQUIRE(path);
CAF_CHECK(path->hdl == remote_hdl(i)); CAF_CHECK_EQUAL(path->hdl, remote_hdl(i));
CAF_CHECK(path->next_hop == remote_node(i)); CAF_CHECK_EQUAL(path->next_hop, remote_node(i));
} }
std::pair<basp::header, buffer> read_from_out_buf(connection_handle hdl) { std::pair<basp::header, buffer> read_from_out_buf(connection_handle hdl) {
...@@ -476,7 +476,7 @@ CAF_TEST(non_empty_server_handshake) { ...@@ -476,7 +476,7 @@ CAF_TEST(non_empty_server_handshake) {
self()->id(), invalid_actor_id}; self()->id(), invalid_actor_id};
to_buf(expected_buf, expected, nullptr, to_buf(expected_buf, expected, nullptr,
self()->id(), set<string>{"caf::replies_to<@u16>::with<@u16>"}); self()->id(), set<string>{"caf::replies_to<@u16>::with<@u16>"});
CAF_CHECK(hexstr(buf) == hexstr(expected_buf)); CAF_CHECK_EQUAL(hexstr(buf), hexstr(expected_buf));
} }
CAF_TEST(remote_address_and_port) { CAF_TEST(remote_address_and_port) {
...@@ -491,10 +491,10 @@ CAF_TEST(remote_address_and_port) { ...@@ -491,10 +491,10 @@ CAF_TEST(remote_address_and_port) {
CAF_MESSAGE("receive result of MM"); CAF_MESSAGE("receive result of MM");
self()->receive( self()->receive(
[&](const node_id& nid, const std::string& addr, uint16_t port) { [&](const node_id& nid, const std::string& addr, uint16_t port) {
CAF_CHECK(nid == remote_node(1)); CAF_CHECK_EQUAL(nid, remote_node(1));
// all test nodes have address "test" and connection handle ID as port // all test nodes have address "test" and connection handle ID as port
CAF_CHECK(addr == "test"); CAF_CHECK_EQUAL(addr, "test");
CAF_CHECK(port == remote_hdl(1).id()); CAF_CHECK_EQUAL(port, remote_hdl(1).id());
} }
); );
} }
...@@ -517,9 +517,9 @@ CAF_TEST(client_handshake_and_dispatch) { ...@@ -517,9 +517,9 @@ CAF_TEST(client_handshake_and_dispatch) {
// receive the message // receive the message
self()->receive( self()->receive(
[](int a, int b, int c) { [](int a, int b, int c) {
CAF_CHECK(a == 1); CAF_CHECK_EQUAL(a, 1);
CAF_CHECK(b == 2); CAF_CHECK_EQUAL(b, 2);
CAF_CHECK(c == 3); CAF_CHECK_EQUAL(c, 3);
return a + b + c; return a + b + c;
} }
); );
...@@ -528,7 +528,7 @@ CAF_TEST(client_handshake_and_dispatch) { ...@@ -528,7 +528,7 @@ CAF_TEST(client_handshake_and_dispatch) {
dispatch_out_buf(remote_hdl(0)); // deserialize and send message from out buf dispatch_out_buf(remote_hdl(0)); // deserialize and send message from out buf
pseudo_remote(0)->receive( pseudo_remote(0)->receive(
[](int i) { [](int i) {
CAF_CHECK(i == 6); CAF_CHECK_EQUAL(i, 6);
} }
); );
} }
...@@ -603,10 +603,10 @@ CAF_TEST(remote_actor_and_send) { ...@@ -603,10 +603,10 @@ CAF_TEST(remote_actor_and_send) {
CAF_REQUIRE(res); CAF_REQUIRE(res);
auto aptr = actor_cast<abstract_actor*>(res); auto aptr = actor_cast<abstract_actor*>(res);
CAF_REQUIRE(dynamic_cast<forwarding_actor_proxy*>(aptr) != nullptr); CAF_REQUIRE(dynamic_cast<forwarding_actor_proxy*>(aptr) != nullptr);
CAF_CHECK(proxies().count_proxies(remote_node(0)) == 1); CAF_CHECK_EQUAL(proxies().count_proxies(remote_node(0)), 1u);
CAF_CHECK(nid == remote_node(0)); CAF_CHECK_EQUAL(nid, remote_node(0));
CAF_CHECK(res->node() == remote_node(0)); CAF_CHECK_EQUAL(res->node(), remote_node(0));
CAF_CHECK(res->id() == pseudo_remote(0)->id()); CAF_CHECK_EQUAL(res->id(), pseudo_remote(0)->id());
CAF_CHECK(ifs.empty()); CAF_CHECK(ifs.empty());
auto proxy = proxies().get(remote_node(0), pseudo_remote(0)->id()); auto proxy = proxies().get(remote_node(0), pseudo_remote(0)->id());
CAF_REQUIRE(proxy != nullptr); CAF_REQUIRE(proxy != nullptr);
...@@ -635,9 +635,9 @@ CAF_TEST(remote_actor_and_send) { ...@@ -635,9 +635,9 @@ CAF_TEST(remote_actor_and_send) {
make_message("hi there!")); make_message("hi there!"));
self()->receive( self()->receive(
[&](const string& str) { [&](const string& str) {
CAF_CHECK(to_string(self()->current_sender()) == to_string(result)); CAF_CHECK_EQUAL(to_string(self()->current_sender()), to_string(result));
CAF_CHECK(self()->current_sender() == result); CAF_CHECK_EQUAL(self()->current_sender(), result.address());
CAF_CHECK(str == "hi there!"); CAF_CHECK_EQUAL(str, "hi there!");
} }
); );
} }
...@@ -658,8 +658,8 @@ CAF_TEST(actor_serialize_and_deserialize) { ...@@ -658,8 +658,8 @@ CAF_TEST(actor_serialize_and_deserialize) {
basp::message_type::announce_proxy_instance, uint32_t{0}, uint64_t{0}, basp::message_type::announce_proxy_instance, uint32_t{0}, uint64_t{0},
this_node(), prx->node(), this_node(), prx->node(),
invalid_actor_id, prx->id()); invalid_actor_id, prx->id());
CAF_CHECK(prx->node() == remote_node(0)); CAF_CHECK_EQUAL(prx->node(), remote_node(0));
CAF_CHECK(prx->id() == pseudo_remote(0)->id()); CAF_CHECK_EQUAL(prx->id(), pseudo_remote(0)->id());
auto testee = system.spawn(testee_impl); auto testee = system.spawn(testee_impl);
registry()->put(testee->id(), actor_cast<strong_actor_ptr>(testee)); registry()->put(testee->id(), actor_cast<strong_actor_ptr>(testee));
CAF_MESSAGE("send message via BASP (from proxy)"); CAF_MESSAGE("send message via BASP (from proxy)");
...@@ -718,7 +718,7 @@ CAF_TEST(indirect_connections) { ...@@ -718,7 +718,7 @@ CAF_TEST(indirect_connections) {
CAF_MESSAGE("receive message from jupiter"); CAF_MESSAGE("receive message from jupiter");
self()->receive( self()->receive(
[](const std::string& str) -> std::string { [](const std::string& str) -> std::string {
CAF_CHECK(str == "hello from jupiter!"); CAF_CHECK_EQUAL(str, "hello from jupiter!");
return "hello from earth!"; return "hello from earth!";
} }
); );
...@@ -745,7 +745,8 @@ CAF_TEST(automatic_connection) { ...@@ -745,7 +745,8 @@ CAF_TEST(automatic_connection) {
// (this node receives a message from jupiter via mars and responds via mars, // (this node receives a message from jupiter via mars and responds via mars,
// but then also establishes a connection to jupiter directly) // but then also establishes a connection to jupiter directly)
mpx()->provide_scribe("jupiter", 8080, remote_hdl(0)); mpx()->provide_scribe("jupiter", 8080, remote_hdl(0));
CAF_CHECK(mpx()->pending_scribes().count(make_pair("jupiter", 8080)) == 1); CAF_CHECK_EQUAL(mpx()->pending_scribes().count(make_pair("jupiter", 8080)),
1u);
CAF_MESSAGE("self: " << to_string(self()->address())); CAF_MESSAGE("self: " << to_string(self()->address()));
auto ax = accept_handle::from_int(4242); auto ax = accept_handle::from_int(4242);
mpx()->provide_acceptor(4242, ax); mpx()->provide_acceptor(4242, ax);
...@@ -820,7 +821,7 @@ CAF_TEST(automatic_connection) { ...@@ -820,7 +821,7 @@ CAF_TEST(automatic_connection) {
CAF_MESSAGE("receive message from jupiter"); CAF_MESSAGE("receive message from jupiter");
self()->receive( self()->receive(
[](const std::string& str) -> std::string { [](const std::string& str) -> std::string {
CAF_CHECK(str == "hello from jupiter!"); CAF_CHECK_EQUAL(str, "hello from jupiter!");
return "hello from earth!"; return "hello from earth!";
} }
); );
...@@ -833,7 +834,7 @@ CAF_TEST(automatic_connection) { ...@@ -833,7 +834,7 @@ CAF_TEST(automatic_connection) {
self()->id(), pseudo_remote(0)->id(), self()->id(), pseudo_remote(0)->id(),
std::vector<actor_id>{}, std::vector<actor_id>{},
make_message("hello from earth!")); make_message("hello from earth!"));
CAF_CHECK(mpx()->output_buffer(remote_hdl(1)).size() == 0); CAF_CHECK_EQUAL(mpx()->output_buffer(remote_hdl(1)).size(), 0u);
} }
CAF_TEST_FIXTURE_SCOPE_END() CAF_TEST_FIXTURE_SCOPE_END()
...@@ -130,7 +130,8 @@ CAF_TEST(identity_semantics) { ...@@ -130,7 +130,8 @@ CAF_TEST(identity_semantics) {
// client side // client side
auto server1 = client_side_mm.remote_actor(local_host, port1); auto server1 = client_side_mm.remote_actor(local_host, port1);
auto server2 = client_side_mm.remote_actor(local_host, port2); auto server2 = client_side_mm.remote_actor(local_host, port2);
CAF_CHECK(server1 && server2); CAF_REQUIRE(server1);
CAF_REQUIRE(server2);
CAF_CHECK_EQUAL(server1, client_side_mm.remote_actor(local_host, port1)); CAF_CHECK_EQUAL(server1, client_side_mm.remote_actor(local_host, port1));
CAF_CHECK_EQUAL(server2, client_side_mm.remote_actor(local_host, port2)); CAF_CHECK_EQUAL(server2, client_side_mm.remote_actor(local_host, port2));
// cleanup // cleanup
......
...@@ -80,8 +80,9 @@ behavior server(stateful_actor<server_state>* self) { ...@@ -80,8 +80,9 @@ behavior server(stateful_actor<server_state>* self) {
self->send(self->state.aut, "hello mirror"); self->send(self->state.aut, "hello mirror");
self->become( self->become(
[=](const std::string& str) { [=](const std::string& str) {
CAF_CHECK(self->current_sender() == self->state.aut); CAF_CHECK_EQUAL(self->current_sender(),
CAF_CHECK(str == "hello mirror"); self->state.aut.address());
CAF_CHECK_EQUAL(str, "hello mirror");
self->send_exit(self->state.aut, exit_reason::kill); self->send_exit(self->state.aut, exit_reason::kill);
self->send_exit(self->state.client, exit_reason::kill); self->send_exit(self->state.client, exit_reason::kill);
self->quit(); self->quit();
......
...@@ -100,7 +100,7 @@ void run_client(int argc, char** argv, uint16_t port) { ...@@ -100,7 +100,7 @@ void run_client(int argc, char** argv, uint16_t port) {
self->monitor(serv); self->monitor(serv);
self->receive([&](const down_msg& dm) { self->receive([&](const down_msg& dm) {
CAF_CHECK_EQUAL(dm.reason, exit_reason::user_shutdown); CAF_CHECK_EQUAL(dm.reason, exit_reason::user_shutdown);
CAF_CHECK(dm.source == serv); CAF_CHECK_EQUAL(dm.source, serv.address());
}); });
} }
......
...@@ -106,14 +106,14 @@ CAF_TEST(unpublishing) { ...@@ -106,14 +106,14 @@ CAF_TEST(unpublishing) {
auto testee2 = system.spawn<dummy>(); auto testee2 = system.spawn<dummy>();
system.middleman().unpublish(testee2, port); system.middleman().unpublish(testee2, port);
auto x0 = remote_actor("127.0.0.1", port); auto x0 = remote_actor("127.0.0.1", port);
CAF_CHECK(x0 != testee2); CAF_CHECK_NOT_EQUAL(x0, testee2);
CAF_CHECK(x0 == testee); CAF_CHECK_EQUAL(x0, testee);
anon_send_exit(testee2, exit_reason::kill); anon_send_exit(testee2, exit_reason::kill);
CAF_MESSAGE("unpublish testee"); CAF_MESSAGE("unpublish testee");
system.middleman().unpublish(testee, port); system.middleman().unpublish(testee, port);
CAF_MESSAGE("check whether testee is still available via cache"); CAF_MESSAGE("check whether testee is still available via cache");
auto x1 = remote_actor("127.0.0.1", port); auto x1 = remote_actor("127.0.0.1", port);
CAF_CHECK(x1 == testee); CAF_CHECK_EQUAL(x1, testee);
CAF_MESSAGE("fake dead of testee and check if testee becomes unavailable"); CAF_MESSAGE("fake dead of testee and check if testee becomes unavailable");
anon_send(system.middleman().actor_handle(), down_msg{testee.address(), anon_send(system.middleman().actor_handle(), down_msg{testee.address(),
exit_reason::normal}); exit_reason::normal});
......
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