From: David Steele Date: Wed, 29 Jul 2020 13:04:18 +0000 (+0100) Subject: Added test for assigning nullptr to IntrusivePtr X-Git-Tag: dali_1.9.23~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a1f6858c790d40741760a3b7dad28617cf79dd75;p=platform%2Fcore%2Fuifw%2Fdali-core.git Added test for assigning nullptr to IntrusivePtr Change-Id: Ice44376754d9aa686b8e3f724655dec85c74c6a1 --- diff --git a/automated-tests/src/dali/utc-Dali-IntrusivePtr.cpp b/automated-tests/src/dali/utc-Dali-IntrusivePtr.cpp index 3e9a403..8f057fe 100644 --- a/automated-tests/src/dali/utc-Dali-IntrusivePtr.cpp +++ b/automated-tests/src/dali/utc-Dali-IntrusivePtr.cpp @@ -529,6 +529,35 @@ int UtcDaliRefObjectAssignmentOperator(void) } DALI_TEST_EQUALS( testPtr->ReferenceCount(), 1, TEST_LOCATION ); } + + END_TEST; +} + + +int UtcDaliRefObjectAssignmentOperatorToNull(void) +{ + tet_infoline("Testing Dali::IntrusivePtr = nullptr"); + + g_creationCount = g_destructionCount = 0; + + IntrusivePtr counted( new Counted ); + + DALI_TEST_EQUALS( g_creationCount, 1u, TEST_LOCATION); + DALI_TEST_EQUALS( g_destructionCount, 0u, TEST_LOCATION); + + IntrusivePtr counted2 = counted; + DALI_TEST_EQUALS( g_creationCount, 1u, TEST_LOCATION); + DALI_TEST_EQUALS( g_destructionCount, 0u, TEST_LOCATION); + + DALI_TEST_EQUALS( counted->ReferenceCount(), 2, TEST_LOCATION); + + counted2 = nullptr; + DALI_TEST_EQUALS( g_destructionCount, 0u, TEST_LOCATION); + DALI_TEST_EQUALS( counted->ReferenceCount(), 1, TEST_LOCATION); + + counted = nullptr; + DALI_TEST_EQUALS( g_destructionCount, 1u, TEST_LOCATION); + END_TEST; }