Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)

To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
This commit is contained in:
Konstantin Pastbin
2025-04-13 16:37:30 +07:00
commit e3e4a1985a
12931 changed files with 13195100 additions and 0 deletions

View File

@@ -0,0 +1,97 @@
#include "testing/testing.hpp"
#include "drape/pointers.hpp"
#include "base/base.hpp"
#include <algorithm>
#include <string>
#include <utility>
namespace
{
class Tester
{
public:
Tester() = default;
};
#if defined(TRACK_POINTERS)
bool g_assertRaised = false;
bool OnAssertRaised(base::SrcPoint const & /* srcPoint */, std::string const & /* msg */)
{
g_assertRaised = true;
return false;
}
#endif
}
UNIT_TEST(PointersTrackingTest)
{
#if defined(TRACK_POINTERS)
DpPointerTracker::TAlivePointers const & alivePointers = DpPointerTracker::Instance().GetAlivePointers();
drape_ptr<Tester> ptr = make_unique_dp<Tester>();
void * ptrAddress = ptr.get();
std::string const ptrTypeName = typeid(Tester*).name();
// no references
TEST(alivePointers.find(ptrAddress) == alivePointers.end(), ());
// create a reference
ref_ptr<Tester> refPtr = make_ref(ptr);
DpPointerTracker::TAlivePointers::const_iterator found = alivePointers.find(ptrAddress);
TEST(found != alivePointers.end(), ());
TEST_EQUAL(found->second.first, 1, ());
TEST_EQUAL(found->second.second, ptrTypeName, ());
// copy reference
ref_ptr<Tester> refPtr2 = refPtr;
found = alivePointers.find(ptrAddress);
TEST_EQUAL(found->second.first, 2, ());
// remove reference
{
ref_ptr<Tester> refPtrInScope = refPtr2;
TEST_EQUAL(found->second.first, 3, ());
}
TEST_EQUAL(found->second.first, 2, ());
// move reference
ref_ptr<Tester> refPtr3 = std::move(refPtr2);
TEST_EQUAL(found->second.first, 2, ());
// assign reference
ref_ptr<Tester> refPtr4;
refPtr4 = refPtr3;
TEST_EQUAL(found->second.first, 3, ());
// move-assign reference
refPtr4 = std::move(refPtr3);
TEST_EQUAL(found->second.first, 2, ());
// create another reference
ref_ptr<Tester> refPtr5 = make_ref(ptr);
TEST_EQUAL(found->second.first, 3, ());
#endif
}
UNIT_TEST(RefPointerExpiringTest)
{
#if defined(TRACK_POINTERS)
g_assertRaised = false;
base::AssertFailedFn prevFn = base::SetAssertFunction(OnAssertRaised);
drape_ptr<Tester> ptr = make_unique_dp<Tester>();
ref_ptr<Tester> refPtr1 = make_ref(ptr);
ref_ptr<Tester> refPtr2 = make_ref(ptr);
ptr.reset();
base::SetAssertFunction(prevFn);
TEST(g_assertRaised, ());
#endif
}