Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STYLE: Replace Fill(0) with {} initializer for local variables in tests #4881

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Modules/Core/Common/test/itkAggregateTypesGTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,8 @@ class CommonIndexOffsetMathOps

//============ Test Copy with Round/Cast Type ====================================
{
AggregateType known3s{ { 3, 3, 3, 3 } };
AggregateType threes;

threes.Fill(0);
AggregateType known3s{ { 3, 3, 3, 3 } };
AggregateType threes{};
AggregateType known4s{ { 4, 4, 4, 4 } };
itk::Point<double, 4> p1;
p1.Fill(3.5);
Expand Down
6 changes: 2 additions & 4 deletions Modules/Core/Common/test/itkConstNeighborhoodIteratorTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ GetTestImage(int d1, int d2, int d3, int d4)
sizeND[2] = d3;
sizeND[3] = d4;

itk::Index<4> origND;
origND.Fill(0);
itk::Index<4> origND{};

itk::ImageRegion<4> RegionND{ origND, sizeND };

Expand Down Expand Up @@ -318,8 +317,7 @@ itkConstNeighborhoodIteratorTest(int, char *[])
{
// Create an image
using ChangeRegionTestImageType = itk::Image<int, 2>;
ChangeRegionTestImageType::IndexType imageCorner;
imageCorner.Fill(0);
ChangeRegionTestImageType::IndexType imageCorner{};

ChangeRegionTestImageType::SizeType imageSize;
imageSize.Fill(4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ itkConstNeighborhoodIteratorWithOnlyIndexTestGetTestImage(int d1, int d2, int d3
sizeND[2] = d3;
sizeND[3] = d4;

itk::Index<4> origND;
origND.Fill(0);
itk::Index<4> origND{};

itk::ImageRegion<4> RegionND{ origND, sizeND };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,7 @@ itkConstShapedNeighborhoodIteratorTest(int, char *[])
{
// Create an image
using ChangeRegionTestImageType = itk::Image<int, 2>;
ChangeRegionTestImageType::IndexType imageCorner;
imageCorner.Fill(0);
ChangeRegionTestImageType::IndexType imageCorner{};

ChangeRegionTestImageType::SizeType imageSize;
imageSize.Fill(4);
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/test/itkFixedArrayTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ itkFixedArrayTest(int, char *[])
Set_c_Array(array3.GetDataPointer());
Print_Array(array3, std::cout);

itk::FixedArray<int, 3> array4;
array4.Fill(0);
itk::FixedArray<int, 3> array4{};
Print_Array(array4, std::cout);

// Test operator!= and operator==
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/test/itkImageAlgorithmCopyTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ AverageTestCopy(typename TImage::SizeType & size)
typename ImageType::RegionType region;


typename ImageType::IndexType index;
index.Fill(0);
typename ImageType::IndexType index{};
region.SetSize(size);
region.SetIndex(index);

Expand Down
5 changes: 2 additions & 3 deletions Modules/Core/Common/test/itkImageAlgorithmCopyTest2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ itkImageAlgorithmCopyTest2(int, char *[])
using RegionType = itk::ImageRegion<3>;


RegionType::IndexType index;
index.Fill(0);
RegionType::SizeType size;
RegionType::IndexType index{};
RegionType::SizeType size;
size.Fill(64);

RegionType region{ index, size };
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/test/itkImageBufferRangeGTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ typename TImage::Pointer
CreateSmallImage()
{
const auto image = TImage::New();
typename TImage::SizeType imageSize;
imageSize.Fill(0);
typename TImage::SizeType imageSize{};
image->SetRegions(imageSize);
SetVectorLengthIfImageIsVectorImage(*image, 1);
image->AllocateInitialized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ template <typename TImage>
void
ComputeFastIndex(TImage * image, unsigned int count, unsigned int repeat)
{
typename TImage::IndexType index;
index.Fill(0);
typename TImage::IndexType index{};
const typename TImage::IndexType & bufferedRegionIndex = image->GetBufferedRegion().GetIndex();
const typename TImage::OffsetValueType * offsetTable = image->GetOffsetTable();

Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/test/itkImageDuplicatorTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ itkImageDuplicatorTest(int, char *[])
size[0] = 10;
size[1] = 20;
size[2] = 30;
ImageType::IndexType index;
index.Fill(0);
ImageType::IndexType index{};
region.SetSize(size);
region.SetIndex(index);

Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/test/itkImageIteratorWithIndexTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ class itkImageIteratorWithIndexTestIteratorTester
typename ImageType::SizeType size;
size.Fill(100);

typename ImageType::IndexType start;
start.Fill(0);
typename ImageType::IndexType start{};

typename ImageType::RegionType region{ start, size };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ itkImageIteratorsForwardBackwardTest(int, char *[])
size[1] = 4;
size[2] = 4;

ImageType::IndexType start;
start.Fill(0);
ImageType::IndexType start{};

ImageType::RegionType region{ start, size };

Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/test/itkImageLinearIteratorTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ itkImageLinearIteratorTest(int, char *[])
size0[1] = 100;
size0[2] = 100;

ImageType::IndexType start0;
start0.Fill(0);
ImageType::IndexType start0{};

ImageType::RegionType region0{ start0, size0 };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ itkImageRandomConstIteratorWithOnlyIndexTest(int, char *[])

unsigned long numberOfSamples = 10;

ImageType::IndexType start0;
start0.Fill(0);
ImageType::IndexType start0{};

ImageType::RegionType region0{ start0, size0 };

Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/test/itkImageRandomIteratorTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ itkImageRandomIteratorTest(int, char *[])

unsigned long numberOfSamples = 10;

ImageType::IndexType start0;
start0.Fill(0);
ImageType::IndexType start0{};

ImageType::RegionType region0{ start0, size0 };

Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/test/itkImageRandomIteratorTest2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ itkImageRandomIteratorTest2(int argc, char * argv[])

unsigned long numberOfSamples = size[0] * size[1];

ImageType::IndexType start;
start.Fill(0);
ImageType::IndexType start{};

ImageType::RegionType region{ start, size };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ itkImageRandomNonRepeatingIteratorWithIndexTest(int, char *[])
size0[0] = 50;
size0[1] = 50;
size0[2] = 50;
unsigned long numberOfSamples = 10;
ImageType::IndexType start0;
start0.Fill(0);
unsigned long numberOfSamples = 10;
ImageType::IndexType start0{};
ImageType::RegionType region0{ start0, size0 };
myImage->SetRegions(region0);
myImage->Allocate();
Expand All @@ -58,8 +57,7 @@ itkImageRandomNonRepeatingIteratorWithIndexTest(int, char *[])
prioritySize[0] = 50;
prioritySize[1] = 50;
prioritySize[2] = 50;
PriorityImageType::IndexType priorityStart;
priorityStart.Fill(0);
PriorityImageType::IndexType priorityStart{};
PriorityImageType::RegionType priorityRegion{ priorityStart, prioritySize };
priorityImage->SetRegions(priorityRegion);
priorityImage->Allocate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ itkImageRandomNonRepeatingIteratorWithIndexTest2(int, char *[])
constexpr int Seed = 42;
ImageType::SizeType size;
size.Fill(N);
ImageType::IndexType start;
start.Fill(0);
ImageType::IndexType start{};
ImageType::RegionType region{ start, size };
auto myImage = ImageType::New();
myImage->SetRegions(region);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ class itkImageRegionConstIteratorWithOnlyIndexTestIteratorTester
typename ImageType::SizeType size;
size.Fill(100);

typename ImageType::IndexType start;
start.Fill(0);
typename ImageType::IndexType start{};

typename ImageType::RegionType region{ start, size };

Expand Down
6 changes: 2 additions & 4 deletions Modules/Core/Common/test/itkImageRegionIteratorTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ itkImageRegionIteratorTest(int, char *[])
{
// Create an image
using TestImageType = itk::Image<int, 2>;
TestImageType::IndexType imageCorner;
imageCorner.Fill(0);
TestImageType::IndexType imageCorner{};

TestImageType::SizeType imageSize;
imageSize.Fill(3);
Expand Down Expand Up @@ -165,8 +164,7 @@ itkImageRegionIteratorTest(int, char *[])
}

// Setup and iterate over the first region
TestImageType::IndexType region1Start;
region1Start.Fill(0);
TestImageType::IndexType region1Start{};

TestImageType::SizeType regionSize;
regionSize.Fill(2);
Expand Down
6 changes: 2 additions & 4 deletions Modules/Core/Common/test/itkImageScanlineIteratorTest1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ itkImageScanlineIteratorTest1(int, char *[])
{
// Create an image
using TestImageType = itk::Image<int, 2>;
TestImageType::IndexType imageCorner;
imageCorner.Fill(0);
TestImageType::IndexType imageCorner{};

TestImageType::SizeType imageSize;
imageSize.Fill(3);
Expand Down Expand Up @@ -181,8 +180,7 @@ itkImageScanlineIteratorTest1(int, char *[])
}

// Setup and iterate over the first region
TestImageType::IndexType region1Start;
region1Start.Fill(0);
TestImageType::IndexType region1Start{};

TestImageType::SizeType regionSize;
regionSize.Fill(2);
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/test/itkImageSliceIteratorTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ itkImageSliceIteratorTest(int, char *[])
size[1] = 100;
size[2] = 100;

ImageType::IndexType start;
start.Fill(0);
ImageType::IndexType start{};

ImageType::RegionType region{ start, size };

Expand Down
26 changes: 10 additions & 16 deletions Modules/Core/Common/test/itkImageTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,8 @@ itkImageTest(int, char *[])
direction.SetIdentity();
image->SetDirection(direction);
Image::RegionType region;
Image::IndexType index;
index.Fill(0);
Image::SizeType size;
Image::IndexType index{};
Image::SizeType size;
size.Fill(4);
region.SetIndex(index);
region.SetSize(size);
Expand All @@ -133,8 +132,7 @@ itkImageTest(int, char *[])
auto imageRef = Image::New();
Image::SpacingType spacingRef;
spacingRef.Fill(2);
Image::PointType originRef;
originRef.Fill(0);
Image::PointType originRef{};
Image::DirectionType directionRef;
directionRef.SetIdentity();
imageRef->SetSpacing(spacingRef);
Expand All @@ -155,9 +153,8 @@ itkImageTest(int, char *[])
image.GetPointer(),
imageRef.GetPointer(),
static_cast<TransformType *>(nullptr));
Image::IndexType correctIndex;
correctIndex.Fill(0);
Image::SizeType correctSize;
Image::IndexType correctIndex{};
Image::SizeType correctSize;
correctSize.Fill(3);
if (!(boxRegion.GetIndex() == correctIndex) || !(boxRegion.GetSize() == correctSize))
{
Expand All @@ -170,18 +167,16 @@ itkImageTest(int, char *[])
auto volume = Image3D::New();
Image3D::SpacingType spacingVol;
spacingVol.Fill(1);
Image3D::PointType originVol;
originVol.Fill(0);
Image3D::PointType originVol{};
Image3D::DirectionType directionVol;
directionVol.SetIdentity();
volume->SetSpacing(spacingVol);
volume->SetOrigin(originVol);
volume->SetDirection(directionVol);

Image3D::RegionType cuboid;
Image3D::IndexType indexCuboid;
indexCuboid.Fill(0);
Image3D::SizeType sizeCuboid;
Image3D::IndexType indexCuboid{};
Image3D::SizeType sizeCuboid;
sizeCuboid[0] = 1;
sizeCuboid[1] = 2;
sizeCuboid[2] = 3;
Expand All @@ -196,9 +191,8 @@ itkImageTest(int, char *[])
volume->GetLargestPossibleRegion(), volume.GetPointer(), imageRef.GetPointer(), projectionTransform);

delete projectionTransform;
Image::IndexType correctRectangleIndex;
correctRectangleIndex.Fill(0);
Image::SizeType correctRectangleSize;
Image::IndexType correctRectangleIndex{};
Image::SizeType correctRectangleSize;
correctRectangleSize[0] = 1;
correctRectangleSize[1] = 2;
if (!(rectangleRegion.GetIndex() == correctRectangleIndex) || !(rectangleRegion.GetSize() == correctRectangleSize))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ itkImageVectorOptimizerParametersHelperTest(int, char *[])

ImageVectorPointer imageOfVectors = ImageVectorType::New();

IndexType start;
start.Fill(0);
IndexType start{};

SizeType size;
constexpr int dimLength = 3;
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/test/itkLineIteratorTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ itkLineIteratorTest(int argc, char * argv[])


// Set up a test image
ImageType::RegionType::IndexType index;
index.Fill(0);
ImageType::RegionType::IndexType index{};

ImageType::RegionType::SizeType size;
size.Fill(200);
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/test/itkNeighborhoodAlgorithmTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ NeighborhoodAlgorithmTest()
using IndexType = typename ImageType::IndexType;
using SizeType = typename ImageType::SizeType;

IndexType ind;
ind.Fill(0);
IndexType ind{};

SizeType size;
size.Fill(5);
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/test/itkNeighborhoodIteratorTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ itkNeighborhoodIteratorTest(int, char *[])
loc[2] = 2;
loc[3] = 1;

itk::NeighborhoodIterator<TestImageType>::IndexType zeroIDX;
zeroIDX.Fill(0);
itk::NeighborhoodIterator<TestImageType>::IndexType zeroIDX{};

itk::NeighborhoodIterator<TestImageType>::RadiusType radius;
radius[0] = radius[1] = radius[2] = radius[3] = 1;
Expand Down
6 changes: 2 additions & 4 deletions Modules/Core/Common/test/itkObjectFactoryTest2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,8 @@ itkObjectFactoryTest2(int argc, char * argv[])
MakeImage(10, static_cast<float>(0));
MakeImage(10, static_cast<double>(0));
}
itk::RGBPixel<unsigned char> rgbUC;
rgbUC.Fill(0);
itk::RGBPixel<unsigned short> rgbUS;
rgbUS.Fill(0);
itk::RGBPixel<unsigned char> rgbUC{};
itk::RGBPixel<unsigned short> rgbUS{};
MakeImage(10, rgbUC);
MakeImage(10, rgbUS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ typename TImage::Pointer
CreateSmallImage()
{
const auto image = TImage::New();
typename TImage::SizeType imageSize;
imageSize.Fill(0);
typename TImage::SizeType imageSize{};
image->SetRegions(imageSize);
SetVectorLengthIfImageIsVectorImage(*image, 1);
image->AllocateInitialized();
Expand Down
Loading