Skip to content

Commit 26869ac

Browse files
authored
Merge pull request #4156 from jhlegarreta/IncreaseMiscClassesCoverage18
ENH: Increase coverage for miscellaneous classes
2 parents c3ae515 + f7615d2 commit 26869ac

14 files changed

Lines changed: 170 additions & 24 deletions

Modules/Core/Common/test/itkDecoratorTest.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ itkDecoratorTest(int, char *[])
134134
vop->Set(vp);
135135

136136
std::cout << vop;
137+
138+
VectorType * vec = vop->Get();
139+
const VectorType * constVec = vop->Get();
140+
std::cout << "AutoPointerDataObjectDecorator::Get: " << vec << std::endl;
141+
std::cout << "AutoPointerDataObjectDecorator::Get const: " << constVec << std::endl;
137142
}
138143

139144
std::cout << "----------------------------------------------------" << std::endl;

Modules/Core/Common/test/itkNumericTraitsTest.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,10 @@ itkNumericTraitsTest(int, char *[])
887887
rgbaPixelSize = itk::NumericTraits<RGBAPixelType>::GetLength(rgbaPixel) - 1;
888888
ITK_TRY_EXPECT_EXCEPTION(itk::NumericTraits<RGBAPixelType>::SetLength(rgbaPixel, rgbaPixelSize));
889889

890+
const auto constRgbaPixel = RGBAPixelType();
891+
rgbaPixelSize = itk::NumericTraits<RGBAPixelType>::GetLength(constRgbaPixel);
892+
ITK_TEST_EXPECT_EQUAL(rgbaPixelSize, 4);
893+
890894
// itk::SymmetricSecondRankTensor<char, 1>()
891895
CheckFixedArrayTraits(itk::SymmetricSecondRankTensor<char, 1>());
892896
CheckFixedArrayTraits(itk::SymmetricSecondRankTensor<signed char, 1>());

Modules/Core/ImageFunction/test/itkNeighborhoodOperatorImageFunctionTest.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "itkNeighborhoodOperatorImageFunction.h"
2121

2222
#include "itkGaussianOperator.h"
23+
#include "itkTestingMacros.h"
2324

2425
int
2526
itkNeighborhoodOperatorImageFunctionTest(int, char *[])
@@ -54,6 +55,10 @@ itkNeighborhoodOperatorImageFunctionTest(int, char *[])
5455

5556

5657
auto function = FunctionType::New();
58+
59+
ITK_EXERCISE_BASIC_OBJECT_METHODS(function, NeighborhoodOperatorImageFunction, ImageFunction);
60+
61+
5762
function->SetInputImage(image);
5863

5964
auto * oper = new NeighborhoodOperatorType;

Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshPolygonCellTest.cxx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*=========================================================================*/
1818

1919
#include "itkQuadEdgeMesh.h"
20+
#include "itkTestingMacros.h"
2021

2122
#include <iostream>
2223

@@ -86,6 +87,20 @@ itkQuadEdgeMeshPolygonCellTest(int, char *[])
8687
*/
8788
mesh->SetCellsAllocationMethod(itk::MeshEnums::MeshClassCellsAllocationMethod::CellsAllocatedDynamicallyCellByCell);
8889

