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

Replace Fill(T{}) with {} initialization, replace T var; var.Fill with auto var = T::Filled in tests #4887

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
5 changes: 2 additions & 3 deletions Modules/Bridge/VtkGlue/test/itkVtkMedianFilterTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ itkVtkMedianFilterTest(int argc, char * argv[])
reader->SetFileName(inputFilename);

// Create and setup a median filter
auto medianFilter = FilterType::New();
FilterType::InputSizeType radius;
radius.Fill(2);
auto medianFilter = FilterType::New();
auto radius = FilterType::InputSizeType::Filled(2);
if (argc > 2)
{
radius.Fill(std::stoi(argv[2]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,12 @@ TEST(ConnectedImageNeighborhoodShape, SupportsConstShapedNeighborhoodIterator)

// Create a "dummy" image.
const auto image = ImageType::New();
SizeType imageSize;
imageSize.Fill(1);
auto imageSize = SizeType::Filled(1);
image->SetRegions(imageSize);
image->AllocateInitialized();

// Create a radius, (just) large enough for all offsets activated below here.
SizeType radius;
radius.Fill(1);
auto radius = SizeType::Filled(1);

itk::ConstShapedNeighborhoodIterator<ImageType> shapedNeighborhoodIterator{ radius,
image,
Expand Down
15 changes: 5 additions & 10 deletions Modules/Core/Common/test/itkConstNeighborhoodIteratorTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,7 @@ itkConstNeighborhoodIteratorTest(int, char *[])
using ChangeRegionTestImageType = itk::Image<int, 2>;
ChangeRegionTestImageType::IndexType imageCorner{};

ChangeRegionTestImageType::SizeType imageSize;
imageSize.Fill(4);
auto imageSize = ChangeRegionTestImageType::SizeType::Filled(4);

ChangeRegionTestImageType::RegionType imageRegion(imageCorner, imageSize);

Expand All @@ -346,17 +345,14 @@ itkConstNeighborhoodIteratorTest(int, char *[])
}

// Setup and iterate over the first region
ChangeRegionTestImageType::IndexType region1Start;
region1Start.Fill(1);
auto region1Start = ChangeRegionTestImageType::IndexType::Filled(1);

ChangeRegionTestImageType::SizeType regionSize;
regionSize.Fill(1);
auto regionSize = ChangeRegionTestImageType::SizeType::Filled(1);

ChangeRegionTestImageType::RegionType region1(region1Start, regionSize);

// Create the radius (a 3x3 region)
ChangeRegionTestImageType::SizeType neighborhoodRadius;
neighborhoodRadius.Fill(1);
auto neighborhoodRadius = ChangeRegionTestImageType::SizeType::Filled(1);

using NeighborhoodIteratorType = itk::ConstNeighborhoodIterator<ChangeRegionTestImageType>;
NeighborhoodIteratorType neighborhoodIterator(neighborhoodRadius, image, region1);
Expand Down Expand Up @@ -385,8 +381,7 @@ itkConstNeighborhoodIteratorTest(int, char *[])
}

// Change iteration region
ChangeRegionTestImageType::IndexType region2start;
region2start.Fill(2);
auto region2start = ChangeRegionTestImageType::IndexType::Filled(2);

ChangeRegionTestImageType::RegionType region2(region2start, regionSize);

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

ChangeRegionTestImageType::SizeType imageSize;
imageSize.Fill(4);
auto imageSize = ChangeRegionTestImageType::SizeType::Filled(4);

ChangeRegionTestImageType::RegionType imageRegion(imageCorner, imageSize);

Expand All @@ -446,17 +445,14 @@ itkConstShapedNeighborhoodIteratorTest(int, char *[])
}

// Setup and iterate over the first region
ChangeRegionTestImageType::IndexType region1Start;
region1Start.Fill(1);
auto region1Start = ChangeRegionTestImageType::IndexType::Filled(1);

ChangeRegionTestImageType::SizeType regionSize;
regionSize.Fill(1);
auto regionSize = ChangeRegionTestImageType::SizeType::Filled(1);

ChangeRegionTestImageType::RegionType region1(region1Start, regionSize);

// Create the radius (a 3x3 region)
ChangeRegionTestImageType::SizeType neighborhoodRadius;
neighborhoodRadius.Fill(1);
auto neighborhoodRadius = ChangeRegionTestImageType::SizeType::Filled(1);

// Use the first two offsets
std::vector<itk::Offset<2>> offsets;
Expand Down Expand Up @@ -498,8 +494,7 @@ itkConstShapedNeighborhoodIteratorTest(int, char *[])
//}

// Change iteration region
ChangeRegionTestImageType::IndexType region2start;
region2start.Fill(2);
auto region2start = ChangeRegionTestImageType::IndexType::Filled(2);

ChangeRegionTestImageType::RegionType region2(region2start, regionSize);

Expand Down
8 changes: 2 additions & 6 deletions Modules/Core/Common/test/itkImageAlgorithmCopyTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ int
itkImageAlgorithmCopyTest(int, char *[])
{
using ImageType3D = itk::Image<char, 3>;
ImageType3D::SizeType size3d;

size3d.Fill(16);
auto size3d = ImageType3D::SizeType::Filled(16);
AverageTestCopy<ImageType3D>(size3d);

size3d.Fill(32);
Expand All @@ -134,9 +132,7 @@ itkImageAlgorithmCopyTest(int, char *[])
AverageTestCopy<ImageType3D>(size3d);

using ImageType2D = itk::Image<char, 2>;
ImageType2D::SizeType size2d;

size2d.Fill(16);
auto size2d = ImageType2D::SizeType::Filled(16);
AverageTestCopy<ImageType2D>(size2d);

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


RegionType::IndexType index{};
RegionType::SizeType size;
size.Fill(64);
auto size = RegionType::SizeType::Filled(64);

RegionType region{ index, size };

Expand Down
10 changes: 4 additions & 6 deletions Modules/Core/Common/test/itkImageBufferRangeGTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,8 @@ void
ExpectRangeIsNotEmptyForNonEmptyImage()
{
// First create a non-empty image:
const auto image = TImage::New();
typename TImage::SizeType imageSize;
imageSize.Fill(1);
const auto image = TImage::New();
auto imageSize = TImage::SizeType::Filled(1);
image->SetRegions(imageSize);
SetVectorLengthIfImageIsVectorImage(*image, 1);
image->Allocate();
Expand All @@ -178,9 +177,8 @@ void
ExpectMakeImageBufferRangeReturnsCorrectRangeForNonEmptyImage()
{
// First create a non-empty image:
const auto image = TImage::New();
typename TImage::SizeType imageSize;
imageSize.Fill(1);
const auto image = TImage::New();
auto imageSize = TImage::SizeType::Filled(1);
image->SetRegions(imageSize);
SetVectorLengthIfImageIsVectorImage(*image, 1);
image->Allocate();
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 @@ -40,8 +40,7 @@ class itkImageIteratorWithIndexTestIteratorTester
{
m_Image = ImageType::New();

typename ImageType::SizeType size;
size.Fill(100);
auto size = ImageType::SizeType::Filled(100);

typename ImageType::IndexType start{};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ itkImageRandomNonRepeatingIteratorWithIndexTest2(int, char *[])
using RandomConstIteratorType = itk::ImageRandomNonRepeatingConstIteratorWithIndex<ImageType>;
constexpr unsigned long N = 10;
constexpr int Seed = 42;
ImageType::SizeType size;
size.Fill(N);
ImageType::IndexType start{};
ImageType::RegionType region{ start, size };
auto myImage = ImageType::New();
auto size = ImageType::SizeType::Filled(N);
ImageType::IndexType start{};
ImageType::RegionType region{ start, size };
auto myImage = ImageType::New();
myImage->SetRegions(region);
myImage->Allocate();
using WalkType = std::vector<ImageType::IndexType>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ class itkImageRegionConstIteratorWithOnlyIndexTestIteratorTester
{
m_Image = ImageType::New();

typename ImageType::SizeType size;
size.Fill(100);
auto size = ImageType::SizeType::Filled(100);

typename ImageType::IndexType start{};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,7 @@ itkImageRegionExclusionIteratorWithIndexTest(int, char *[])
exclusionStart[1] = j;
exclusionStart[2] = k;

SizeType exclusionSize;
exclusionSize.Fill(s);
auto exclusionSize = SizeType::Filled(s);

RegionType exclusionRegion(exclusionStart, exclusionSize);

Expand All @@ -298,10 +297,8 @@ itkImageRegionExclusionIteratorWithIndexTest(int, char *[])
}

// Test exclusion region completely outside the region.
IndexType exclusionStart;
exclusionStart.Fill(-3);
SizeType exclusionSize;
exclusionSize.Fill(2);
auto exclusionStart = IndexType::Filled(-3);
auto exclusionSize = SizeType::Filled(2);
RegionType exclusionRegion(exclusionStart, exclusionSize);

if (!RunTest(region, exclusionRegion))
Expand Down
9 changes: 3 additions & 6 deletions Modules/Core/Common/test/itkImageRegionIteratorTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ itkImageRegionIteratorTest(int, char *[])
using TestImageType = itk::Image<int, 2>;
TestImageType::IndexType imageCorner{};

TestImageType::SizeType imageSize;
imageSize.Fill(3);
auto imageSize = TestImageType::SizeType::Filled(3);

TestImageType::RegionType imageRegion(imageCorner, imageSize);

Expand Down Expand Up @@ -166,8 +165,7 @@ itkImageRegionIteratorTest(int, char *[])
// Setup and iterate over the first region
TestImageType::IndexType region1Start{};

TestImageType::SizeType regionSize;
regionSize.Fill(2);
auto regionSize = TestImageType::SizeType::Filled(2);

TestImageType::RegionType region1(region1Start, regionSize);

Expand All @@ -190,8 +188,7 @@ itkImageRegionIteratorTest(int, char *[])
}

// Change iteration region
TestImageType::IndexType region2start;
region2start.Fill(1);
auto region2start = TestImageType::IndexType::Filled(1);

TestImageType::RegionType region2(region2start, regionSize);

Expand Down
5 changes: 2 additions & 3 deletions Modules/Core/Common/test/itkImageRegionRangeGTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,8 @@ void
ExpectRangeIsNotEmptyForNonEmptyImage()
{
// First create a non-empty image:
const auto image = TImage::New();
typename TImage::SizeType imageSize;
imageSize.Fill(1);
const auto image = TImage::New();
auto imageSize = TImage::SizeType::Filled(1);
image->SetRegions(imageSize);
SetVectorLengthIfImageIsVectorImage(*image, 1);
image->Allocate();
Expand Down
9 changes: 3 additions & 6 deletions Modules/Core/Common/test/itkImageScanlineIteratorTest1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ itkImageScanlineIteratorTest1(int, char *[])
using TestImageType = itk::Image<int, 2>;
TestImageType::IndexType imageCorner{};

TestImageType::SizeType imageSize;
imageSize.Fill(3);
auto imageSize = TestImageType::SizeType::Filled(3);

TestImageType::RegionType imageRegion(imageCorner, imageSize);

Expand Down Expand Up @@ -182,8 +181,7 @@ itkImageScanlineIteratorTest1(int, char *[])
// Setup and iterate over the first region
TestImageType::IndexType region1Start{};

TestImageType::SizeType regionSize;
regionSize.Fill(2);
auto regionSize = TestImageType::SizeType::Filled(2);

TestImageType::RegionType region1(region1Start, regionSize);

Expand All @@ -210,8 +208,7 @@ itkImageScanlineIteratorTest1(int, char *[])
}

// Change iteration region
TestImageType::IndexType region2start;
region2start.Fill(1);
auto region2start = TestImageType::IndexType::Filled(1);

TestImageType::RegionType region2(region2start, regionSize);

Expand Down
6 changes: 2 additions & 4 deletions Modules/Core/Common/test/itkImageTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ itkImageTest(int, char *[])
image->SetDirection(direction);
Image::RegionType region;
Image::IndexType index{};
Image::SizeType size;
size.Fill(4);
auto size = Image::SizeType::Filled(4);
region.SetIndex(index);
region.SetSize(size);
image->SetRegions(region);
Expand Down Expand Up @@ -153,8 +152,7 @@ itkImageTest(int, char *[])
imageRef.GetPointer(),
static_cast<TransformType *>(nullptr));
Image::IndexType correctIndex{};
Image::SizeType correctSize;
correctSize.Fill(3);
auto correctSize = Image::SizeType::Filled(3);
if (!(boxRegion.GetIndex() == correctIndex) || !(boxRegion.GetSize() == correctSize))
{
std::cerr << "EnlargeRegionOverBox test failed: "
Expand Down
6 changes: 2 additions & 4 deletions Modules/Core/Common/test/itkImageTransformTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,10 @@ TestTransform()
typename ImageType::PointType point;
RegionType region;

SizeType size;
size.Fill(10);
auto size = SizeType::Filled(10);
region.SetSize(size);

IndexType index;
index.Fill(5);
auto index = IndexType::Filled(5);

std::cout << "TransformIndexToPhysicalPoint..." << std::endl;
orientedImage->TransformIndexToPhysicalPoint(index, point);
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 @@ -44,8 +44,7 @@ itkLineIteratorTest(int argc, char * argv[])
// Set up a test image
ImageType::RegionType::IndexType index{};

ImageType::RegionType::SizeType size;
size.Fill(200);
auto size = ImageType::RegionType::SizeType::Filled(200);

ImageType::RegionType region{ index, size };

Expand Down
6 changes: 2 additions & 4 deletions Modules/Core/Common/test/itkNeighborhoodAlgorithmTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,9 @@ NeighborhoodAlgorithmTest()

IndexType ind{};

SizeType size;
size.Fill(5);
auto size = SizeType::Filled(5);

SizeType radius;
radius.Fill(1);
auto radius = SizeType::Filled(1);

RegionType region(ind, size);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ itkPhasedArray3DSpecialCoordinatesImageTest(int, char *[])
auto image = Image::New();
// image->DebugOn();
// image->GetSource();
SizeType size;
size.Fill(5); // 5x5x5 sampling of data
auto size = SizeType::Filled(5); // 5x5x5 sampling of data
RegionType region;
region.SetSize(size);
image->SetRegions(region);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,8 @@ template <typename TImage>
void
ExpectRangeIsEmptyForAnEmptyContainerOfShapeOffsets()
{
const auto image = TImage::New();
typename TImage::SizeType imageSize;
imageSize.Fill(1);
const auto image = TImage::New();
auto imageSize = TImage::SizeType::Filled(1);
image->SetRegions(imageSize);
SetVectorLengthIfImageIsVectorImage(*image, 1);
image->Allocate();
Expand All @@ -157,9 +156,8 @@ void
ExpectRangeIsNotEmptyForNonEmptyImageAndShapeOffsetContainer()
{
// First create a non-empty image:
const auto image = TImage::New();
typename TImage::SizeType imageSize;
imageSize.Fill(1);
const auto image = TImage::New();
auto imageSize = TImage::SizeType::Filled(1);
image->SetRegions(imageSize);
SetVectorLengthIfImageIsVectorImage(*image, 1);
image->Allocate();
Expand Down
Loading