Skip to content

Commit

Permalink
Add unit test for callback generated by the user.
Browse files Browse the repository at this point in the history
  • Loading branch information
geektoni authored and vigsterkr committed May 25, 2018
1 parent da950d5 commit 8d720dd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/unit/lib/StoppableSGObject_unittest.cc
Expand Up @@ -73,3 +73,24 @@ TEST(StoppableSGObject, custom_callback)
a.train();
EXPECT_TRUE(a.get_check() == 5);
}

TEST(StoppableSGObject, custom_callback_by_user)
{
int i=0;
function<bool()> callback = [&i]()
{
if (i>=3) {
get_global_signal()->get_subscriber()->on_next(SG_BLOCK_COMP);
return true;
}
i++;
return false;
};


Mock_model a;
a.add_callback(callback);
a.train();
EXPECT_TRUE(a.get_check() == 3);
}

0 comments on commit 8d720dd

Please sign in to comment.