90+
91+
// Test point container iterators
92+
auto * quadEdgeMeshPolygonCell = new PolygonCellType();
93+
94+
PolygonCellType::PointIdIterator pointId = quadEdgeMeshPolygonCell->PointIdsBegin();
95+
PolygonCellType::PointIdIterator endId = quadEdgeMeshPolygonCell->PointIdsEnd();
96+
ITK_TEST_EXPECT_TRUE(pointId);
97+
ITK_TEST_EXPECT_TRUE(endId);
98+
99+
PolygonCellType::PointIdConstIterator constPointId = quadEdgeMeshPolygonCell->PointIdsBegin();
100+
PolygonCellType::PointIdConstIterator constEndId = quadEdgeMeshPolygonCell->PointIdsEnd();
101+
ITK_TEST_EXPECT_TRUE(pointId);
102+
ITK_TEST_EXPECT_TRUE(endId);
103+
89104
/**
90105
* Create the test cell. Note that testCell is a generic auto
91106
* pointer to a cell; in this example it ends up pointing to
@@ -110,6 +125,27 @@ itkQuadEdgeMeshPolygonCellTest(int, char *[])
110125
return EXIT_FAILURE;
111126
}
112127

128+
// Test iterators
129+
std::cout << "Iterator: ";
130+
pointId = newcell->PointIdsBegin();
131+
endId = newcell->PointIdsEnd();
132+
while (pointId != endId)
133+
{
134+
std::cout << *pointId << ", ";
135+
pointId++;
136+
}
137+
std::cout << std::endl;
138+
139+
std::cout << "Iterator const: ";
140+
constPointId = newcell->PointIdsBegin();
141+
constEndId = newcell->PointIdsEnd();
142+
while (constPointId != constEndId)
143+
{
144+
std::cout << *constPointId << ", ";
145+
constPointId++;
146+
}
147+
std::cout << std::endl;
148+
113149
std::cout << "Test MakeCopy" << std::endl;
114150

115151
CellAutoPointer anotherCell;

Modules/Core/SpatialObjects/test/itkSpatialObjectDuplicatorTest.cxx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,20 @@ itkSpatialObjectDuplicatorTest(int, char *[])
3737
ITK_EXERCISE_BASIC_OBJECT_METHODS(duplicator, SpatialObjectDuplicator, Object);
3838

3939

40+
ITK_TEST_SET_GET_NULL_VALUE(duplicator->GetOutput());
41+
#if !defined(ITK_LEGACY_REMOVE)
42+
ITK_TEST_SET_GET_NULL_VALUE(duplicator->GetModifiedOutput());
43+
#endif
44+
4045
duplicator->SetInput(ellipse);
4146
duplicator->Update();
4247

48+
49+
std::cout << "Output: " << duplicator->GetOutput() << std::endl;
50+
#if !defined(ITK_LEGACY_REMOVE)
51+
std::cout << "ModifiedOutput: " << duplicator->GetModifiedOutput() << std::endl;
52+
#endif
53+
4354
EllipseType::Pointer ellipse_copy = duplicator->GetOutput();
4455

4556
std::cout << ellipse_copy->GetRadiusInObjectSpace() << std::endl;

Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryDilateImageFilterTest.cxx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ itkBinaryDilateImageFilterTest(int, char *[])
119119
using myFilterType = itk::BinaryDilateImageFilter<myImageType, myImageType, myKernelType>;
120120

121121
// Create the filter
122-
auto filter = myFilterType::New();
122+
auto filter = myFilterType::New();
123+
124+
ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, BinaryDilateImageFilter, BinaryMorphologyImageFilter);
125+
126+
123127
itk::SimpleFilterWatcher filterWatcher(filter);
124128

125129
// Create the structuring element
@@ -133,16 +137,14 @@ itkBinaryDilateImageFilterTest(int, char *[])
133137
// Connect the input image
134138
filter->SetInput(inputImage);
135139
filter->SetKernel(ball);
140+
136141
filter->SetDilateValue(fgValue);
142+
ITK_TEST_SET_GET_VALUE(fgValue, filter->GetDilateValue());
143+
137144

138145
// Get the Smart Pointer to the Filter Output
139146
myImageType::Pointer outputImage = filter->GetOutput();
140147

141-
142-
// Test the itkGetMacro
143-
unsigned short value = filter->GetDilateValue();
144-
std::cout << "filter->GetDilateValue(): " << value << std::endl;
145-
146148
// Execute the filter
147149
ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update());
148150

Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryErodeImageFilterTest.cxx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ itkBinaryErodeImageFilterTest(int, char *[])
119119
using myFilterType = itk::BinaryErodeImageFilter<myImageType, myImageType, myKernelType>;
120120

121121
// Create the filter
122-
auto filter = myFilterType::New();
122+
auto filter = myFilterType::New();
123+
124+
ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, BinaryErodeImageFilter, BinaryMorphologyImageFilter);
125+
126+
123127
itk::SimpleFilterWatcher watcher(filter, "filter");
124128

125129
// Create the structuring element
@@ -133,16 +137,14 @@ itkBinaryErodeImageFilterTest(int, char *[])
133137
// Connect the input image
134138
filter->SetInput(inputImage);
135139
filter->SetKernel(ball);
140+
136141
filter->SetErodeValue(fgValue);
142+
ITK_TEST_SET_GET_VALUE(fgValue, filter->GetErodeValue());
137143

138144
// Get the Smart Pointer to the Filter Output
139145
myImageType::Pointer outputImage = filter->GetOutput();
140146

141147

142-
// Test the itkGetMacro
143-
unsigned short value = filter->GetErodeValue();
144-
std::cout << "filter->GetErodeValue(): " << value << std::endl;
145-
146148
// Execute the filter
147149
ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update());
148150

Modules/Filtering/Denoising/test/itkPatchBasedDenoisingImageFilterDefaultTest.cxx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,24 @@ doDenoising(const std::string & inputFileName, const std::string & outputFileNam
4747
auto filter = FilterType::New();
4848
filter->SetInput(reader->GetOutput());
4949

50+
ITK_TEST_SET_GET_BOOLEAN(filter, UseSmoothDiscPatchWeights, true);
51+
auto kernelBandwidthSigma = typename FilterType::RealArrayType{};
52+
ITK_TEST_SET_GET_VALUE(kernelBandwidthSigma, filter->GetKernelBandwidthSigma());
53+
ITK_TEST_SET_GET_VALUE(0.20, filter->GetKernelBandwidthFractionPixelsForEstimation());
54+
ITK_TEST_SET_GET_BOOLEAN(filter, ComputeConditionalDerivatives, false);
55+
ITK_TEST_SET_GET_BOOLEAN(filter, UseFastTensorComputations, true);
56+
ITK_TEST_SET_GET_VALUE(1.0, filter->GetKernelBandwidthMultiplicationFactor());
57+
ITK_TEST_SET_GET_VALUE(0, filter->GetNoiseSigma());
58+
5059
// Use 2 threads for consistency
5160
filter->SetNumberOfWorkUnits(2);
5261

5362
// Denoise the image
5463
ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update());
5564

5665

66+
std::cout << "NumIndependentComponents: " << filter->GetNumIndependentComponents() << std::endl;
67+
5768
// Write the denoised image to file
5869
auto writer = WriterType::New();
5970
writer->SetFileName(outputFileName);

Modules/Filtering/Denoising/test/itkPatchBasedDenoisingImageFilterTest.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ doDenoising(const std::string & inputFileName,
218218

219219
ITK_TRY_EXPECT_EXCEPTION(filter->Update());
220220

221+
std::cout << "NumIndependentComponents: " << filter->GetNumIndependentComponents() << std::endl;
222+
221223
// Restore the original pixel value
222224
inputImage->SetPixel(pixelIndex, originalPixelValue);
223225
}

Modules/Filtering/ImageGrid/test/itkPasteImageFilterGTest.cxx

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ TEST_F(PasteFixture, ConstantPaste3_2)
180180
filter->SetDestinationImage(inputImage);
181181

182182
filter->SetDestinationIndex({ { 11, 13, 17 } });
183-
filter->SetDestinationSkipAxes(SkipType{ { { true, false, false } } });
183+
184+
SkipType destinationSkipAxes{ { { true, false, false } } };
185+
filter->SetDestinationSkipAxes(destinationSkipAxes);
186+
EXPECT_EQ(destinationSkipAxes, filter->GetDestinationSkipAxes());
187+
184188
filter->SetSourceRegion(Utils::SourceSizeType{ { 5, 6 } });
185189
filter->UpdateLargestPossibleRegion();
186190
EXPECT_EQ("dfdbfe702adeccece580c5e0795d8f0a", MD5Hash(filter->GetOutput()));
@@ -189,36 +193,56 @@ TEST_F(PasteFixture, ConstantPaste3_2)
189193

190194

191195
filter->SetDestinationIndex({ { 11, 13, 17 } });
192-
filter->SetDestinationSkipAxes(SkipType{ { { false, false, true } } });
196+
197+
destinationSkipAxes = SkipType{ { { false, false, true } } };
198+
filter->SetDestinationSkipAxes(destinationSkipAxes);
199+
EXPECT_EQ(destinationSkipAxes, filter->GetDestinationSkipAxes());
200+
193201
filter->SetSourceRegion(Utils::SourceSizeType{ { 5, 6 } });
194202
filter->UpdateLargestPossibleRegion();
195203
EXPECT_EQ("7bca1328ead4ab2c6b89e1cdd1e3fdad", MD5Hash(filter->GetOutput()));
196204

197205
filter->SetDestinationIndex({ { 11, 13, 17 } });
198-
filter->SetDestinationSkipAxes(SkipType{ { { false, false, true } } });
206+
207+
destinationSkipAxes = SkipType{ { { false, false, true } } };
208+
filter->SetDestinationSkipAxes(destinationSkipAxes);
209+
EXPECT_EQ(destinationSkipAxes, filter->GetDestinationSkipAxes());
210+
199211
filter->SetSourceRegion(Utils::SourceSizeType{ { 5, 6 } });
200212
filter->UpdateLargestPossibleRegion();
201213
EXPECT_EQ("7bca1328ead4ab2c6b89e1cdd1e3fdad", MD5Hash(filter->GetOutput()));
202214

203215

204216
filter->SetDestinationIndex({ { 11, 13, 17 } });
205-
filter->SetDestinationSkipAxes(SkipType{ { { true, false, false } } });
217+
218+
destinationSkipAxes = SkipType{ { { true, false, false } } };
219+
filter->SetDestinationSkipAxes(destinationSkipAxes);
220+
EXPECT_EQ(destinationSkipAxes, filter->GetDestinationSkipAxes());
221+
206222
filter->SetSourceRegion(Utils::SourceSizeType{ { 1, 1 } });
207223
filter->UpdateLargestPossibleRegion();
208224
EXPECT_EQ("2e40b486120da8d8a225d9ab505bc580", MD5Hash(filter->GetOutput()));
209225

210226

211227
filter->SetDestinationIndex({ { 11, 13, 17 } });
212228
filter->SetSourceRegion(Utils::SourceSizeType{ { 1, 1 } });
213-
filter->SetDestinationSkipAxes(SkipType{ { { true, true, true } } });
229+
230+
destinationSkipAxes = SkipType{ { { true, true, true } } };
231+
filter->SetDestinationSkipAxes(destinationSkipAxes);
232+
EXPECT_EQ(destinationSkipAxes, filter->GetDestinationSkipAxes());
233+
214234
EXPECT_THROW(filter->VerifyPreconditions(), itk::ExceptionObject);
215235

236+
destinationSkipAxes = SkipType{ { { false, true, true } } };
237+
filter->SetDestinationSkipAxes(destinationSkipAxes);
238+
EXPECT_EQ(destinationSkipAxes, filter->GetDestinationSkipAxes());
216239

217-
filter->SetDestinationSkipAxes(SkipType{ { { false, true, true } } });
218240
EXPECT_THROW(filter->VerifyPreconditions(), itk::ExceptionObject);
219241

242+
destinationSkipAxes = SkipType{ { { true, true, false } } };
243+
filter->SetDestinationSkipAxes(destinationSkipAxes);
244+
EXPECT_EQ(destinationSkipAxes, filter->GetDestinationSkipAxes());
220245

221-
filter->SetDestinationSkipAxes(SkipType{ { { true, true, false } } });
222246
EXPECT_THROW(filter->VerifyPreconditions(), itk::ExceptionObject);
223247
}
224248
TEST_F(PasteFixture, InPlace)
@@ -296,18 +320,27 @@ TEST_F(PasteFixture, Paste3_2)
296320
filter->SetDestinationIndex({ { 11, 13, 17 } });
297321
filter->SetSourceRegion(sourceImage->GetLargestPossibleRegion());
298322

299-
filter->SetDestinationSkipAxes(SkipType{ { { true, false, false } } });
323+
SkipType destinationSkipAxes{ { { true, false, false } } };
324+
filter->SetDestinationSkipAxes(destinationSkipAxes);
325+
EXPECT_EQ(destinationSkipAxes, filter->GetDestinationSkipAxes());
326+
300327
filter->UpdateLargestPossibleRegion();
301328
EXPECT_EQ("753e433a43ab8fcf3d2ef0f8c78aef35", MD5Hash(filter->GetOutput()));
302329
EXPECT_EQ(0, filter->GetOutput()->GetPixel({ { 12, 13, 17 } }));
303330

304-
filter->SetDestinationSkipAxes(SkipType{ { { false, true, false } } });
331+
destinationSkipAxes = SkipType{ { { false, true, false } } };
332+
filter->SetDestinationSkipAxes(destinationSkipAxes);
333+
EXPECT_EQ(destinationSkipAxes, filter->GetDestinationSkipAxes());
334+
305335
filter->UpdateLargestPossibleRegion();
306336
EXPECT_EQ(0, filter->GetOutput()->GetPixel({ { 11, 14, 17 } }));
307337
EXPECT_EQ("44bd0a10b89c58fd306beee6148fdb4d", MD5Hash(filter->GetOutput()));
308338

309339

310-
filter->SetDestinationSkipAxes(SkipType{ { { false, false, true } } });
340+
destinationSkipAxes = SkipType{ { { false, false, true } } };
341+
filter->SetDestinationSkipAxes(destinationSkipAxes);
342+
EXPECT_EQ(destinationSkipAxes, filter->GetDestinationSkipAxes());
343+
311344
filter->UpdateLargestPossibleRegion();
312345
EXPECT_EQ("ce630d54304b6eba8cd73ec9617d2cf4", MD5Hash(filter->GetOutput()));
313346
EXPECT_EQ(0, filter->GetOutput()->GetPixel({ { 11, 13, 18 } }));

0 commit comments

Comments
 (0)