Skip to content

Commit 67999b0

Browse files
authored
Merge pull request InsightSoftwareConsortium#5879 from hjmjohnson/convert-itkabortprocessobjecttest-to-itkabortprocessobjectgtest
ENH: Convert itkAbortProcessObjectTest to itkAbortProcessObjectGTest
2 parents d7bdae9 + 1d28315 commit 67999b0

2 files changed

Lines changed: 8 additions & 27 deletions

File tree

Modules/Core/Common/test/CMakeLists.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ itk_module_test()
22
set(
33
ITKCommon1Tests
44
itkImageRegionExplicitTest.cxx
5-
itkAbortProcessObjectTest.cxx
65
itkCommandObserverObjectTest.cxx
76
itkAdaptorComparisonTest.cxx
87
itkCovariantVectorGeometryTest.cxx
@@ -223,12 +222,6 @@ if(ITK_BUILD_SHARED_LIBS)
223222
add_dependencies(ITKCommon2TestDriver FactoryTestLib)
224223
endif()
225224

226-
itk_add_test(
227-
NAME itkAbortProcessObjectTest
228-
COMMAND
229-
ITKCommon1TestDriver
230-
itkAbortProcessObjectTest
231-
)
232225
itk_add_test(
233226
NAME itkCommandObserverObjectTest
234227
COMMAND
@@ -1774,6 +1767,7 @@ set(
17741767
itkAutoPointerGTest.cxx
17751768
itkStdStreamStateSaveGTest.cxx
17761769
itkDecoratorGTest.cxx
1770+
itkAbortProcessObjectGTest.cxx
17771771
)
17781772
creategoogletestdriver(ITKCommon "${ITKCommon-Test_LIBRARIES}" "${ITKCommonGTests}")
17791773
# If `-static` was passed to CMAKE_EXE_LINKER_FLAGS, compilation fails. No need to

Modules/Core/Common/test/itkAbortProcessObjectTest.cxx renamed to Modules/Core/Common/test/itkAbortProcessObjectGTest.cxx

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
*
1717
*=========================================================================*/
1818

19-
#include <iostream>
2019
#include "itkExtractImageFilter.h"
21-
#include "itkTestingMacros.h"
22-
20+
#include "itkGTest.h"
2321
#include "itkCommand.h"
2422

23+
#include <iostream>
24+
2525
//
2626
// This test ensures the abort event occurs and the ProcessAborted
2727
// exception occurs.
@@ -56,8 +56,7 @@ onAbort(itk::Object *, const itk::EventObject &, void *)
5656

5757
} // namespace
5858

59-
int
60-
itkAbortProcessObjectTest(int, char *[])
59+
TEST(AbortProcessObject, ConvertedLegacyTest)
6160
{
6261
// type alias to simplify the syntax
6362
using ShortImage = itk::Image<short, 2>;
@@ -99,19 +98,7 @@ itkAbortProcessObjectTest(int, char *[])
9998
extract->AddObserver(itk::AbortEvent(), abortCmd);
10099

101100
std::cout << extract << std::endl;
102-
try
103-
{
104-
extract->UpdateLargestPossibleRegion();
105-
}
106-
catch (const itk::ProcessAborted &)
107-
{
108-
if (onAbortCalled)
109-
{
110-
std::cout << "PASS: Abort event occurred and exception was thrown." << std::endl;
111-
return EXIT_SUCCESS;
112-
}
113-
std::cout << "Caught expected abort exception, but didn't get Abort Event!";
114-
}
115-
std::cout << "Test FAILED!" << std::endl;
116-
return EXIT_FAILURE;
101+
102+
EXPECT_THROW(extract->UpdateLargestPossibleRegion(), itk::ProcessAborted);
103+
EXPECT_TRUE(onAbortCalled) << "Expected Abort Event callback to be called.";
117104
}

0 commit comments

Comments
 (0)