@@ -1384,7 +1384,7 @@ static int TestBasic(GDALDataset *poDS, OGRLayer *poLayer)
1384
1384
static int TestLayerErrorConditions (OGRLayer *poLyr)
1385
1385
{
1386
1386
int bRet = TRUE ;
1387
- OGRFeature * poFeat = nullptr ;
1387
+ std::unique_ptr< OGRFeature> poFeat;
1388
1388
1389
1389
CPLPushErrorHandler (CPLQuietErrorHandler);
1390
1390
@@ -1422,18 +1422,16 @@ static int TestLayerErrorConditions(OGRLayer *poLyr)
1422
1422
}
1423
1423
1424
1424
poLyr->ResetReading ();
1425
- poFeat = poLyr->GetNextFeature ();
1425
+ poFeat. reset ( poLyr->GetNextFeature () );
1426
1426
if (poFeat)
1427
1427
{
1428
1428
poFeat->SetFID (-10 );
1429
- if (poLyr->SetFeature (poFeat) == OGRERR_NONE)
1429
+ if (poLyr->SetFeature (poFeat. get () ) == OGRERR_NONE)
1430
1430
{
1431
1431
printf (" ERROR: SetFeature(-10) should have returned an error\n " );
1432
- delete poFeat;
1433
1432
bRet = FALSE ;
1434
1433
goto bye;
1435
1434
}
1436
- delete poFeat;
1437
1435
}
1438
1436
1439
1437
if (poLyr->DeleteFeature (-10 ) == OGRERR_NONE)
@@ -1451,18 +1449,40 @@ static int TestLayerErrorConditions(OGRLayer *poLyr)
1451
1449
goto bye;
1452
1450
}
1453
1451
1454
- if (LOG_ACTION (poLyr->SetNextByIndex (-10 )) != OGRERR_FAILURE )
1452
+ if (LOG_ACTION (poLyr->SetNextByIndex (-1 )) != OGRERR_NON_EXISTING_FEATURE )
1455
1453
{
1456
- printf (" ERROR: SetNextByIndex(-10) should have "
1457
- " returned OGRERR_FAILURE\n " );
1454
+ printf (" ERROR: SetNextByIndex(-1) should have "
1455
+ " returned OGRERR_NON_EXISTING_FEATURE\n " );
1456
+ bRet = FALSE ;
1457
+ goto bye;
1458
+ }
1459
+ if (LOG_ACTION (std::unique_ptr<OGRFeature>(poLyr->GetNextFeature ())) !=
1460
+ nullptr )
1461
+ {
1462
+ printf (" ERROR: GetNextFeature() after SetNextByIndex(-1) "
1463
+ " should have returned NULL\n " );
1458
1464
bRet = FALSE ;
1459
1465
goto bye;
1460
1466
}
1461
1467
1462
- if (LOG_ACTION (poLyr->SetNextByIndex (2000000000 )) == OGRERR_NONE &&
1463
- LOG_ACTION (poLyr->GetNextFeature ()) != nullptr )
1468
+ if (poFeat)
1469
+ {
1470
+ poLyr->ResetReading ();
1471
+ poFeat.reset (poLyr->GetNextFeature ());
1472
+ if (!poFeat)
1473
+ {
1474
+ printf (" ERROR: GetNextFeature() after SetNextByIndex(-1) and "
1475
+ " ResetReading() should have returned a non-NULL feature\n " );
1476
+ bRet = FALSE ;
1477
+ goto bye;
1478
+ }
1479
+ }
1480
+
1481
+ CPL_IGNORE_RET_VAL (LOG_ACTION (poLyr->SetNextByIndex (2000000000 )));
1482
+ if (LOG_ACTION (std::unique_ptr<OGRFeature>(poLyr->GetNextFeature ())) !=
1483
+ nullptr )
1464
1484
{
1465
- printf (" ERROR: SetNextByIndex(2000000000) and then GetNextFeature( ) "
1485
+ printf (" ERROR: GetNextFeature() after SetNextByIndex(2000000000 ) "
1466
1486
" should have returned NULL\n " );
1467
1487
bRet = FALSE ;
1468
1488
goto bye;
0 commit comments