MCPcopy Create free account
hub / github.com/comaps/comaps / UNIT_TEST

Function UNIT_TEST

libs/drape/drape_tests/pointers_tests.cpp:28–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26} // namespace
27
28UNIT_TEST(PointersTrackingTest)
29{
30#if defined(TRACK_POINTERS)
31
32 DpPointerTracker::TAlivePointers const & alivePointers = DpPointerTracker::Instance().GetAlivePointers();
33
34 drape_ptr<Tester> ptr = make_unique_dp<Tester>();
35 void * ptrAddress = ptr.get();
36 std::string const ptrTypeName = typeid(Tester *).name();
37
38 // no references
39 TEST(alivePointers.find(ptrAddress) == alivePointers.end(), ());
40
41 // create a reference
42 ref_ptr<Tester> refPtr = make_ref(ptr);
43
44 DpPointerTracker::TAlivePointers::const_iterator found = alivePointers.find(ptrAddress);
45 TEST(found != alivePointers.end(), ());
46 TEST_EQUAL(found->second.first, 1, ());
47 TEST_EQUAL(found->second.second, ptrTypeName, ());
48
49 // copy reference
50 ref_ptr<Tester> refPtr2 = refPtr;
51
52 found = alivePointers.find(ptrAddress);
53 TEST_EQUAL(found->second.first, 2, ());
54
55 // remove reference
56 {
57 ref_ptr<Tester> refPtrInScope = refPtr2;
58 TEST_EQUAL(found->second.first, 3, ());
59 }
60 TEST_EQUAL(found->second.first, 2, ());
61
62 // move reference
63 ref_ptr<Tester> refPtr3 = std::move(refPtr2);
64 TEST_EQUAL(found->second.first, 2, ());
65
66 // assign reference
67 ref_ptr<Tester> refPtr4;
68 refPtr4 = refPtr3;
69 TEST_EQUAL(found->second.first, 3, ());
70
71 // move-assign reference
72 refPtr4 = std::move(refPtr3);
73 TEST_EQUAL(found->second.first, 2, ());
74
75 // create another reference
76 ref_ptr<Tester> refPtr5 = make_ref(ptr);
77 TEST_EQUAL(found->second.first, 3, ());
78
79#endif
80}
81
82UNIT_TEST(RefPointerExpiringTest)
83{

Callers

nothing calls this directly

Calls 8

TESTFunction · 0.85
make_refFunction · 0.85
SetAssertFunctionFunction · 0.85
getMethod · 0.65
nameMethod · 0.45
findMethod · 0.45
endMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected