Added test for assigning nullptr to IntrusivePtr 75/239775/2
authorDavid Steele <david.steele@samsung.com>
Wed, 29 Jul 2020 13:04:18 +0000 (14:04 +0100)
committerDavid Steele <david.steele@samsung.com>
Wed, 29 Jul 2020 14:17:08 +0000 (15:17 +0100)
Change-Id: Ice44376754d9aa686b8e3f724655dec85c74c6a1

automated-tests/src/dali/utc-Dali-IntrusivePtr.cpp

index 3e9a403..8f057fe 100644 (file)
@@ -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> counted( new Counted );
+
+  DALI_TEST_EQUALS( g_creationCount, 1u, TEST_LOCATION);
+  DALI_TEST_EQUALS( g_destructionCount, 0u, TEST_LOCATION);
+
+  IntrusivePtr<Counted> 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;
 }