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