Skip to content

Commit

Permalink
STYLE: Use testing macros in itkFancyStringTest.cxx
Browse files Browse the repository at this point in the history
Use testing macros in `itkFancyStringTest.cxx`:
- Use the `ITK_TRY_EXPECT_EXCEPTION` macro in lieu of `try/catch` blocks
  to check for expected exceptions for the sake of readability and
  compactness, and to save typing/avoid boilerplate code.
  • Loading branch information
jhlegarreta authored and dzenanz committed Nov 9, 2023
1 parent 8a802d7 commit 2b8ce77
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions Modules/IO/XML/test/itkFancyStringTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,35 +49,17 @@ testFancyStringEqualOperator();
int
itkFancyStringTest(int, char *[])
{
try
{
testFancyStringWithBasicType();
ITK_TRY_EXPECT_NO_EXCEPTION(testFancyStringWithBasicType());

testFancyStringWithStdVector();
ITK_TRY_EXPECT_NO_EXCEPTION(testFancyStringWithStdVector());

testFancyStringWithItkArray();
ITK_TRY_EXPECT_NO_EXCEPTION(testFancyStringWithItkArray());

testFancyStringForStringOperations();
ITK_TRY_EXPECT_NO_EXCEPTION(testFancyStringForStringOperations());

testFancyStringUnequalOperator();
ITK_TRY_EXPECT_NO_EXCEPTION(testFancyStringUnequalOperator());

testFancyStringEqualOperator();
}
catch (const itk::ExceptionObject & eo)
{
eo.Print(std::cerr);
return EXIT_FAILURE;
}
catch (const char * emsg)
{
std::cerr << emsg << std::endl;
return EXIT_FAILURE;
}
catch (...)
{
std::cerr << "Unknown exception caught!" << std::endl;
return EXIT_FAILURE;
}
ITK_TRY_EXPECT_NO_EXCEPTION(testFancyStringEqualOperator());


std::cout << "Test finished." << std::endl;
Expand Down

0 comments on commit 2b8ce77

Please sign in to comment.