@@ -2483,6 +2483,36 @@ TEST_F(test_ogr, feature_defn_geomfields_iterator)
2483
2483
EXPECT_EQ (i, oFDefn.GetGeomFieldCount ());
2484
2484
}
2485
2485
2486
+ // Test OGRGeomFieldDefn copy constructor
2487
+ TEST_F (test_ogr, geom_field_defn_copy_constructor)
2488
+ {
2489
+ {
2490
+ OGRGeomFieldDefn oGeomFieldDefn (" field1" , wkbPoint);
2491
+ oGeomFieldDefn.SetNullable (false );
2492
+ OGRGeomFieldDefn oGeomFieldDefn2 (" field2" , wkbLineString);
2493
+ oGeomFieldDefn2 = oGeomFieldDefn;
2494
+ EXPECT_TRUE (oGeomFieldDefn2.IsSame (&oGeomFieldDefn));
2495
+ }
2496
+
2497
+ {
2498
+ OGRSpatialReference oSRS;
2499
+ oSRS.SetFromUserInput (" WGS84" );
2500
+ EXPECT_EQ (oSRS.GetReferenceCount (), 1 );
2501
+ OGRGeomFieldDefn oGeomFieldDefn (" field1" , wkbPoint);
2502
+ oGeomFieldDefn.SetSpatialRef (&oSRS);
2503
+ EXPECT_EQ (oSRS.GetReferenceCount (), 2 );
2504
+ OGRGeomFieldDefn oGeomFieldDefn2 (" field2" , wkbLineString);
2505
+ oGeomFieldDefn2 = oGeomFieldDefn;
2506
+ EXPECT_EQ (oSRS.GetReferenceCount (), 3 );
2507
+ EXPECT_TRUE (oGeomFieldDefn2.IsSame (&oGeomFieldDefn));
2508
+
2509
+ // oGeomFieldDefn2 already points to oSRS
2510
+ oGeomFieldDefn2 = oGeomFieldDefn;
2511
+ EXPECT_EQ (oSRS.GetReferenceCount (), 3 );
2512
+ EXPECT_TRUE (oGeomFieldDefn2.IsSame (&oGeomFieldDefn));
2513
+ }
2514
+ }
2515
+
2486
2516
// Test GDALDataset QueryLoggerFunc callback
2487
2517
TEST_F (test_ogr, GDALDatasetSetQueryLoggerFunc)
2488
2518
{
0 commit comments