From 6d5b4c162a2564fcd67f9b5cd5be4ed22a3dc575 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 20 Oct 2018 14:31:38 -0700 Subject: Updated core; updated smart pointer test --- Tests/TestApp/include/SmartPointerTest.h | 14 ++++++++++++-- Tests/TestApp/src/SmartPointerTest.cpp | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'Tests/TestApp') diff --git a/Tests/TestApp/include/SmartPointerTest.h b/Tests/TestApp/include/SmartPointerTest.h index f205246..9b2073e 100644 --- a/Tests/TestApp/include/SmartPointerTest.h +++ b/Tests/TestApp/include/SmartPointerTest.h @@ -58,6 +58,16 @@ public: int m_Value; }; + class DerivedObject : public Object + { + public: + DerivedObject(Diligent::IReferenceCounters *pRefCounters) : + Object(pRefCounters), + m_Value2(1) + {} + int m_Value2; + }; + typedef Diligent::RefCntAutoPtr SmartPtr; typedef Diligent::RefCntWeakPtr WeakPtr; @@ -76,9 +86,9 @@ public: bool m_bStopThreads = false; int m_NumTestsPerformed = 0; #ifdef _DEBUG - static const int NumThreadInterations = 20; + static const int NumThreadInterations = 5; #else - static const int NumThreadInterations = 50; + static const int NumThreadInterations = 10; #endif std::mutex m_Mtx; std::condition_variable m_CondVar; diff --git a/Tests/TestApp/src/SmartPointerTest.cpp b/Tests/TestApp/src/SmartPointerTest.cpp index 27a73fb..6a049ff 100644 --- a/Tests/TestApp/src/SmartPointerTest.cpp +++ b/Tests/TestApp/src/SmartPointerTest.cpp @@ -298,7 +298,14 @@ SmartPointerTest::SmartPointerTest() : SmartPtr SP3(SP0); SmartPtr SP4(SP2); SmartPtr SP5(std::move(SP3)); + VERIFY_EXPR(!SP3); SmartPtr SP6(std::move(SP4)); + VERIFY_EXPR(!SP4); + + RefCntAutoPtr DerivedSP(MakeNewObj()); + SmartPtr SP7(DerivedSP); + SmartPtr SP8(std::move(DerivedSP)); + VERIFY_EXPR(!DerivedSP); } // Test Attach/Detach @@ -370,10 +377,17 @@ SmartPointerTest::SmartPointerTest() : SP4 = SP3; SmartPtr SP5; SP5 = std::move(SP4); + VERIFY_EXPR(!SP4); SP1 = pRawPtr2; SP1 = nullptr; SP1 = std::move(SP5); + VERIFY_EXPR(!SP5); + + RefCntAutoPtr DerivedSP(MakeNewObj()); + SP1 = DerivedSP; + SP2 = std::move(DerivedSP); + VERIFY_EXPR(!DerivedSP); } // Test logical operators -- cgit v1.2.3