tests: code coverage
This commit is contained in:
@@ -12,24 +12,27 @@ TEST(Emitter, Clear) {
|
||||
test_emitter emitter;
|
||||
|
||||
ASSERT_TRUE(emitter.empty());
|
||||
ASSERT_TRUE(emitter.empty<quux_event>());
|
||||
|
||||
emitter.on<foo_event>([](const auto &, const auto &){});
|
||||
emitter.once<quux_event>([](const auto &, const auto &){});
|
||||
|
||||
ASSERT_FALSE(emitter.empty());
|
||||
ASSERT_FALSE(emitter.empty<foo_event>());
|
||||
ASSERT_FALSE(emitter.empty<quux_event>());
|
||||
ASSERT_TRUE(emitter.empty<bar_event>());
|
||||
|
||||
emitter.clear<bar_event>();
|
||||
|
||||
ASSERT_FALSE(emitter.empty());
|
||||
ASSERT_FALSE(emitter.empty<foo_event>());
|
||||
ASSERT_FALSE(emitter.empty<quux_event>());
|
||||
ASSERT_TRUE(emitter.empty<bar_event>());
|
||||
|
||||
emitter.clear<foo_event>();
|
||||
|
||||
ASSERT_TRUE(emitter.empty());
|
||||
ASSERT_FALSE(emitter.empty());
|
||||
ASSERT_TRUE(emitter.empty<foo_event>());
|
||||
ASSERT_FALSE(emitter.empty<quux_event>());
|
||||
ASSERT_TRUE(emitter.empty<bar_event>());
|
||||
|
||||
emitter.on<foo_event>([](const auto &, const auto &){});
|
||||
@@ -37,6 +40,7 @@ TEST(Emitter, Clear) {
|
||||
|
||||
ASSERT_FALSE(emitter.empty());
|
||||
ASSERT_FALSE(emitter.empty<foo_event>());
|
||||
ASSERT_FALSE(emitter.empty<quux_event>());
|
||||
ASSERT_FALSE(emitter.empty<bar_event>());
|
||||
|
||||
emitter.clear();
|
||||
@@ -48,19 +52,25 @@ TEST(Emitter, Clear) {
|
||||
|
||||
TEST(Emitter, ClearPublishing) {
|
||||
test_emitter emitter;
|
||||
bool invoked = false;
|
||||
|
||||
ASSERT_TRUE(emitter.empty());
|
||||
|
||||
emitter.on<bar_event>([&invoked](const auto &, auto &em){
|
||||
invoked = true;
|
||||
em.clear();
|
||||
emitter.once<foo_event>([](const auto &, auto &em){
|
||||
em.template once<foo_event>([](const auto &, auto &){});
|
||||
em.template clear<foo_event>();
|
||||
});
|
||||
|
||||
emitter.on<bar_event>([](const auto &, auto &em){
|
||||
em.template once<bar_event>([](const auto &, auto &){});
|
||||
em.template clear<bar_event>();
|
||||
});
|
||||
|
||||
ASSERT_FALSE(emitter.empty());
|
||||
|
||||
emitter.publish<foo_event>();
|
||||
emitter.publish<bar_event>();
|
||||
|
||||
ASSERT_TRUE(emitter.empty());
|
||||
ASSERT_TRUE(invoked);
|
||||
}
|
||||
|
||||
TEST(Emitter, On) {
|
||||
|
||||
Reference in New Issue
Block a user