Skip to content

Commit fa1e339

Browse files
committed
STYLE: Replace index.Fill with auto index = Index::Filled in tests
Replaced code of the form IndexType index; index.Fill(x); with `auto index = IndexType::Filled(x);` Following C++ Core Guidelines, Oct 3, 2024, "Always initialize an object", https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-always Using Notepad++, Replace in Files, doing: Find what: ^([ ]+ )(.*::Index.*[^ ])[ ]+(\w+);[\r\n]+ [ ]+\3\.Fill\( Find what: ^([ ]+ )(IndexType)[ ]+(\w+);[\r\n]+ [ ]+\3\.Fill\( Replace with: $1auto $3 = $2::Filled\( Filters: itk*Test*.cxx [v] Match case (*) Regular expression Removed "typename" keywords from `typename T::::IndexType::Filled` calls. Follow-up to pull request #4881 commit 569a8b6 "STYLE: Replace Fill(0) with {} initializer for local variables in tests"
1 parent 4012aad commit fa1e339

File tree

43 files changed

+53
-105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+53
-105
lines changed

Modules/Core/Common/test/itkConstNeighborhoodIteratorTest.cxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,7 @@ itkConstNeighborhoodIteratorTest(int, char *[])
345345
}
346346

347347
// Setup and iterate over the first region
348-
ChangeRegionTestImageType::IndexType region1Start;
349-
region1Start.Fill(1);
348+
auto region1Start = ChangeRegionTestImageType::IndexType::Filled(1);
350349

351350
auto regionSize = ChangeRegionTestImageType::SizeType::Filled(1);
352351

@@ -382,8 +381,7 @@ itkConstNeighborhoodIteratorTest(int, char *[])
382381
}
383382

384383
// Change iteration region
385-
ChangeRegionTestImageType::IndexType region2start;
386-
region2start.Fill(2);
384+
auto region2start = ChangeRegionTestImageType::IndexType::Filled(2);
387385

388386
ChangeRegionTestImageType::RegionType region2(region2start, regionSize);
389387

Modules/Core/Common/test/itkConstShapedNeighborhoodIteratorTest.cxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,7 @@ itkConstShapedNeighborhoodIteratorTest(int, char *[])
445445
}
446446

447447
// Setup and iterate over the first region
448-
ChangeRegionTestImageType::IndexType region1Start;
449-
region1Start.Fill(1);
448+
auto region1Start = ChangeRegionTestImageType::IndexType::Filled(1);
450449

451450
auto regionSize = ChangeRegionTestImageType::SizeType::Filled(1);
452451

@@ -495,8 +494,7 @@ itkConstShapedNeighborhoodIteratorTest(int, char *[])
495494
//}
496495

497496
// Change iteration region
498-
ChangeRegionTestImageType::IndexType region2start;
499-
region2start.Fill(2);
497+
auto region2start = ChangeRegionTestImageType::IndexType::Filled(2);
500498

501499
ChangeRegionTestImageType::RegionType region2(region2start, regionSize);
502500

Modules/Core/Common/test/itkImageRegionExclusionIteratorWithIndexTest.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,7 @@ itkImageRegionExclusionIteratorWithIndexTest(int, char *[])
297297
}
298298

299299
// Test exclusion region completely outside the region.
300-
IndexType exclusionStart;
301-
exclusionStart.Fill(-3);
300+
auto exclusionStart = IndexType::Filled(-3);
302301
auto exclusionSize = SizeType::Filled(2);
303302
RegionType exclusionRegion(exclusionStart, exclusionSize);
304303

Modules/Core/Common/test/itkImageRegionIteratorTest.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ itkImageRegionIteratorTest(int, char *[])
188188
}
189189

190190
// Change iteration region
191-
TestImageType::IndexType region2start;
192-
region2start.Fill(1);
191+
auto region2start = TestImageType::IndexType::Filled(1);
193192

194193
TestImageType::RegionType region2(region2start, regionSize);
195194

Modules/Core/Common/test/itkImageScanlineIteratorTest1.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@ itkImageScanlineIteratorTest1(int, char *[])
208208
}
209209

210210
// Change iteration region
211-
TestImageType::IndexType region2start;
212-
region2start.Fill(1);
211+
auto region2start = TestImageType::IndexType::Filled(1);
213212

214213
TestImageType::RegionType region2(region2start, regionSize);
215214

