diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/actor/actor.test.cpp | 22 | ||||
-rw-r--r-- | test/actor/actor_ref.test.cpp | 22 |
2 files changed, 44 insertions, 0 deletions
diff --git a/test/actor/actor.test.cpp b/test/actor/actor.test.cpp index 4c7fc3666d..967dc152d9 100644 --- a/test/actor/actor.test.cpp +++ b/test/actor/actor.test.cpp @@ -306,6 +306,28 @@ TEST(Actor, Ask) { ASSERT_EQ(2, result.get()); } +TEST(Actor, AskVoid) { + // Ask waits for void methods + + struct Test { + bool& executed; + + Test(bool& executed_) : executed(executed_) { + } + + void doIt() { + executed = true; + } + }; + + ThreadPool pool { 1 }; + bool executed = false; + Actor<Test> actor(pool, executed); + + actor.ask(&Test::doIt).get(); + EXPECT_TRUE(executed); +} + TEST(Actor, NoSelfActorRef) { // Not all actors need a reference to self diff --git a/test/actor/actor_ref.test.cpp b/test/actor/actor_ref.test.cpp index 52b0de295b..20aa1c35c1 100644 --- a/test/actor/actor_ref.test.cpp +++ b/test/actor/actor_ref.test.cpp @@ -62,6 +62,28 @@ TEST(ActorRef, Ask) { EXPECT_EQ(30, ref.ask(&Test::echo, 30).get()); } +TEST(ActorRef, AskVoid) { + // Ask waits for void methods + + struct Test { + bool& executed; + + Test(bool& executed_) : executed(executed_) { + } + + void doIt() { + executed = true; + } + }; + + ThreadPool pool { 1 }; + bool executed = false; + Actor<Test> actor(pool, executed); + ActorRef<Test> ref = actor.self(); + + ref.ask(&Test::doIt).get(); + EXPECT_TRUE(executed); +} TEST(ActorRef, AskOnDestroyedActor) { // Tests behavior when calling ask() after the |