77454af96e215355d1882f0921db852842b506de
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-IntrusivePtr.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <dali-test-suite-utils.h>
19 #include <dali/public-api/dali-core.h>
20 #include <stdlib.h>
21
22 #include <iostream>
23
24 using namespace Dali;
25
26 namespace
27 {
28 const int REPEAT = 1000;
29
30 size_t g_creationCount             = 0;
31 size_t g_destructionCount          = 0;
32 size_t g_creationCountSubclass     = 0;
33 size_t g_destructionCountSubclass  = 0;
34 size_t g_creationCountUnrelated    = 0;
35 size_t g_destructionCountUnrelated = 0;
36
37 class Counted : public RefObject
38 {
39 public:
40   Counted()
41   {
42     ++g_creationCount;
43   }
44   ~Counted()
45   {
46     ++g_destructionCount;
47   }
48 };
49
50 class CountedSubclass : public Counted
51 {
52 public:
53   CountedSubclass()
54   {
55     ++g_creationCountSubclass;
56   }
57   ~CountedSubclass()
58   {
59     ++g_destructionCountSubclass;
60   }
61 };
62
63 class UnrelatedCounted : public RefObject
64 {
65 public:
66   UnrelatedCounted()
67   {
68     ++g_creationCountUnrelated;
69   }
70   ~UnrelatedCounted()
71   {
72     ++g_destructionCountUnrelated;
73   }
74 };
75
76 class TestObject : public RefObject
77 {
78 public:
79   TestObject()
80   : data(201)
81   {
82   }
83
84   TestObject(const TestObject& testObject)
85   : RefObject(testObject),
86     data(testObject.data)
87   {
88   }
89
90   TestObject& Assign(const TestObject& testObject)
91   {
92     RefObject::operator=(testObject);
93     data               = testObject.data;
94     return *this;
95   }
96
97   int data;
98 };
99
100 } // Anonymous namespace
101
102 /**
103  * Test that a default constructed pointer is null and harmless.
104  */
105 int UtcDaliIntrusivePtrIntrusivePtr(void)
106 {
107   tet_infoline("Testing Dali::IntrusivePtr::IntrusivePtr()");
108
109   g_creationCount = g_destructionCount = 0;
110
111   IntrusivePtr<Counted> counted;
112   DALI_TEST_EQUALS(g_creationCount, 0u, TEST_LOCATION);
113   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
114   // Test the pointer is null
115   DALI_TEST_EQUALS(counted.Get(), (Counted*)0, TEST_LOCATION);
116   DALI_TEST_EQUALS(&(*counted), (Counted*)0, TEST_LOCATION);
117   // Check destruction of the null smart pointer does nothing:
118   counted = IntrusivePtr<Counted>();
119   DALI_TEST_EQUALS(g_creationCount, 0u, TEST_LOCATION);
120   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
121
122   END_TEST;
123 }
124
125 int UtcDaliIntrusivePtrIntrusivePtrTP(void)
126 {
127   tet_infoline("Testing Dali::IntrusivePtr::IntrusivePtr(T*)");
128
129   g_creationCount = g_destructionCount = 0;
130
131   IntrusivePtr<Counted> counted(new Counted);
132   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
133   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
134   counted = 0;
135   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
136   DALI_TEST_EQUALS(g_destructionCount, 1u, TEST_LOCATION);
137
138   END_TEST;
139 }
140
141 // Class is too simple for a negative case to be created: int UtcDaliIntrusiveIntrusivePtrTN(void)
142
143 int UtcDaliIntrusivePtrIntrusivePtrIntrusivePtrUP(void)
144 {
145   tet_infoline("Testing Dali::IntrusivePtr::IntrusivePtr(IntrusivePtr<U> const &)");
146
147   g_creationCount = g_destructionCount = g_creationCountSubclass = g_destructionCountSubclass = 0;
148
149   IntrusivePtr<CountedSubclass> countedSubclass(new CountedSubclass);
150   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
151   DALI_TEST_EQUALS(g_creationCountSubclass, 1u, TEST_LOCATION);
152   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
153   DALI_TEST_EQUALS(g_destructionCountSubclass, 0u, TEST_LOCATION);
154
155   IntrusivePtr<Counted> counted(countedSubclass);
156   DALI_TEST_EQUALS(counted->ReferenceCount(), 2, TEST_LOCATION);
157
158   // Make loads more references:
159   std::vector<IntrusivePtr<Counted> > intrusivePtrs;
160   for(int i = 0; i < REPEAT; ++i)
161   {
162     intrusivePtrs.push_back(IntrusivePtr<Counted>(countedSubclass));
163   }
164   DALI_TEST_EQUALS(counted->ReferenceCount(), 2 + REPEAT, TEST_LOCATION);
165
166   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
167   DALI_TEST_EQUALS(g_creationCountSubclass, 1u, TEST_LOCATION);
168   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
169
170   END_TEST;
171 }
172
173 // The negative version of this test would fail at compile time:
174 // int UtcDaliIntrusivePtrIntrusivePtrIntrusivePtrUN(void)
175
176 int UtcDaliIntrusivePtrIntrusivePtrIntrusivePtrP(void)
177 {
178   tet_infoline("Testing Dali::IntrusivePtr::IntrusivePtr(IntrusivePtr const &)");
179
180   // Pass a pointer to a constructed second object:
181   // Pass a pointer to null:
182
183   g_creationCount = g_destructionCount = 0;
184
185   IntrusivePtr<Counted> counted(new Counted);
186   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
187   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
188   DALI_TEST_EQUALS(counted->ReferenceCount(), 1, TEST_LOCATION);
189
190   IntrusivePtr<Counted> counted2(counted);
191   DALI_TEST_EQUALS(counted->ReferenceCount(), 2, TEST_LOCATION);
192   DALI_TEST_EQUALS(counted.Get(), counted2.Get(), TEST_LOCATION);
193
194   // Make loads more references:
195   std::vector<IntrusivePtr<Counted> > intrusivePtrs;
196   for(int i = 0; i < REPEAT; ++i)
197   {
198     intrusivePtrs.push_back(IntrusivePtr<Counted>(counted));
199   }
200   DALI_TEST_EQUALS(counted->ReferenceCount(), 2 + REPEAT, TEST_LOCATION);
201
202   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
203   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
204
205   intrusivePtrs.clear();
206
207   DALI_TEST_EQUALS(counted->ReferenceCount(), 2, TEST_LOCATION);
208
209   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
210   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
211
212   counted.Reset();
213   DALI_TEST_EQUALS(counted2->ReferenceCount(), 1, TEST_LOCATION);
214   counted2.Reset();
215
216   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
217   DALI_TEST_EQUALS(g_destructionCount, 1u, TEST_LOCATION);
218
219   END_TEST;
220 }
221
222 int UtcDaliIntrusivePtrGetP(void)
223 {
224   tet_infoline("Testing Dali::IntrusivePtr::Get()");
225
226   IntrusivePtr<Counted> counted(new Counted);
227   DALI_TEST_CHECK(counted.Get() != 0);
228   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
229   DALI_TEST_EQUALS(counted->ReferenceCount(), 1, TEST_LOCATION);
230
231   END_TEST;
232 }
233
234 int UtcDaliIntrusivePtrGetN(void)
235 {
236   tet_infoline("Testing Dali::IntrusivePtr::Get()");
237
238   g_creationCount = 0;
239
240   IntrusivePtr<Counted> counted(0);
241   DALI_TEST_CHECK(counted.Get() == 0);
242   DALI_TEST_EQUALS(g_creationCount, 0u, TEST_LOCATION);
243
244   END_TEST;
245 }
246
247 int UtcDaliIntrusivePtrArrowOperatorP(void)
248 {
249   tet_infoline("Positive Test for Dali::IntrusivePtr::operator->()");
250
251   IntrusivePtr<Counted> counted(new Counted);
252   DALI_TEST_CHECK((counted.operator->()) != 0);
253   DALI_TEST_EQUALS(counted->ReferenceCount(), 1, TEST_LOCATION);
254
255   END_TEST;
256 }
257
258 int UtcDaliIntrusivePtrArrowOperatorN(void)
259 {
260   tet_infoline("Negative Test for Dali::IntrusivePtr::operator->()");
261
262   IntrusivePtr<Counted> counted;
263   DALI_TEST_CHECK((counted.operator->()) == 0);
264
265   END_TEST;
266 }
267
268 int UtcDaliIntrusivePtrIndirectionOperatorP(void)
269 {
270   tet_infoline("Positive Test for Dali::IntrusivePtr::operator*()");
271
272   IntrusivePtr<Counted> counted(new Counted);
273   DALI_TEST_CHECK(&(counted.operator*()) != 0);
274   DALI_TEST_EQUALS((*counted).ReferenceCount(), 1, TEST_LOCATION);
275
276   END_TEST;
277 }
278
279 int UtcDaliIntrusivePtrIndirectionOperatorN(void)
280 {
281   tet_infoline("Negative Test for Dali::IntrusivePtr::operator*()");
282
283   IntrusivePtr<Counted> counted;
284   DALI_TEST_CHECK(&(counted.operator*()) == 0);
285
286   END_TEST;
287 }
288
289 int UtcDaliIntrusivePtrResetP(void)
290 {
291   tet_infoline("Positive Test for Dali::IntrusivePtr::Reset()");
292
293   IntrusivePtr<Counted> counted(new Counted);
294   DALI_TEST_CHECK(counted.Get() != 0);
295   counted.Reset();
296   DALI_TEST_CHECK(counted.Get() == 0);
297
298   END_TEST;
299 }
300
301 int UtcDaliIntrusivePtrResetN(void)
302 {
303   tet_infoline("Negative Test for Dali::IntrusivePtr::Reset()");
304
305   IntrusivePtr<Counted> counted;
306   Counted*              firstGet = counted.Get();
307   counted.Reset();
308   DALI_TEST_EQUALS(counted.Get(), firstGet, TEST_LOCATION);
309
310   END_TEST;
311 }
312
313 int UtcDaliIntrusivePtrResetTP(void)
314 {
315   tet_infoline("Positive Test for Dali::IntrusivePtr::Reset(T*)");
316
317   g_creationCount = g_destructionCount = 0;
318
319   IntrusivePtr<Counted> counted(new Counted);
320
321   IntrusivePtr<Counted> counted2(new Counted);
322
323   DALI_TEST_EQUALS(counted->ReferenceCount(), 1, TEST_LOCATION);
324   DALI_TEST_EQUALS(counted2->ReferenceCount(), 1, TEST_LOCATION);
325
326   counted.Reset(counted2.Get());
327
328   DALI_TEST_EQUALS(counted->ReferenceCount(), 2, TEST_LOCATION);
329   DALI_TEST_EQUALS(counted2->ReferenceCount(), 2, TEST_LOCATION);
330
331   DALI_TEST_EQUALS(counted.Get(), counted2.Get(), TEST_LOCATION);
332
333   DALI_TEST_EQUALS(g_creationCount, 2u, TEST_LOCATION);
334   DALI_TEST_EQUALS(g_destructionCount, 1u, TEST_LOCATION);
335
336   counted2.Reset((Counted*)0);
337   counted.Reset(counted2.Get());
338   DALI_TEST_EQUALS(g_destructionCount, 2u, TEST_LOCATION);
339
340   // Check that reseting nulls is harmless:
341   counted2.Reset(counted.Get());
342   counted.Reset(counted2.Get());
343
344   DALI_TEST_EQUALS(g_destructionCount, 2u, TEST_LOCATION);
345
346   END_TEST;
347 }
348
349 int UtcDaliIntrusivePtrResetTN(void)
350 {
351   tet_infoline("Negative Test for Dali::IntrusivePtr::Reset(T*)");
352
353   g_creationCount = g_destructionCount = 0;
354
355   IntrusivePtr<Counted> counted(new Counted);
356
357   counted.Reset((Counted*)0);
358
359   DALI_TEST_EQUALS(counted.Get(), (Counted*)0, TEST_LOCATION);
360   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
361   DALI_TEST_EQUALS(g_destructionCount, 1u, TEST_LOCATION);
362
363   END_TEST;
364 }
365
366 int UtcDaliIntrusivePtrOperatorBoolP(void)
367 {
368   tet_infoline("Positive Test for Dali::IntrusivePtr::operator bool()");
369
370   IntrusivePtr<Counted> counted(new Counted);
371   DALI_TEST_CHECK(counted.operator bool() == true);
372   DALI_TEST_CHECK(counted);
373
374   counted.Reset();
375   DALI_TEST_CHECK(counted.operator bool() == false);
376
377   END_TEST;
378 }
379
380 int UtcDaliIntrusivePtrOperatorBoolN(void)
381 {
382   tet_infoline("Negative Test for Dali::IntrusivePtr::operator bool()");
383
384   IntrusivePtr<Counted> counted;
385   DALI_TEST_CHECK(counted.operator bool() == false);
386   DALI_TEST_CHECK(!counted);
387   END_TEST;
388 }
389
390 /** Equality of two different types*/
391 int UtcDaliIntrusivePtrOperatorEqualTU(void)
392 {
393   tet_infoline("Test for Dali::IntrusivePtr::operator ==(T, U)");
394
395   IntrusivePtr<Counted>         counted1(new Counted);
396   IntrusivePtr<CountedSubclass> countedSubclass1(new CountedSubclass);
397   IntrusivePtr<CountedSubclass> countedSubclass2(new CountedSubclass);
398   IntrusivePtr<Counted>         counted2(countedSubclass2);
399
400   DALI_TEST_EQUALS(operator==(counted1, countedSubclass1), false, TEST_LOCATION);
401   DALI_TEST_EQUALS(operator==(counted2, countedSubclass2), true, TEST_LOCATION);
402   END_TEST;
403 }
404
405 /** Inequality of two different types*/
406 int UtcDaliIntrusivePtrOperatorNotEqualTU(void)
407 {
408   tet_infoline("Test for Dali::IntrusivePtr::operator !=(T, U)");
409
410   IntrusivePtr<Counted>         counted1(new Counted);
411   IntrusivePtr<CountedSubclass> countedSubclass1(new CountedSubclass);
412   IntrusivePtr<CountedSubclass> countedSubclass2(new CountedSubclass);
413   IntrusivePtr<Counted>         counted2(countedSubclass2);
414
415   DALI_TEST_EQUALS(operator!=(counted1, countedSubclass1), true, TEST_LOCATION);
416   DALI_TEST_EQUALS(operator!=(counted2, countedSubclass2), false, TEST_LOCATION);
417   END_TEST;
418 }
419
420 /** Equality of two different types where right hand side is a raw pointer */
421 int UtcDaliIntrusivePtrOperatorEqualRightPointerTU(void)
422 {
423   tet_infoline("Test for Dali::IntrusivePtr::operator ==(T, U*)");
424
425   IntrusivePtr<Counted>         counted1(new Counted);
426   IntrusivePtr<CountedSubclass> countedSubclass1(new CountedSubclass);
427   IntrusivePtr<CountedSubclass> countedSubclass2(new CountedSubclass);
428   IntrusivePtr<Counted>         counted2(countedSubclass2);
429
430   DALI_TEST_EQUALS(operator==(counted1, countedSubclass1.Get()), false, TEST_LOCATION);
431   DALI_TEST_EQUALS(operator==(counted2, countedSubclass2.Get()), true, TEST_LOCATION);
432   END_TEST;
433 }
434
435 /** Inequality of two different types where the right hand side is a raw pointer */
436 int UtcDaliIntrusivePtrOperatorNotEqualRightPointerTU(void)
437 {
438   tet_infoline("Test for Dali::IntrusivePtr::operator !=(T, U*)");
439
440   IntrusivePtr<Counted>         counted1(new Counted);
441   IntrusivePtr<CountedSubclass> countedSubclass1(new CountedSubclass);
442   IntrusivePtr<CountedSubclass> countedSubclass2(new CountedSubclass);
443   IntrusivePtr<Counted>         counted2(countedSubclass2);
444
445   DALI_TEST_EQUALS(operator!=(counted1, countedSubclass1.Get()), true, TEST_LOCATION);
446   DALI_TEST_EQUALS(operator!=(counted2, countedSubclass2.Get()), false, TEST_LOCATION);
447   END_TEST;
448 }
449
450 /** Equality of two different types where left hand side is a raw pointer */
451 int UtcDaliIntrusivePtrOperatorEqualLeftPointerTU(void)
452 {
453   tet_infoline("Test for Dali::IntrusivePtr::operator ==(T*, U)");
454
455   IntrusivePtr<Counted>         counted1(new Counted);
456   IntrusivePtr<CountedSubclass> countedSubclass1(new CountedSubclass);
457   IntrusivePtr<CountedSubclass> countedSubclass2(new CountedSubclass);
458   IntrusivePtr<Counted>         counted2(countedSubclass2);
459
460   DALI_TEST_EQUALS(operator==(counted1.Get(), countedSubclass1), false, TEST_LOCATION);
461   DALI_TEST_EQUALS(operator==(counted2.Get(), countedSubclass2), true, TEST_LOCATION);
462   END_TEST;
463 }
464
465 /** Inequality of two different types where the left hand side is a raw pointer */
466 int UtcDaliIntrusivePtrOperatorNotEqualLeftPointerTU(void)
467 {
468   tet_infoline("Test for Dali::IntrusivePtr::operator !=(T*, U)");
469
470   IntrusivePtr<Counted>         counted1(new Counted);
471   IntrusivePtr<CountedSubclass> countedSubclass1(new CountedSubclass);
472   IntrusivePtr<CountedSubclass> countedSubclass2(new CountedSubclass);
473   IntrusivePtr<Counted>         counted2(countedSubclass2);
474
475   DALI_TEST_EQUALS(operator!=(counted1.Get(), countedSubclass1), true, TEST_LOCATION);
476   DALI_TEST_EQUALS(operator!=(counted2.Get(), countedSubclass2), false, TEST_LOCATION);
477   END_TEST;
478 }
479
480 int UtcDaliRefObjectCopyConstructor(void)
481 {
482   tet_infoline("Test for Dali::RefObject(const RefObject&)");
483
484   {
485     IntrusivePtr<TestObject> testPtr(new TestObject);
486     DALI_TEST_EQUALS(testPtr->ReferenceCount(), 1, TEST_LOCATION);
487
488     const TestObject& testObject = *testPtr.Get();
489     {
490       IntrusivePtr<TestObject> testPtr2(new TestObject(testObject));
491       DALI_TEST_EQUALS(testPtr2->ReferenceCount(), 1, TEST_LOCATION);
492     }
493     DALI_TEST_EQUALS(testPtr->ReferenceCount(), 1, TEST_LOCATION);
494   }
495   END_TEST;
496 }
497
498 int UtcDaliRefObjectAssignmentOperator(void)
499 {
500   tet_infoline("Test for Dali::RefObject::operator=(const RefObject&)");
501
502   {
503     IntrusivePtr<TestObject> testPtr(new TestObject);
504     DALI_TEST_EQUALS(testPtr->ReferenceCount(), 1, TEST_LOCATION);
505
506     const TestObject& testObject = *testPtr.Get();
507     {
508       IntrusivePtr<TestObject> testPtr2(new TestObject());
509       testPtr->data                     = 33;
510       IntrusivePtr<TestObject> testPtr3 = testPtr2;
511       DALI_TEST_EQUALS(testPtr2->ReferenceCount(), 2, TEST_LOCATION);
512       DALI_TEST_EQUALS(testPtr2->data, 201, TEST_LOCATION);
513
514       TestObject& testObject2 = *testPtr2.Get();
515       testObject2             = testObject;
516
517       DALI_TEST_EQUALS(testPtr->ReferenceCount(), 1, TEST_LOCATION);
518       DALI_TEST_EQUALS(testPtr2->ReferenceCount(), 2, TEST_LOCATION);
519     }
520     DALI_TEST_EQUALS(testPtr->ReferenceCount(), 1, TEST_LOCATION);
521   }
522
523   END_TEST;
524 }
525
526 int UtcDaliRefObjectAssignmentOperatorToNull(void)
527 {
528   tet_infoline("Testing Dali::IntrusivePtr = nullptr");
529
530   g_creationCount = g_destructionCount = 0;
531
532   IntrusivePtr<Counted> counted(new Counted);
533
534   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
535   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
536
537   IntrusivePtr<Counted> counted2 = counted;
538   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
539   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
540
541   DALI_TEST_EQUALS(counted->ReferenceCount(), 2, TEST_LOCATION);
542
543   counted2 = nullptr;
544   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
545   DALI_TEST_EQUALS(counted->ReferenceCount(), 1, TEST_LOCATION);
546
547   counted = nullptr;
548   DALI_TEST_EQUALS(g_destructionCount, 1u, TEST_LOCATION);
549
550   END_TEST;
551 }
552
553 int UtcDaliIntrusivePtrMoveConstructor(void)
554 {
555   IntrusivePtr<TestObject> testPtr(new TestObject);
556   DALI_TEST_EQUALS(testPtr->ReferenceCount(), 1, TEST_LOCATION);
557   DALI_TEST_EQUALS(testPtr->data, 201, TEST_LOCATION);
558
559   IntrusivePtr<TestObject> movePtr = std::move(testPtr);
560   DALI_TEST_EQUALS(movePtr->ReferenceCount(), 1, TEST_LOCATION);
561   DALI_TEST_EQUALS(movePtr->data, 201, TEST_LOCATION);
562   DALI_TEST_CHECK(!testPtr);
563
564   IntrusivePtr<TestObject> anotherTestPtr(new TestObject);
565   DALI_TEST_EQUALS(anotherTestPtr->ReferenceCount(), 1, TEST_LOCATION);
566   DALI_TEST_EQUALS(anotherTestPtr->data, 201, TEST_LOCATION);
567   IntrusivePtr<TestObject> anotherMovePtr = std::move(anotherTestPtr);
568   DALI_TEST_EQUALS(anotherMovePtr->ReferenceCount(), 1, TEST_LOCATION);
569   DALI_TEST_EQUALS(anotherMovePtr->data, 201, TEST_LOCATION);
570   DALI_TEST_CHECK(!anotherTestPtr.Get());
571
572   IntrusivePtr<CountedSubclass> countedSubclass(new CountedSubclass);
573   DALI_TEST_EQUALS(countedSubclass->ReferenceCount(), 1, TEST_LOCATION);
574
575   IntrusivePtr<Counted> countedMovePtr = std::move(countedSubclass);
576   DALI_TEST_EQUALS(countedMovePtr->ReferenceCount(), 1, TEST_LOCATION);
577   DALI_TEST_CHECK(!countedSubclass);
578
579   END_TEST;
580 }
581
582 int UtcDaliIntrusivePtrMoveAssignment(void)
583 {
584   IntrusivePtr<TestObject> testPtr(new TestObject);
585   DALI_TEST_EQUALS(testPtr->ReferenceCount(), 1, TEST_LOCATION);
586   DALI_TEST_EQUALS(testPtr->data, 201, TEST_LOCATION);
587
588   IntrusivePtr<TestObject> secondPtr(testPtr);
589   DALI_TEST_EQUALS(testPtr->ReferenceCount(), 2, TEST_LOCATION);
590
591   IntrusivePtr<TestObject> thirdPtr;
592   testPtr = std::move(thirdPtr);
593   DALI_TEST_EQUALS(secondPtr->ReferenceCount(), 1, TEST_LOCATION);
594   DALI_TEST_EQUALS(secondPtr->data, 201, TEST_LOCATION);
595   DALI_TEST_CHECK(!testPtr.Get());
596
597   IntrusivePtr<TestObject> fourthPtr(new TestObject);
598   testPtr = std::move(fourthPtr);
599   DALI_TEST_CHECK(!fourthPtr.Get());
600
601   IntrusivePtr<CountedSubclass> countedSubclassPtr(new CountedSubclass);
602   DALI_TEST_EQUALS(countedSubclassPtr->ReferenceCount(), 1, TEST_LOCATION);
603
604   IntrusivePtr<Counted> countedMovePtr;
605   countedMovePtr = std::move(countedSubclassPtr);
606   DALI_TEST_EQUALS(countedMovePtr->ReferenceCount(), 1, TEST_LOCATION);
607   DALI_TEST_CHECK(!countedSubclassPtr);
608
609   END_TEST;
610 }