| 48 | |
| 49 | template <class T> |
| 50 | void 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 |
| 83 | TEST_F(test_ogr, SpatialReference_leak) |
nothing calls this directly
no test coverage detected