Commit 98f05215 authored by Dominik Charousset's avatar Dominik Charousset

Fix leak in `constructor_attach` unit test

parent d071989a
...@@ -34,11 +34,12 @@ using done_atom = atom_constant<atom("done")>; ...@@ -34,11 +34,12 @@ using done_atom = atom_constant<atom("done")>;
CAF_TEST(constructor_attach) { CAF_TEST(constructor_attach) {
class testee : public event_based_actor { class testee : public event_based_actor {
public: public:
explicit testee(actor buddy) : buddy_(buddy) { explicit testee(actor buddy) {
attach_functor([=](uint32_t reason) { attach_functor([=](uint32_t reason) {
send(buddy_, done_atom::value, reason); send(buddy, done_atom::value, reason);
}); });
} }
behavior make_behavior() { behavior make_behavior() {
return { return {
[=](die_atom) { [=](die_atom) {
...@@ -46,18 +47,19 @@ CAF_TEST(constructor_attach) { ...@@ -46,18 +47,19 @@ CAF_TEST(constructor_attach) {
} }
}; };
} }
private:
actor buddy_;
}; };
class spawner : public event_based_actor { class spawner : public event_based_actor {
public: public:
spawner() : downs_(0) { spawner() : downs_(0) {
// nop
} }
behavior make_behavior() { behavior make_behavior() {
testee_ = spawn<testee, monitored>(this); testee_ = spawn<testee, monitored>(this);
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_);
if (++downs_ == 2) { if (++downs_ == 2) {
quit(msg.reason); quit(msg.reason);
} }
...@@ -73,6 +75,11 @@ CAF_TEST(constructor_attach) { ...@@ -73,6 +75,11 @@ CAF_TEST(constructor_attach) {
} }
}; };
} }
void on_exit() {
testee_ = invalid_actor;
}
private: private:
int downs_; int downs_;
actor testee_; actor testee_;
......
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