diff --git a/tests/unittest/test_scopedremover.cpp b/tests/unittest/test_scopedremover.cpp index 2ca84ee..8a825ef 100644 --- a/tests/unittest/test_scopedremover.cpp +++ b/tests/unittest/test_scopedremover.cpp @@ -56,8 +56,9 @@ TEST_CASE("ScopedRemover, CallbackList") using CL = eventpp::CallbackList; CL callbackList; using Remover = eventpp::ScopedRemover; + Remover r4; - std::vector dataList(4); + std::vector dataList(5); callbackList.append([&dataList]() { ++dataList[0]; @@ -78,23 +79,33 @@ TEST_CASE("ScopedRemover, CallbackList") r3.insert([&dataList]() { ++dataList[3]; }, handle); + { + r4.setCallbackList(callbackList); + r4.append([&dataList]() { + ++dataList[4]; + }); - REQUIRE(dataList == std::vector { 0, 0, 0, 0 }); + REQUIRE(dataList == std::vector { 0, 0, 0, 0, 0 }); + + callbackList(); + REQUIRE(dataList == std::vector { 1, 1, 1, 1, 1 }); + r4.reset(); + } callbackList(); - REQUIRE(dataList == std::vector { 1, 1, 1, 1 }); + REQUIRE(dataList == std::vector { 2, 2, 2, 2, 1 }); } callbackList(); - REQUIRE(dataList == std::vector { 2, 2, 2, 1 }); + REQUIRE(dataList == std::vector { 3, 3, 3, 2, 1 }); } callbackList(); - REQUIRE(dataList == std::vector { 3, 3, 2, 1 }); + REQUIRE(dataList == std::vector { 4, 4, 3, 2, 1 }); } callbackList(); - REQUIRE(dataList == std::vector { 4, 3, 2, 1 }); + REQUIRE(dataList == std::vector { 5, 4, 3, 2, 1 }); } TEST_CASE("ScopedRemover, HeterEventDispatcher")