Skip to content

Commit 2cec1ba

Browse files
hjmjohnsonclaude
andcommitted
ENH: Convert itkAnnulusOperatorTest to itkAnnulusOperatorGTest
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 680450e commit 2cec1ba

2 files changed

Lines changed: 17 additions & 41 deletions

File tree

Modules/Core/Common/test/CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ set(
4848
itkExceptionObjectTest.cxx
4949
itkNeighborhoodOperatorTest.cxx
5050
itkNumericsTest.cxx
51-
itkAnnulusOperatorTest.cxx
5251
itkLineIteratorTest.cxx
5352
itkGaussianSpatialFunctionTest.cxx
5453
itkRealTimeClockTest.cxx
@@ -284,12 +283,6 @@ itk_add_test(
284283
ITKCommon1TestDriver
285284
itkFloodFillIteratorTest
286285
)
287-
itk_add_test(
288-
NAME itkAnnulusOperatorTest
289-
COMMAND
290-
ITKCommon1TestDriver
291-
itkAnnulusOperatorTest
292-
)
293286

294287
itk_add_test(
295288
NAME itkColorTableTest1
@@ -1699,7 +1692,7 @@ set(
16991692
itkImportContainerGTest.cxx
17001693
itkPixelAccessGTest.cxx
17011694
itkImageTransformGTest.cxx
1702-
itkCrossHelperGTest.cxx
1695+
itkAnnulusOperatorGTest.cxx
17031696
)
17041697
creategoogletestdriver(ITKCommon "${ITKCommon-Test_LIBRARIES}" "${ITKCommonGTests}")
17051698
# If `-static` was passed to CMAKE_EXE_LINKER_FLAGS, compilation fails. No need to

Modules/Core/Common/test/itkAnnulusOperatorTest.cxx renamed to Modules/Core/Common/test/itkAnnulusOperatorGTest.cxx

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818

1919
#include "itkAnnulusOperator.h"
2020
#include "itkStdStreamStateSave.h"
21-
#include "itkTestingMacros.h"
21+
#include "itkGTest.h"
2222

23-
int
24-
itkAnnulusOperatorTest(int, char *[])
23+
TEST(AnnulusOperator, CreateAndInspect)
2524
{
2625
// Save the format stream variables for std::cout
2726
// They will be restored when coutState goes out of scope
@@ -32,37 +31,21 @@ itkAnnulusOperatorTest(int, char *[])
3231
using PixelType = float;
3332
using OperatorType = itk::AnnulusOperator<PixelType, Dimension>;
3433

35-
OperatorType normalizedAnnulus;
34+
OperatorType normalizedAnnulus;
35+
OperatorType * normalizedAnnulusPtr = &normalizedAnnulus;
3636

37-
ITK_EXERCISE_BASIC_OBJECT_METHODS((&normalizedAnnulus), AnnulusOperator, NeighborhoodOperator);
37+
ITK_GTEST_EXERCISE_BASIC_OBJECT_METHODS(normalizedAnnulusPtr, AnnulusOperator, NeighborhoodOperator);
3838

3939

4040
normalizedAnnulus.NormalizeOn();
4141
normalizedAnnulus.SetInnerRadius(3);
4242
normalizedAnnulus.SetThickness(2);
4343

4444
constexpr bool brightCenter{ false };
45-
ITK_TEST_SET_GET_BOOLEAN((&normalizedAnnulus), BrightCenter, brightCenter);
45+
normalizedAnnulus.SetBrightCenter(brightCenter);
46+
EXPECT_EQ(normalizedAnnulus.GetBrightCenter(), brightCenter);
4647

47-
try
48-
{
49-
normalizedAnnulus.CreateOperator();
50-
}
51-
catch (const itk::ExceptionObject & e)
52-
{
53-
std::cout << e;
54-
return EXIT_FAILURE;
55-
}
56-
catch (const std::exception & e)
57-
{
58-
std::cout << "Std exception" << e.what();
59-
return EXIT_FAILURE;
60-
}
61-
catch (...)
62-
{
63-
std::cout << "Unknown exception" << std::endl;
64-
return EXIT_FAILURE;
65-
}
48+
EXPECT_NO_THROW(normalizedAnnulus.CreateOperator());
6649

6750
OperatorType::SizeType normalizedAnnulusSize;
6851
normalizedAnnulusSize = normalizedAnnulus.GetSize();
@@ -108,27 +91,28 @@ itkAnnulusOperatorTest(int, char *[])
10891
OperatorType annulus;
10992

11093
constexpr bool normalize{ false };
111-
ITK_TEST_SET_GET_BOOLEAN((&annulus), Normalize, normalize);
94+
annulus.SetNormalize(normalize);
95+
EXPECT_EQ(annulus.GetNormalize(), normalize);
11296

11397
constexpr double innerRadius{ 2 };
11498
annulus.SetInnerRadius(innerRadius);
115-
ITK_TEST_SET_GET_VALUE(innerRadius, annulus.GetInnerRadius());
99+
EXPECT_EQ(annulus.GetInnerRadius(), innerRadius);
116100

117101
constexpr double thickness{ 1 };
118102
annulus.SetThickness(thickness);
119-
ITK_TEST_SET_GET_VALUE(thickness, annulus.GetThickness());
103+
EXPECT_EQ(annulus.GetThickness(), thickness);
120104

121105
constexpr OperatorType::PixelType exteriorValue{ 1 };
122106
annulus.SetExteriorValue(exteriorValue);
123-
ITK_TEST_SET_GET_VALUE(exteriorValue, annulus.GetExteriorValue());
107+
EXPECT_EQ(annulus.GetExteriorValue(), exteriorValue);
124108

125109
constexpr OperatorType::PixelType annulusValue{ 8 };
126110
annulus.SetAnnulusValue(annulusValue);
127-
ITK_TEST_SET_GET_VALUE(annulusValue, annulus.GetAnnulusValue());
111+
EXPECT_EQ(annulus.GetAnnulusValue(), annulusValue);
128112

129113
constexpr OperatorType::PixelType interiorValue{ 4 };
130114
annulus.SetInteriorValue(interiorValue);
131-
ITK_TEST_SET_GET_VALUE(interiorValue, annulus.GetInteriorValue());
115+
EXPECT_EQ(annulus.GetInteriorValue(), interiorValue);
132116

133117
annulus.CreateOperator();
134118

@@ -204,7 +188,7 @@ itkAnnulusOperatorTest(int, char *[])
204188
spacing[1] = 0.25;
205189

206190
annulus.SetSpacing(spacing);
207-
ITK_TEST_SET_GET_VALUE(spacing, annulus.GetSpacing());
191+
EXPECT_EQ(annulus.GetSpacing(), spacing);
208192

209193
annulus.SetInnerRadius(2);
210194
annulus.SetThickness(1);
@@ -229,5 +213,4 @@ itkAnnulusOperatorTest(int, char *[])
229213

230214

231215
std::cout << "Test finished." << std::endl;
232-
return EXIT_SUCCESS;
233216
}

0 commit comments

Comments
 (0)