MCPcopy Create free account
hub / github.com/OSGeo/gdal / testSpatialReferenceLeakOnCopy

Function testSpatialReferenceLeakOnCopy

autotest/cpp/test_ogr.cpp:50–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48
49template <class T>
50void testSpatialReferenceLeakOnCopy(OGRSpatialReference *poSRS)
51{
52 ASSERT_EQ(1, poSRS->GetReferenceCount());
53 {
54 int nCurCount;
55 int nLastCount = 1;
56 T value;
57 value.assignSpatialReference(poSRS);
58 nCurCount = poSRS->GetReferenceCount();
59 ASSERT_GT(nCurCount, nLastCount);
60 nLastCount = nCurCount;
61
62 T value2(value);
63 nCurCount = poSRS->GetReferenceCount();
64 ASSERT_GT(nCurCount, nLastCount);
65 nLastCount = nCurCount;
66
67 T value3;
68 value3 = value;
69 nCurCount = poSRS->GetReferenceCount();
70 ASSERT_GT(nCurCount, nLastCount);
71 nLastCount = nCurCount;
72
73 value3 = value;
74 // avoid Coverity Scan warning about above assignment being better
75 // replaced with a move.
76 EXPECT_NE(value.getSpatialReference(), nullptr);
77 ASSERT_EQ(nLastCount, poSRS->GetReferenceCount());
78 }
79 ASSERT_EQ(1, poSRS->GetReferenceCount());
80}
81
82// Test if copy does not leak or double delete the spatial reference
83TEST_F(test_ogr, SpatialReference_leak)

Callers

nothing calls this directly

Calls 3

ASSERT_EQFunction · 0.85
GetReferenceCountMethod · 0.80

Tested by

no test coverage detected