Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Increase coverage for itk::FancyString #4280

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Modules/IO/XML/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ set(ITKIOXMLTests
itkDOMTest4.cxx
itkDOMTest5.cxx
itkDOMTest6.cxx
itkDOMTest7.cxx
itkDOMTest8.cxx
itkFancyStringTest.cxx
itkFileToolsTest.cxx)

createtestdriver(ITKIOXML "${ITKIOXML-Test_LIBRARIES}" "${ITKIOXMLTests}")
Expand Down Expand Up @@ -303,19 +303,19 @@ itk_add_test(

itk_add_test(
NAME
itkDOMTest7
itkDOMTest8
COMMAND
ITKIOXMLTestDriver
itkDOMTest7)
itkDOMTest8
${ITK_TEST_OUTPUT_DIR}/xmldom-test8/
output/test_file)

itk_add_test(
NAME
itkDOMTest8
itkFancyStringTest
COMMAND
ITKIOXMLTestDriver
itkDOMTest8
${ITK_TEST_OUTPUT_DIR}/xmldom-test8/
output/test_file)
itkFancyStringTest)

itk_add_test(
NAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ This program tests operations of itk::FancyString.
#include <iostream>
#include "itkMacro.h"
#include "itkMath.h"
#include "itkTestingMacros.h"

void
testFancyStringWithBasicType();
Expand All @@ -39,33 +40,26 @@ void
testFancyStringForStringOperations();

int
jhlegarreta marked this conversation as resolved.
Show resolved Hide resolved
itkDOMTest7(int, char *[])
testFancyStringUnequalOperator();

int
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();
}
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(testFancyStringForStringOperations());

ITK_TRY_EXPECT_NO_EXCEPTION(testFancyStringUnequalOperator());

ITK_TRY_EXPECT_NO_EXCEPTION(testFancyStringEqualOperator());


std::cout << "Test finished." << std::endl;
Expand Down Expand Up @@ -445,3 +439,71 @@ testFancyStringForStringOperations()

// all testings were successful if reached here
}

int
testFancyStringUnequalOperator()
{
{
const std::string str = "Hello World!";

itk::FancyString s1{ str };
const std::string s2{ "Hello World" };

ITK_TEST_EXPECT_TRUE(s1 != s2);

const std::string s3{ "Hello world!" };

ITK_TEST_EXPECT_TRUE(s1 != s3);
jhlegarreta marked this conversation as resolved.
Show resolved Hide resolved

ITK_TEST_EXPECT_TRUE(!(s1 != str));
}

{
itk::FancyString s1{ "s" };
const char * s2{ "S" };

ITK_TEST_EXPECT_TRUE(s1 != s2);
}

{
itk::FancyString s1{ "Hello World!" };
itk::FancyString s2{ "Hello World" };

ITK_TEST_EXPECT_TRUE(s1 != s2);

itk::FancyString s3{ "Hello world!" };

ITK_TEST_EXPECT_TRUE(s1 != s3);
}

return EXIT_SUCCESS;
}

int
testFancyStringEqualOperator()
{
{
itk::FancyString s1{ "Hello World!" };
const std::string s2{ "Hello World!" };

ITK_TEST_EXPECT_TRUE(s1 == s2);
jhlegarreta marked this conversation as resolved.
Show resolved Hide resolved

ITK_TEST_EXPECT_TRUE(!(s1 == "Hello"));
}

{
itk::FancyString s1{ "s" };
const char * s2{ "s" };

ITK_TEST_EXPECT_TRUE(s1 == s2);
}

{
itk::FancyString s1{ "Hello World!" };
itk::FancyString s2{ "Hello World!" };

ITK_TEST_EXPECT_TRUE(s1 == s2);
}

return EXIT_SUCCESS;
}