diff --git a/src/Delegate/DelegateAsyncWait.h b/src/Delegate/DelegateAsyncWait.h index ac8d583..c559a60 100644 --- a/src/Delegate/DelegateAsyncWait.h +++ b/src/Delegate/DelegateAsyncWait.h @@ -366,7 +366,7 @@ class DelegateFreeAsyncWait : public DelegateFree msg) { + virtual bool Invoke(std::shared_ptr msg) override { static_assert(!(is_unique_ptr::value), "std::unique_ptr return value not allowed"); // Typecast the base pointer to back correct derived to instance @@ -769,7 +769,7 @@ class DelegateMemberAsyncWait : public DelegateMember< /// target function, the target function is not called. /// @param[in] msg The delegate message created and sent within `operator()(Args... args)`. /// @return `true` if target function invoked or timeout expired; `false` if error. - virtual bool Invoke(std::shared_ptr msg) { + virtual bool Invoke(std::shared_ptr msg) override { static_assert(!(is_unique_ptr::value), "std::unique_ptr return value not allowed"); // Typecast the base pointer to back correct derived to instance @@ -1091,7 +1091,7 @@ class DelegateFunctionAsyncWait : public DelegateFunction msg) { + virtual bool Invoke(std::shared_ptr msg) override { static_assert(!(is_unique_ptr::value), "std::unique_ptr return value not allowed"); // Typecast the base pointer to back correct derived to instance diff --git a/tests/UnitTests/DelegateAsyncWait_UT.cpp b/tests/UnitTests/DelegateAsyncWait_UT.cpp index b73263b..53b56a6 100644 --- a/tests/UnitTests/DelegateAsyncWait_UT.cpp +++ b/tests/UnitTests/DelegateAsyncWait_UT.cpp @@ -201,21 +201,6 @@ static void DelegateFreeAsyncWaitTests() for (int i = 0; i < 2; i++) arr[i](TEST_INT); delete[] arr; - - { - // Should never be called! - auto lambdaInt1 = [](int i) { ASSERT_TRUE(i == TEST_INT); }; - TestClass1 testClass1; - - // Invalid runtime. Add temporary objects to list should not work. Checks - // that delegate destructor sets delegate Empty() to help prevent misused. - std::list*> delList; - delList.push_back(&MakeDelegate(FreeFuncInt1, workerThread, WAIT_INFINITE)); - delList.push_back(&MakeDelegate(&testClass1, &TestClass1::MemberFuncInt1, workerThread, WAIT_INFINITE)); - delList.push_back(&MakeDelegate(std::function(lambdaInt1), workerThread, WAIT_INFINITE)); - for (auto& d : delList) - (*d)(0); // All invalid targets; no delegates called - } } static void DelegateMemberAsyncWaitTests() diff --git a/tests/UnitTests/DelegateAsync_UT.cpp b/tests/UnitTests/DelegateAsync_UT.cpp index b353e8c..c99a6a3 100644 --- a/tests/UnitTests/DelegateAsync_UT.cpp +++ b/tests/UnitTests/DelegateAsync_UT.cpp @@ -141,7 +141,7 @@ static void DelegateFreeAsyncTests() auto outgoingArg = MakeDelegate(&OutgoingPtrArg, workerThread); std::this_thread::sleep_for(std::chrono::milliseconds(500)); outgoingArg(&sparam, &iparam); - ASSERT_TRUE(sparam.val == TEST_INT); + ASSERT_TRUE(sparam.val == TEST_INT); ASSERT_TRUE(iparam == 100); // Test outgoing ptr-ptr argument @@ -200,21 +200,6 @@ static void DelegateFreeAsyncTests() for (int i = 0; i < 2; i++) arr[i](TEST_INT); delete[] arr; - - { - // Should never be called! - auto lambdaInt1 = [](int i) { ASSERT_TRUE(i == TEST_INT); }; - TestClass1 testClass1; - - // Invalid runtime. Add temporary objects to list should not work. Checks - // that delegate destructor sets delegate Empty() to help prevent misused. - std::list*> delList; - delList.push_back(&MakeDelegate(FreeFuncInt1, workerThread)); - delList.push_back(&MakeDelegate(&testClass1, &TestClass1::MemberFuncInt1, workerThread)); - delList.push_back(&MakeDelegate(std::function(lambdaInt1), workerThread)); - for (auto& d : delList) - (*d)(0); // All invalid targets; no delegates called - } } static void DelegateMemberAsyncTests() diff --git a/tests/UnitTests/Delegate_UT.cpp b/tests/UnitTests/Delegate_UT.cpp index 13e105e..96ced36 100644 --- a/tests/UnitTests/Delegate_UT.cpp +++ b/tests/UnitTests/Delegate_UT.cpp @@ -203,21 +203,6 @@ static void DelegateFreeTests() for (int i = 0; i < 2; i++) arr[i](TEST_INT); delete[] arr; - - { - // Should never be called! - auto lambdaInt1 = [](int i) { ASSERT_TRUE(i == TEST_INT); }; - TestClass1 testClass1; - - // Invalid runtime. Add temporary objects to list should not work. Checks - // that delegate destructor sets delegate Empty() to help prevent misused. - std::list*> delList; - delList.push_back(&MakeDelegate(FreeFuncInt1)); - delList.push_back(&MakeDelegate(&testClass1, &TestClass1::MemberFuncInt1)); - delList.push_back(&MakeDelegate(std::function(lambdaInt1))); - for (auto& d : delList) - (*d)(0); // All invalid targets; no delegates called - } } static void DelegateMemberTests()