Modules/Core/Common/test/itkImageTransformTest.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ TestTransform()
4949
auto size = SizeType::Filled(10);
5050
region.SetSize(size);
5151

52-
IndexType index;
53-
index.Fill(5);
52+
auto index = IndexType::Filled(5);
5453

5554
std::cout << "TransformIndexToPhysicalPoint..." << std::endl;
5655
orientedImage->TransformIndexToPhysicalPoint(index, point);

Modules/Core/ImageAdaptors/test/itkVectorImageTest.cxx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ testVectorImageAdaptor(typename TAdaptor::Pointer &
5757
bool failed = false;
5858

5959
using AdaptedImageType = itk::Image<PixelType, Dimension>;
60-
typename AdaptedImageType::IndexType index;
61-
index.Fill(10);
60+
auto index = AdaptedImageType::IndexType::Filled(10);
6261
std::cout << "Before adaptor initialization, vectorImage->GetPixel(" << index << ")[" << componentToExtract
6362
<< "] = " << vectorImage->GetPixel(index)[componentToExtract] << std::endl;
6463

@@ -559,8 +558,7 @@ itkVectorImageTest(int, char * argv[])
559558
lcit.NextLine();
560559
}
561560

562-
VectorImageType::IndexType idx;
563-
idx.Fill(1);
561+
auto idx = VectorImageType::IndexType::Filled(1);
564562
LinearIteratorType lit(vectorImage, vectorImage->GetBufferedRegion());
565563
lit.SetIndex(idx);
566564
lit.Set(f);
@@ -714,8 +712,7 @@ itkVectorImageTest(int, char * argv[])
714712

715713
ConstNeighborhoodIteratorType::RegionType region = vectorImage->GetBufferedRegion();
716714
auto size = ConstNeighborhoodIteratorType::SizeType::Filled(4);
717-
ConstNeighborhoodIteratorType::IndexType index;
718-
index.Fill(1);
715+
auto index = ConstNeighborhoodIteratorType::IndexType::Filled(1);
719716
region.SetIndex(index);
720717
region.SetSize(size);
721718

@@ -754,8 +751,7 @@ itkVectorImageTest(int, char * argv[])
754751
// Test GoToEnd()
755752
cNit.GoToEnd();
756753
--cNit;
757-
ConstNeighborhoodIteratorType::IndexType endIndex;
758-
endIndex.Fill(4);
754+
auto endIndex = ConstNeighborhoodIteratorType::IndexType::Filled(4);
759755
if (cNit.GetPixel(centerIndex) != vectorImage->GetPixel(endIndex))
760756
{
761757
std::cerr << " GoToEnd [FAILED]" << std::endl;

Modules/Core/ImageAdaptors/test/itkVectorImageToImageAdaptorTest.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ itkVectorImageToImageAdaptorTest(int, char *[])
8585
}
8686

8787
// test Get/SetPixel() methods
88-
VectorImageToImageAdaptorType::IndexType index;
89-
index.Fill(10);
88+
auto index = VectorImageToImageAdaptorType::IndexType::Filled(10);
9089
ITK_TEST_EXPECT_EQUAL(PixelType(componentToExtract), vectorImageToImageAdaptor->GetPixel(index));
9190

9291
PixelType v = 4.4f;

Modules/Core/ImageFunction/test/itkBSplineInterpolateImageFunctionTest.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,7 @@ set2DInterpData(ImageType2D::Pointer imgPtr)
732732
-225.6000, -84.6000, 0, 28.2000, 0, -84.6000, -543.0000, -289.6000, -108.6000,
733733
0, 36.2000, 0, -108.6000 };
734734

735-
ImageType2D::IndexType index;
736-
index.Fill(10);
735+
auto index = ImageType2D::IndexType::Filled(10);
737736

738737
ImageType2D::RegionType region{ index, size };
739738

Modules/Core/ImageFunction/test/itkGaussianBlurImageFunctionTest.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ itkGaussianBlurImageFunctionTest(int, char *[])
5858
// Test the derivative of Gaussian image function
5959
auto gaussianFunction = GFunctionType::New();
6060
gaussianFunction->SetInputImage(image);
61-
itk::Index<2> index;
62-
index.Fill(25);
61+
auto index = itk::Index<2>::Filled(25);
6362

6463
// Testing Set/GetVariance()
6564
std::cout << "Testing Set/GetVariance(): ";

0 commit comments

Comments
 (0)