diff --git a/CMake/mitkMacroCreateModuleTests.cmake b/CMake/mitkMacroCreateModuleTests.cmake index c6d0996a2f..d1fa655554 100644 --- a/CMake/mitkMacroCreateModuleTests.cmake +++ b/CMake/mitkMacroCreateModuleTests.cmake @@ -1,114 +1,129 @@ # # Create tests and testdriver for this module # # Usage: MITK_CREATE_MODULE_TESTS( [EXTRA_DRIVER_INIT init_code] ) # # EXTRA_DRIVER_INIT is inserted as c++ code in the testdriver and will be executed before each test # macro(MITK_CREATE_MODULE_TESTS) MACRO_PARSE_ARGUMENTS(MODULE_TEST "EXTRA_DRIVER_INIT;EXTRA_DRIVER_INCLUDE;EXTRA_DEPENDS" "" ${ARGN}) if(BUILD_TESTING AND MODULE_IS_ENABLED) set(OLD_MOC_H_FILES ${MOC_H_FILES}) set(MOC_H_FILES) include(files.cmake) include_directories(.) if(DEFINED MOC_H_FILES) QT4_WRAP_CPP(MODULE_TEST_GENERATED_MOC_CPP ${MOC_H_FILES} OPTIONS -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) endif(DEFINED MOC_H_FILES) - if (MODULE_TEST_EXTRA_DEPENDS) - MITK_USE_MODULE("${MODULE_TEST_EXTRA_DEPENDS}") - include_directories(${ALL_INCLUDE_DIRECTORIES}) - endif() + MITK_USE_MODULE(CppUnit ${MODULE_TEST_EXTRA_DEPENDS}) + include_directories(${ALL_INCLUDE_DIRECTORIES}) + + set(TESTDRIVER ${MODULE_NAME}TestDriver) + set(MODULE_TEST_EXTRA_DRIVER_INIT "${MODULE_TEST_EXTRA_DRIVER_INIT}") - set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "mitk::LoggingBackend::Register(); ${MODULE_TEST_EXTRA_DRIVER_INIT};") + # Write a header file containing include directives and custom code + # for the test driver. + set(_extra_include_content ) + list(APPEND MODULE_TEST_EXTRA_DRIVER_INCLUDE "mitkLog.h") + list(REMOVE_DUPLICATES MODULE_TEST_EXTRA_DRIVER_INCLUDE) + foreach(_include ${MODULE_TEST_EXTRA_DRIVER_INCLUDE}) + set(_extra_include_content "${_extra_include_content} +#include <${_include}>") + endforeach() + set(_extra_include_content "${_extra_include_content} +#include +std::vector globalCmdLineArgs;") + set(_extra_include_file ${CMAKE_CURRENT_BINARY_DIR}/${TESTDRIVER}_extras.h) + file(WRITE ${_extra_include_file} "${_extra_include_content}") + + set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN " +for (int avIndex = 1; avIndex < ac; ++avIndex) globalCmdLineArgs.push_back(av[avIndex]); +mitk::LoggingBackend::Register(); +${MODULE_TEST_EXTRA_DRIVER_INIT};" +) set(CMAKE_TESTDRIVER_AFTER_TESTMAIN "mitk::LoggingBackend::Unregister();") - if(NOT MODULE_TEST_EXTRA_DRIVER_INCLUDE) - # this is necessary to make the LoggingBackend calls available if nothing else is included - set(MODULE_TEST_EXTRA_DRIVER_INCLUDE "mitkLog.h") - endif(NOT MODULE_TEST_EXTRA_DRIVER_INCLUDE) create_test_sourcelist(MODULETEST_SOURCE ${MODULE_NAME}TestDriver.cpp ${MODULE_TESTS} ${MODULE_IMAGE_TESTS} ${MODULE_SURFACE_TESTS} ${MODULE_CUSTOM_TESTS} - EXTRA_INCLUDE ${MODULE_TEST_EXTRA_DRIVER_INCLUDE} + EXTRA_INCLUDE ${_extra_include_file} ) - set(TESTDRIVER ${MODULE_NAME}TestDriver) add_executable(${TESTDRIVER} ${MODULETEST_SOURCE} ${MODULE_TEST_GENERATED_MOC_CPP} ${TEST_CPP_FILES}) target_link_libraries(${TESTDRIVER} ${MODULE_PROVIDES} ${ALL_LIBRARIES}) if(MODULE_SUBPROJECTS) foreach(subproject ${MODULE_SUBPROJECTS}) add_dependencies(${subproject} ${TESTDRIVER}) endforeach() endif() # # Now tell CMake which tests should be run. This is done automatically # for all tests in ${KITNAME}_TESTS and ${KITNAME}_IMAGE_TESTS. The IMAGE_TESTS # are run for each image in the TESTIMAGES list. # foreach( test ${MODULE_TESTS} ) get_filename_component(TName ${test} NAME_WE) add_test(${TName} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} ${TName}) # Add labels for CDash subproject support if(MODULE_SUBPROJECTS) set_property(TEST ${TName} PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK) endif() endforeach( test ) foreach(image ${MODULE_TESTIMAGES} ${ADDITIONAL_TEST_IMAGES} ) if(EXISTS ${image}) set(IMAGE_FULL_PATH ${image}) else(EXISTS ${image}) # todo: maybe search other paths as well # yes, please in mitk/Testing/Data, too set(IMAGE_FULL_PATH ${MITK_DATA_DIR}/${image}) endif(EXISTS ${image}) if(EXISTS ${IMAGE_FULL_PATH}) foreach( test ${MODULE_IMAGE_TESTS} ) get_filename_component(TName ${test} NAME_WE) get_filename_component(ImageName ${IMAGE_FULL_PATH} NAME) add_test(${TName}_${ImageName} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} ${TName} ${IMAGE_FULL_PATH}) # Add labels for CDash subproject support if(MODULE_SUBPROJECTS) set_property(TEST ${TName}_${ImageName} PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK) endif() endforeach( test ) else(EXISTS ${IMAGE_FULL_PATH}) message("!!!!! No such file: ${IMAGE_FULL_PATH} !!!!!") endif(EXISTS ${IMAGE_FULL_PATH}) endforeach( image ) foreach(surface ${MODULE_TESTSURFACES} ${ADDITIONAL_TEST_SURFACES} ) if(EXISTS ${surface}) set(SURFACE_FULL_PATH ${surface}) else(EXISTS ${surface}) # todo: maybe search other paths as well # yes, please in mitk/Testing/Data, too set(SURFACE_FULL_PATH ${MITK_DATA_DIR}/${surface}) endif(EXISTS ${surface}) if(EXISTS ${SURFACE_FULL_PATH}) foreach( test ${MODULE_SURFACE_TESTS} ) get_filename_component(TName ${test} NAME_WE) get_filename_component(SurfaceName ${SURFACE_FULL_PATH} NAME) add_test(${TName}_${SurfaceName} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} ${TName} ${SURFACE_FULL_PATH}) # Add labels for CDash subproject support if(MODULE_SUBPROJECTS) set_property(TEST ${TName}_${SurfaceName} PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK) endif() endforeach( test ) else(EXISTS ${SURFACE_FULL_PATH}) message("!!!!! No such surface file: ${SURFACE_FULL_PATH} !!!!!") endif(EXISTS ${SURFACE_FULL_PATH}) endforeach( surface ) set(MOC_H_FILES ${OLD_MOC_H_FILES}) endif(BUILD_TESTING AND MODULE_IS_ENABLED) endmacro(MITK_CREATE_MODULE_TESTS) diff --git a/Core/Code/Common/mitkTestCaller.h b/Core/Code/Common/mitkTestCaller.h new file mode 100644 index 0000000000..f238a76570 --- /dev/null +++ b/Core/Code/Common/mitkTestCaller.h @@ -0,0 +1,152 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef MITKTESTCALLER_H +#define MITKTESTCALLER_H + +#include "cppunit/TestCase.h" + +#include +#include + +extern std::vector globalCmdLineArgs; + +namespace mitk { + +/** + * \brief A test caller for parameterized tests. + * + * This class is not meant to be used directly. Use the + * mitk::TestFixture class and MITK_PARAMETERIZED_TEST + * instead. + */ +template +class TestCaller : public CppUnit::TestCase +{ + typedef void (ParameterizedFixture::*TestMethod)(); + +public: + + /** + * Constructor for TestCaller. This constructor builds a new ParameterizedFixture + * instance owned by the TestCaller. + * \param name name of this TestCaller + * \param test the method this TestCaller calls in runTest() + */ + TestCaller(const std::string& name, TestMethod test) + : TestCase(name) + , m_OwnFixture(true) + , m_Fixture(new ParameterizedFixture()) + , m_Test(test) + { + m_Fixture->m_Parameter = globalCmdLineArgs; + } + + /** + * Constructor for TestCaller. + * This constructor does not create a new ParameterizedFixture instance but accepts + * an existing one as parameter. The TestCaller will not own the + * ParameterizedFixture object. + * \param name name of this TestCaller + * \param test the method this TestCaller calls in runTest() + * \param fixture the Fixture to invoke the test method on. + */ + TestCaller(const std::string& name, TestMethod test, ParameterizedFixture& fixture) + : TestCase(name) + , m_OwnFixture(false) + , m_Fixture(&fixture) + , m_Test(test) + { + m_Fixture->m_Parameter = globalCmdLineArgs; + } + + /** + * Constructor for TestCaller. + * This constructor does not create a new ParameterizedFixture instance but accepts + * an existing one as parameter. The TestCaller will own the + * ParameterizedFixture object and delete it in its destructor. + * \param name name of this TestCaller + * \param test the method this TestCaller calls in runTest() + * \param fixture the Fixture to invoke the test method on. + */ + TestCaller(const std::string& name, TestMethod test, ParameterizedFixture* fixture) + : TestCase(name) + , m_OwnFixture(true) + , m_Fixture(fixture) + , m_Test(test) + { + m_Fixture->m_Parameter = globalCmdLineArgs; + } + + /** + * Constructor for TestCaller. + * This constructor does not create a new ParameterizedFixture instance but accepts + * an existing one as parameter. The TestCaller will own the + * ParameterizedFixture object and delete it in its destructor. + * \param name name of this TestCaller + * \param test the method this TestCaller calls in runTest() + * \param fixture the Fixture to invoke the test method on. + * \param param A list of string parameters for the fixture. + */ + TestCaller(const std::string& name, TestMethod test, ParameterizedFixture* fixture, + const std::vector& param) + : TestCase(name) + , m_OwnFixture(true) + , m_Fixture(fixture) + , m_Test(test) + { + m_Fixture->m_Parameter = param; + } + + ~TestCaller() + { + if (m_OwnFixture) + delete m_Fixture; + } + + void runTest() + { + (m_Fixture->*m_Test)(); + } + + void setUp() + { + m_Fixture->setUp(); + } + + void tearDown() + { + m_Fixture->tearDown(); + } + + std::string toString() const + { + return "TestCaller " + getName(); + } + +private: + TestCaller(const TestCaller& other); + TestCaller& operator =(const TestCaller& other); + +private: + bool m_OwnFixture; + ParameterizedFixture* m_Fixture; + TestMethod m_Test; +}; + +} + +#endif // MITKTESTCALLER_H diff --git a/Core/Code/Common/mitkTestFixture.h b/Core/Code/Common/mitkTestFixture.h new file mode 100644 index 0000000000..6657749b10 --- /dev/null +++ b/Core/Code/Common/mitkTestFixture.h @@ -0,0 +1,132 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef MITKTESTFIXTURE_H +#define MITKTESTFIXTURE_H + +#include +#include + +#include + +#include +#include + +namespace mitk { + +/** + * \brief Test fixture for parameterized tests + * + * This class is a drop-in replacement for CppUnit::TextFixture and + * enables test methods to access individual parameters. You can also + * invoke one method multiple times with different parameters. + * + * + * The following simple example creates a single test withoud custom + * parameters: + * + * \code + * class MySimpleTestSuite : public mitk::TestFixture + * { + * CPPUNIT_TEST_SUITE(MySimpleTestSuite); + * MITK_TEST(FivePlusFiveTest); + * CPPUNIT_TEST_SUITE_END(); + * + * public: + * void FivePlusFiveTest() + * { + * CPPUNIT_ASSERT(5+5 == 10); + * } + * }; + * MITK_TEST_SUITE_REGISTRATION(MySimpleTestSuite) + * \endcode + * + * + * The following example creates a test class containing only + * one test method, but the associated test suite contains three tests, + * using different parameters for each call of the same method. Use + * the macro MITK_PARAMETERIZED_TEST_1 only if you know what you are + * doing. If you are not sure, use MITK_TEST instead. + * + * \code + * class MyTestSuite : public mitk::TestFixture + * { + * CPPUNIT_TEST_SUITE(MyTestSuite); + * MITK_PARAMETERIZED_TEST_1(TestSomething, "One"); + * MITK_PARAMETERIZED_TEST_1(TestSomething, "Two"); + * MITK_PARAMETERIZED_TEST_1(TestSomething, "Three"); + * CPPUNIT_TEST_SUITE_END(); + * + * public: + * + * void TestSomething() + * { + * std::vector parameter = GetTestParameter(); + * CPPUNIT_ASSERT(parameter.size() == 1); + * std::string testParam = parameter[0]; + * + * MITK_INFO << "Parameter: " << testParam; + * } + * }; + * MITK_TEST_SUITE_REGISTRATION(MyTestSuite) + * \endcode + * + * \sa MITK_PARAMETERIZED_TEST + * \sa MITK_PARAMETERIZED_TEST_1 + */ +class TestFixture : public CppUnit::TestFixture +{ + +protected: + + /** + * \brief Get parameters for this test fixture + * + * This method can be called in tests added via the MITK_PARAMETERIZED_TEST + * macro or one of its variants. + * + * \return The list of \c std::string parameters passed to previous calls + * of the MITK_PARAMETERIZED_TEST macro or one of its variants. + * + */ + std::vector GetTestParameter() const + { + return m_Parameter; + } + + /** + * \brief Get the absolute path for test data. + * + * \param testData The realative path in the MITK test data repository. + * + * \return The absolute path for the test data. + */ + static std::string GetTestDataFilePath(const std::string& testData) + { + if (itksys::SystemTools::FileIsFullPath(testData.c_str())) return testData; + return std::string(MITK_DATA_DIR) + "/" + testData; + } + +private: + + template friend class TestCaller; + + std::vector m_Parameter; +}; + +} + +#endif // MITKTESTFIXTURE_H diff --git a/Core/Code/Common/mitkTestingMacros.h b/Core/Code/Common/mitkTestingMacros.h index da2ae0420e..5948b205b7 100644 --- a/Core/Code/Common/mitkTestingMacros.h +++ b/Core/Code/Common/mitkTestingMacros.h @@ -1,187 +1,374 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include #include #include #include #include +#include + +#include +#include "cppunit/ui/text/TestRunner.h" namespace mitk { - /** \brief Indicate a failed test. */ + /** @brief Indicate a failed test. */ class TestFailedException : public std::exception { public: TestFailedException() {} }; } /** - * - * \brief Output some text without generating a terminating newline. Include + * @brief Output some text without generating a terminating newline. Include * * @ingroup MITKTestingAPI - * - * */ + */ #define MITK_TEST_OUTPUT_NO_ENDL(x) \ std::cout x ; -/** \brief Output some text. - - @ingroup MITKTestingAPI -*/ +/** + * @brief Output some text. + * + * @ingroup MITKTestingAPI + */ #define MITK_TEST_OUTPUT(x) \ MITK_TEST_OUTPUT_NO_ENDL(x << "\n") -/** \brief Do some general test preparations. Must be called first in the - main test function. - - @ingroup MITKTestingAPI -*/ +/** + * @brief Do some general test preparations. Must be called first in the + * main test function. + * + * @deprecatedSince{2013_09} Use MITK_TEST_SUITE_REGISTRATION instead. + * @ingroup MITKTestingAPI + */ #define MITK_TEST_BEGIN(testName) \ std::string mitkTestName(#testName); \ mitk::TestManager::GetInstance()->Initialize(); \ try { -/** \brief Fail and finish test with message MSG - @ingroup MITKTestingAPI -*/ +/** + * @brief Fail and finish test with message MSG + * + * @deprecatedSince{2013_09} Use CPPUNIT_FAIL instead + * @ingroup MITKTestingAPI + */ #define MITK_TEST_FAILED_MSG(MSG) \ MITK_TEST_OUTPUT(MSG) \ throw mitk::TestFailedException(); -/** \brief Must be called last in the main test function. +/** + * @brief Must be called last in the main test function. + * + * @deprecatedSince{2013_09} Use MITK_TEST_SUITE_REGISTRATION instead. * @ingroup MITKTestingAPI -*/ + */ #define MITK_TEST_END() \ } catch (mitk::TestFailedException ex) { \ MITK_TEST_OUTPUT(<< "Further test execution skipped.") \ mitk::TestManager::GetInstance()->TestFailed(); \ } catch (std::exception ex) { \ MITK_TEST_OUTPUT(<< "std::exception occured " << ex.what()) \ mitk::TestManager::GetInstance()->TestFailed(); \ } \ if (mitk::TestManager::GetInstance()->NumberOfFailedTests() > 0) { \ MITK_TEST_OUTPUT(<< mitkTestName << ": [DONE FAILED] , subtests passed: " << \ mitk::TestManager::GetInstance()->NumberOfPassedTests() << " failed: " << \ mitk::TestManager::GetInstance()->NumberOfFailedTests() ) \ return EXIT_FAILURE; \ } else { \ MITK_TEST_OUTPUT(<< mitkTestName << ": " \ << mitk::TestManager::GetInstance()->NumberOfPassedTests() \ << " tests [DONE PASSED]") \ return EXIT_SUCCESS; \ } \ +/** + * @deprecatedSince{2013_09} Use CPPUNIT_ASSERT or CPPUNIT_ASSERT_MESSAGE instead. + */ #define MITK_TEST_CONDITION(COND,MSG) \ MITK_TEST_OUTPUT_NO_ENDL(<< MSG) \ if ( ! (COND) ) { \ mitk::TestManager::GetInstance()->TestFailed(); \ MITK_TEST_OUTPUT(<< " [FAILED]\n" << "In " << __FILE__ \ << ", line " << __LINE__ \ << ": " #COND " : [FAILED]") \ } else { \ MITK_TEST_OUTPUT(<< " [PASSED]") \ mitk::TestManager::GetInstance()->TestPassed(); \ } +/** + * @deprecatedSince{2013_09} Use CPPUNIT_ASSERT or CPPUNIT_ASSERT_MESSAGE instead. + */ #define MITK_TEST_CONDITION_REQUIRED(COND,MSG) \ MITK_TEST_OUTPUT_NO_ENDL(<< MSG) \ if ( ! (COND) ) { \ MITK_TEST_FAILED_MSG(<< " [FAILED]\n" << " +--> in " << __FILE__ \ << ", line " << __LINE__ \ << ", expression is false: \"" #COND "\"") \ } else { \ MITK_TEST_OUTPUT(<< " [PASSED]") \ mitk::TestManager::GetInstance()->TestPassed(); \ } /** * \brief Begin block which should be checked for exceptions * + * @deprecatedSince{2013_09} Use CPPUNIT_ASSERT_THROW instead. * @ingroup MITKTestingAPI * * This macro, together with MITK_TEST_FOR_EXCEPTION_END, can be used * to test whether a code block throws an expected exception. The test FAILS if the * exception is NOT thrown. A simple example: * MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ImageFileReaderException) typedef itk::ImageFileReader< itk::Image > ReaderType; ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName("/tmp/not-existing"); reader->Update(); MITK_TEST_FOR_EXCEPTION_END(itk::ImageFileReaderException) * */ #define MITK_TEST_FOR_EXCEPTION_BEGIN(EXCEPTIONCLASS) \ try { +/** + * @deprecatedSince{2013_09} + */ #define MITK_TEST_FOR_EXCEPTION_END(EXCEPTIONCLASS) \ mitk::TestManager::GetInstance()->TestFailed(); \ MITK_TEST_OUTPUT( << "Expected an '" << #EXCEPTIONCLASS << "' exception. [FAILED]") \ } \ catch (EXCEPTIONCLASS) { \ MITK_TEST_OUTPUT( << "Caught an expected '" << #EXCEPTIONCLASS \ << "' exception. [PASSED]") \ mitk::TestManager::GetInstance()->TestPassed(); \ } /** - * \brief Simplified version of MITK_TEST_FOR_EXCEPTION_BEGIN / END for + * @brief Simplified version of MITK_TEST_FOR_EXCEPTION_BEGIN / END for * a single statement * + * @deprecatedSince{2013_09} Use CPPUNIT_ASSERT_THROW instead. * @ingroup MITKTestingAPI */ #define MITK_TEST_FOR_EXCEPTION(EXCEPTIONCLASS, STATEMENT) \ MITK_TEST_FOR_EXCEPTION_BEGIN(EXCEPTIONCLASS) \ STATEMENT ; \ MITK_TEST_FOR_EXCEPTION_END(EXCEPTIONCLASS) -/** \brief Testing macro to test if two objects are equal. +/** + * @brief Testing macro to test if two objects are equal. * * @ingroup MITKTestingAPI * * This macro uses mitk::eps and the corresponding mitk::Equal methods for all * comparisons and will give verbose output on the dashboard/console. * Feel free to implement mitk::Equal for your own datatype or purpose. * + * @deprecatedSince{2013_09} Use MITK_ASSERT_EQUAL instead. + * * @param OBJ1 First object. * @param OBJ2 Second object. * @param MSG Message to appear with the test. */ #define MITK_TEST_EQUAL(OBJ1,OBJ2,MSG) \ MITK_TEST_CONDITION_REQUIRED( mitk::Equal(OBJ1, OBJ2, mitk::eps, true)==true, MSG) -/** \brief Testing macro to test if two objects are not equal. +/** + * @brief Testing macro to test if two objects are equal. + * + * @ingroup MITKTestingAPI + * + * This macro uses mitk::eps and the corresponding mitk::Equal methods for all + * comparisons and will give verbose output on the dashboard/console. + * Feel free to implement mitk::Equal for your own datatype or purpose. + * + * @param EXPECTED First object. + * @param ACTUAL Second object. + * @param MSG Message to appear with the test. + */ +#define MITK_ASSERT_EQUAL(EXPECTED, ACTUAL, MSG) \ + CPPUNIT_ASSERT_MESSAGE(MSG, mitk::Equal(EXPECTED, ACTUAL, mitk::eps, true)) + +/** + * @brief Testing macro to test if two objects are not equal. * * @ingroup MITKTestingAPI * * This macro uses mitk::eps and the corresponding mitk::Equal methods for all * comparisons and will give verbose output on the dashboard/console. * + * @deprecatedSince{2013_09} Use MITK_ASSERT_NOT_EQUAL instead. + * * @param OBJ1 First object. * @param OBJ2 Second object. * @param MSG Message to appear with the test. * * \sa MITK_TEST_EQUAL */ #define MITK_TEST_NOT_EQUAL(OBJ1,OBJ2,MSG) \ MITK_TEST_CONDITION_REQUIRED( mitk::Equal(OBJ1, OBJ2, mitk::eps, true)==false, MSG) +/** + * @brief Testing macro to test if two objects are not equal. + * + * @ingroup MITKTestingAPI + * + * This macro uses mitk::eps and the corresponding mitk::Equal methods for all + * comparisons and will give verbose output on the dashboard/console. + * + * @param OBJ1 First object. + * @param OBJ2 Second object. + * @param MSG Message to appear with the test. + * + * \sa MITK_ASSERT_EQUAL + */ +#define MITK_ASSERT_NOT_EQUAL(OBJ1, OBJ2, MSG) \ + CPPUNIT_ASSERT_MESSAGE(MSG, !mitk::Equal(OBJ1, OBJ2, mitk::eps, true)) + +/** + * @brief Registers the given test suite. + * + * @ingroup MITKTestingAPI + * + * @param TESTSUITE_NAME The name of the test suite class, without "TestSuite" + * at the end. + */ +#define MITK_TEST_SUITE_REGISTRATION(TESTSUITE_NAME) \ + int TESTSUITE_NAME ## Test(int /*argc*/, char* /*argv*/[]) \ + { \ + CppUnit::TextUi::TestRunner runner; \ + runner.addTest(TESTSUITE_NAME ## TestSuite::suite()); \ + runner.run(); \ + return EXIT_SUCCESS; \ + } + +/** + * @brief Adds a test to the current test suite. + * + * @ingroup MITKTestingAPI + * + * Use this macro after the CPPUNIT_TEST_SUITE() macro to add test cases. + * The macro internally just calls the CPPUNIT_TEST macro. + * + * @param TESTMETHOD The name of the member funtion test. + */ +#define MITK_TEST(TESTMETHOD) CPPUNIT_TEST(TESTMETHOD) + +/** + * @brief Adds a parameterized test to the current test suite. + * + * @ingroup MITKTestingAPI + * + * Use this macro after the CPPUNIT_TEST_SUITE() macro to add test cases + * which need custom parameters. + * + * @param TESTMETHOD The name of the member function test. + * @param ARGS A std::vector object containing test parameter. + * + * @note Use the macro MITK_PARAMETERIZED_TEST only if you know what + * you are doing. If you are not sure, use MITK_TEST instead. + */ +#define MITK_PARAMETERIZED_TEST(TESTMETHOD, ARGS) \ +{ \ + std::string testName = #TESTMETHOD; \ + for (std::size_t i = 0; i < ARGS.size(); ++i) \ + { \ + testName += "_" + ARGS[i]; \ + } \ + CPPUNIT_TEST_SUITE_ADD_TEST( \ + ( new mitk::TestCaller( \ + context.getTestNameFor(testName), \ + &TestFixtureType::TESTMETHOD, \ + context.makeFixture(), args ) ) ); \ +} + +/** + * @brief Adds a parameterized test to the current test suite. + * + * @ingroup MITKTestingAPI + * + * Use this macro after the CPPUNIT_TEST_SUITE() macro to add test cases + * which need parameters from the command line. + * + * @warning Use the macro MITK_PARAMETERIZED_CMD_LINE_TEST only + * if you know what you are doing. If you are not sure, use + * MITK_TEST instead. MITK_PARAMETERIZED_CMD_LINE_TEST is meant + * for migrating from ctest to CppUnit. If you implement new + * tests, the MITK_TEST macro will be sufficient. + * + * @param TESTMETHOD The name of the member function test. + */ +#define MITK_PARAMETERIZED_CMD_LINE_TEST(TESTMETHOD) \ + CPPUNIT_TEST_SUITE_ADD_TEST( \ + ( new mitk::TestCaller( \ + context.getTestNameFor( #TESTMETHOD), \ + &TestFixtureType::TESTMETHOD, \ + context.makeFixture() ) ) ); + +/** + * @brief Adds a parameterized test to the current test suite. + * + * @ingroup MITKTestingAPI + * + * Use this macro after the CPPUNIT_TEST_SUITE() macro to add test cases + * which need one custom parameter. + * + * @param TESTMETHOD The name of the member function test. + * @param arg1 A custom string parameter being passed to the fixture. + * + * @note Use the macro MITK_PARAMETERIZED_TEST_1 only if you know what + * you are doing. If you are not sure, use MITK_TEST instead. + * + * @see MITK_PARAMETERIZED_TEST + */ +#define MITK_PARAMETERIZED_TEST_1(TESTMETHOD, arg1) \ +{ \ + std::vector args; \ + args.push_back(arg1); \ + MITK_PARAMETERIZED_TEST(TESTMETHOD, args) \ +} + +/** + * @brief Adds a parameterized test to the current test suite. + * + * @ingroup MITKTestingAPI + * + * Use this macro after the CPPUNIT_TEST_SUITE() macro to add test cases + * which need two custom parameter. + * + * @param TESTMETHOD The name of the member function test. + * @param arg1 A custom string parameter being passed to the fixture. + * + * @note Use the macro MITK_PARAMETERIZED_TEST_2 only if you know what + * you are doing. If you are not sure, use MITK_TEST instead. + * + * @see MITK_PARAMETERIZED_TEST + */ +#define MITK_PARAMETERIZED_TEST_2(TESTMETHOD, arg1, arg2) \ +{ \ + std::vector args; \ + args.push_back(arg1); \ + args.push_back(arg2); \ + MITK_PARAMETERIZED_TEST(TESTMETHOD, args) \ +} diff --git a/Core/Code/Testing/CMakeLists.txt b/Core/Code/Testing/CMakeLists.txt index 0afa595270..cd1185a7bf 100644 --- a/Core/Code/Testing/CMakeLists.txt +++ b/Core/Code/Testing/CMakeLists.txt @@ -1,221 +1,211 @@ # The core tests need relaxed compiler flags... # TODO fix core tests to compile without these additional no-error flags if(MSVC_VERSION) # disable deprecated warnings (they would lead to errors) mitkFunctionCheckCAndCXXCompilerFlags("/wd4996" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) else() mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=deprecated" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=deprecated-declarations" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) endif() MITK_CREATE_MODULE_TESTS(LABELS MITK-Core) # MITK_INSTALL_TARGETS(EXECUTABLES MitkTestDriver) -mitkAddCustomModuleTest(mitkDICOMLocaleTest_spacingOk_CT mitkDICOMLocaleTest ${MITK_DATA_DIR}/spacing-ok-ct.dcm) -mitkAddCustomModuleTest(mitkDICOMLocaleTest_spacingOk_MR mitkDICOMLocaleTest ${MITK_DATA_DIR}/spacing-ok-mr.dcm) -mitkAddCustomModuleTest(mitkDICOMLocaleTest_spacingOk_SC mitkDICOMLocaleTest ${MITK_DATA_DIR}/spacing-ok-sc.dcm) - mitkAddCustomModuleTest(mitkVolumeCalculatorTest_Png2D-bw mitkVolumeCalculatorTest ${MITK_DATA_DIR}/Png2D-bw.png ${MITK_DATA_DIR}/Pic2DplusT.nrrd) mitkAddCustomModuleTest(mitkEventMapperTest_Test1And2 mitkEventMapperTest ${MITK_DATA_DIR}/TestStateMachine1.xml ${MITK_DATA_DIR}/TestStateMachine2.xml) mitkAddCustomModuleTest(mitkEventConfigTest_CreateObjectInDifferentWays mitkEventConfigTest ${MITK_SOURCE_DIR}/Core/Code/Testing/Resources/Interactions/StatemachineConfigTest.xml) #mitkAddCustomModuleTest(mitkNodeDependentPointSetInteractorTest mitkNodeDependentPointSetInteractorTest ${MITK_DATA_DIR}/Pic3D.pic.gz ${MITK_DATA_DIR}/BallBinary30x30x30.pic.gz) mitkAddCustomModuleTest(mitkNodeDependentPointSetInteractorTest mitkNodeDependentPointSetInteractorTest ${MITK_DATA_DIR}/Pic3D.nrrd ${MITK_DATA_DIR}/BallBinary30x30x30.nrrd) mitkAddCustomModuleTest(mitkDataStorageTest_US4DCyl mitkDataStorageTest ${MITK_DATA_DIR}/US4DCyl.nrrd) mitkAddCustomModuleTest(mitkStateMachineFactoryTest_TestStateMachine1_2 mitkStateMachineFactoryTest ${MITK_DATA_DIR}/TestStateMachine1.xml ${MITK_DATA_DIR}/TestStateMachine2.xml) mitkAddCustomModuleTest(mitkDicomSeriesReaderTest_CTImage mitkDicomSeriesReaderTest ${MITK_DATA_DIR}/TinyCTAbdomen ${MITK_DATA_DIR}/DICOMReader/Broken-Series) mitkAddCustomModuleTest(mitkPointSetReaderTest mitkPointSetReaderTest ${MITK_DATA_DIR}/PointSetReaderTestData.mps) mitkAddCustomModuleTest(mitkImageTest_4DImageData mitkImageTest ${MITK_DATA_DIR}/US4DCyl.nrrd) mitkAddCustomModuleTest(mitkImageTest_2D+tImageData mitkImageTest ${MITK_DATA_DIR}/Pic2DplusT.nrrd) mitkAddCustomModuleTest(mitkImageTest_3DImageData mitkImageTest ${MITK_DATA_DIR}/Pic3D.nrrd) mitkAddCustomModuleTest(mitkImageTest_brainImage mitkImageTest ${MITK_DATA_DIR}/brain.mhd) #mitkAddCustomModuleTest(mitkImageTest_color2DImage mitkImageTest ${MITK_DATA_DIR}/NrrdWritingTestImage.jpg) mitkAddCustomModuleTest(mitkImageTest_3DImageData mitkImageGeneratorTest ${MITK_DATA_DIR}/Pic3D.nrrd) -mitkAddCustomModuleTest(mitkIOUtilTest mitkIOUtilTest #test for a randomly chosen Pic3D swivelled slice - ${MITK_DATA_DIR}/Pic3D.nrrd - ${MITK_DATA_DIR}/pointSet.mps - ${MITK_DATA_DIR}/binary.stl -) - mitkAddCustomModuleTest(mitkLevelWindowManagerTest mitkLevelWindowManagerTest ${MITK_DATA_DIR}/Pic3D.nrrd ) mitkAddCustomModuleTest(mitkMultiComponentImageDataComparisonFilterTest mitkMultiComponentImageDataComparisonFilterTest ${MITK_DATA_DIR}/NrrdWritingTestImage.jpg ) if(MITK_ENABLE_RENDERING_TESTING) ### since the rendering test's do not run in ubuntu, yet, we build them only for other systems or if the user explicitly sets the variable MITK_ENABLE_RENDERING_TESTING mitkAddCustomModuleTest(mitkImageVtkMapper2D_rgbaImage640x480 mitkImageVtkMapper2DTest ${MITK_DATA_DIR}/RenderingTestData/rgbaImage.png #input image to load in data storage -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/rgbaImage640x480REF.png #corresponding reference screenshot ) mitkAddCustomModuleTest(mitkImageVtkMapper2D_pic3d640x480 mitkImageVtkMapper2DTest #test for standard Pic3D axial slice ${MITK_DATA_DIR}/Pic3D.nrrd #input image to load in data storage -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/pic3d640x480REF.png #corresponding reference screenshot ) mitkAddCustomModuleTest(mitkImageVtkMapper2D_pic3dColorBlue640x480 mitkImageVtkMapper2DColorTest #test for color property (=blue) Pic3D sagittal slice ${MITK_DATA_DIR}/Pic3D.nrrd #input image to load in data storage -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/pic3dColorBlue640x480REF.png #corresponding reference screenshot ) mitkAddCustomModuleTest(mitkImageVtkMapper2D_pic3dLevelWindow640x480 mitkImageVtkMapper2DLevelWindowTest #test for levelwindow property (=blood) #Pic3D sagittal slice ${MITK_DATA_DIR}/Pic3D.nrrd #input image to load in data storage -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/pic3dLevelWindowBlood640x480REF.png #corresponding reference #screenshot ) mitkAddCustomModuleTest(mitkImageVtkMapper2D_pic3dOpacity640x480 mitkImageVtkMapper2DOpacityTest #test for opacity (=0.5) Pic3D coronal slice ${MITK_DATA_DIR}/Pic3D.nrrd #input image to load in data storage -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/pic3dOpacity640x480REF.png corresponding reference screenshot ) mitkAddCustomModuleTest(mitkImageVtkMapper2D_pic3dSwivel640x480 mitkImageVtkMapper2DSwivelTest #test for a randomly chosen Pic3D swivelled slice ${MITK_DATA_DIR}/Pic3D.nrrd #input image to load in data storage -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/pic3dSwivel640x480REF.png #corresponding reference screenshot ) mitkAddCustomModuleTest(mitkPointSetVtkMapper2D_openMeAlone640x480 mitkPointSetVtkMapper2DTest ${MITK_DATA_DIR}/RenderingTestData/openMeAlone.mps #input point set to load in data storage -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/openMeAlone640x480REF.png #corresponding reference screenshot ) mitkAddCustomModuleTest(mitkPointSetVtkMapper2D_Pic3DPointSetForPic3D640x480 mitkPointSetVtkMapper2DImageTest ${MITK_DATA_DIR}/Pic3D.nrrd ${MITK_DATA_DIR}/RenderingTestData/PointSetForPic3D.mps #input point set and image to load in data storage -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/Pic3DPointSetForPic3D640x480REF.png #corresponding reference screenshot ) mitkAddCustomModuleTest(mitkPointSetVtkMapper2D_openMeAloneGlyphType640x480 mitkPointSetVtkMapper2DGlyphTypeTest ${MITK_DATA_DIR}/RenderingTestData/openMeAlone.mps #input point set to load in data storage -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/openMeAloneGlyphType640x480REF.png #corresponding reference screenshot ) mitkAddCustomModuleTest(mitkPointSetVtkMapper2D_openMeAloneTransformed640x480 mitkPointSetVtkMapper2DTransformedPointsTest ${MITK_DATA_DIR}/RenderingTestData/openMeAlone.mps #input point set to load in data storage -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/openMeAloneTransformedPoints640x480REF.png #corresponding reference screenshot ) #Test reslice interpolation #note: nearest mode is already tested by swivel test mitkAddCustomModuleTest(ResliceInterpolationIsLinear mitkImageVtkMapper2DResliceInterpolationPropertyTest 1 #linear ${MITK_DATA_DIR}/Pic3D.nrrd -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/pic3dRefLinear.png #corresponding reference screenshot LINEAR ) mitkAddCustomModuleTest(ResliceInterpolationIsCubic mitkImageVtkMapper2DResliceInterpolationPropertyTest 3 #cubic ${MITK_DATA_DIR}/Pic3D.nrrd -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/pic3dRefCubic.png #corresponding reference screenshot CUBIC ) #End test reslice interpolation #Overlays mitkAddCustomModuleTest(mitkLabelOverlay3DRendering2DTest mitkLabelOverlay3DRendering2DTest #OverlayTest -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/mitkLabelOverlay3DRendering2DTest.png #corresponding reference screenshot ) mitkAddCustomModuleTest(mitkLabelOverlay3DRendering3DTest mitkLabelOverlay3DRendering3DTest #OverlayTest -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/mitkLabelOverlay3DRendering3DTest.png #corresponding reference screenshot ) mitkAddCustomModuleTest(mitkTextOverlay2DRenderingTest_ball mitkTextOverlay2DRenderingTest #OverlayTest ${MITK_DATA_DIR}/ball.stl #input image to load in data storage -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/mitkTextOverlay2DRenderingTest_ball.png #corresponding reference screenshot ) mitkAddCustomModuleTest(mitkTextOverlay2DLayouterRenderingTest_ball mitkTextOverlay2DLayouterRenderingTest #OverlayTest ${MITK_DATA_DIR}/ball.stl #input image to load in data storage -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/mitkTextOverlay2DLayouterRenderingTest_ball.png #corresponding reference screenshot ) mitkAddCustomModuleTest(mitkTextOverlay3DRendering2DTest_ball mitkTextOverlay3DRendering2DTest #OverlayTest ${MITK_DATA_DIR}/ball.stl #input image to load in data storage -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/mitkTextOverlay3DRendering2DTest_ball.png #corresponding reference screenshot ) mitkAddCustomModuleTest(mitkTextOverlay3DRendering3DTest_ball mitkTextOverlay3DRendering3DTest #OverlayTest ${MITK_DATA_DIR}/ball.stl #input image to load in data storage -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/mitkTextOverlay3DRendering3DTest_ball.png #corresponding reference screenshot ) mitkAddCustomModuleTest(mitkTextOverlay3DColorRenderingTest_ball mitkTextOverlay3DColorRenderingTest #OverlayTest ${MITK_DATA_DIR}/ball.stl #input image to load in data storage -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/mitkTextOverlay3DColorRenderingTest_ball.png #corresponding reference screenshot ) ##End of overlayTests # Testing of the rendering of binary images mitkAddCustomModuleTest(mitkImageVtkMapper2D_binaryTestImage640x480 mitkImageVtkMapper2DTest #test for standard Pic3D axial slice ${MITK_DATA_DIR}/RenderingTestData/binaryImage.nrrd #input image to load in data storage -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/binaryImage640x480REF.png #corresponding reference screenshot ) mitkAddCustomModuleTest(mitkImageVtkMapper2D_binaryTestImageWithRef640x480 mitkImageVtkMapper2DTest #test for standard Pic3D axial slice ${MITK_DATA_DIR}/Pic3D.nrrd ${MITK_DATA_DIR}/RenderingTestData/binaryImage.nrrd #input image to load in data storage -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/binaryImageWithRef640x480REF.png #corresponding reference screenshot ) # End of binary image tests mitkAddCustomModuleTest(mitkSurfaceVtkMapper3DTest_TextureProperty mitkSurfaceVtkMapper3DTest ${MITK_DATA_DIR}/ToF-Data/Kinect_LiverPhantom.vtp ${MITK_DATA_DIR}/ToF-Data/Kinect_LiverPhantom_RGBImage.nrrd -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/texturedLiver640x480REF.png #corresponding reference screenshot ) mitkAddCustomModuleTest(mitkImageVtkMapper2DTransferFunctionTest_Png2D-bw mitkImageVtkMapper2DTransferFunctionTest ${MITK_DATA_DIR}/Png2D-bw.png -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/Png2D-bw-TransferFunctionRGBImage640x480REF.png #corresponding reference screenshot ) #mitkAddCustomModuleTest(mitkImageVtkMapper2DLookupTableTest_Png2D-bw mitkImageVtkMapper2DLookupTableTest # ${MITK_DATA_DIR}/Png2D-bw.png # -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/Png2D-bw-LookupTableRGBImage640x480REF.png #corresponding reference screenshot #) mitkAddCustomModuleTest(mitkSurfaceGLMapper2DColorTest_RedBall mitkSurfaceGLMapper2DColorTest ${MITK_DATA_DIR}/ball.stl -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/ballColorRed640x480REF.png #corresponding reference screenshot ) mitkAddCustomModuleTest(mitkSurfaceGLMapper2DColorTest_DasArmeSchwein mitkSurfaceGLMapper2DColorTest ${MITK_DATA_DIR}/binary.stl -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/binaryColorRed640x480REF.png #corresponding reference screenshot ) mitkAddCustomModuleTest(mitkSurfaceGLMapper2DOpacityTest_BallOpacity mitkSurfaceGLMapper2DOpacityTest #opacity = 50% (0.5) ${MITK_DATA_DIR}/ball.stl -V ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/ballOpacity640x480REF.png #corresponding reference screenshot ) #Removed due to high rendering error. #mitkAddCustomModuleTest(mitkSurfaceVtkMapper3DTexturedSphereTest_Football mitkSurfaceVtkMapper3DTexturedSphereTest # ${MITK_DATA_DIR}/RenderingTestData/texture.jpg #input texture # -V # ${MITK_DATA_DIR}/RenderingTestData/ReferenceScreenshots/texturedSphere640x480REF.png corresponding reference screenshot #) SET_PROPERTY(TEST mitkImageVtkMapper2D_rgbaImage640x480 mitkImageVtkMapper2D_pic3d640x480 mitkImageVtkMapper2D_pic3dColorBlue640x480 mitkImageVtkMapper2D_pic3dLevelWindow640x480 mitkImageVtkMapper2D_pic3dSwivel640x480 mitkImageVtkMapper2DTransferFunctionTest_Png2D-bw mitkImageVtkMapper2D_pic3dOpacity640x480 mitkSurfaceGLMapper2DOpacityTest_BallOpacity mitkSurfaceGLMapper2DColorTest_DasArmeSchwein mitkSurfaceGLMapper2DColorTest_RedBall mitkSurfaceVtkMapper3DTest_TextureProperty mitkPointSetVtkMapper2D_Pic3DPointSetForPic3D640x480 mitkPointSetVtkMapper2D_openMeAlone640x480 mitkPointSetVtkMapper2D_openMeAloneGlyphType640x480 mitkPointSetVtkMapper2D_openMeAloneTransformed640x480 #mitkSurfaceVtkMapper3DTexturedSphereTest_Football PROPERTY RUN_SERIAL TRUE) endif() add_test(mitkPointSetLocaleTest ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} mitkPointSetLocaleTest ${MITK_DATA_DIR}/pointSet.mps) set_property(TEST mitkPointSetLocaleTest PROPERTY LABELS MITK-Core) add_test(mitkImageWriterTest_nrrdImage ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} mitkImageWriterTest ${MITK_DATA_DIR}/NrrdWritingTestImage.jpg) add_test(mitkImageWriterTest_2DPNGImage ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} mitkImageWriterTest ${MITK_DATA_DIR}/Png2D-bw.png) add_test(mitkImageWriterTest_rgbPNGImage ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} mitkImageWriterTest ${MITK_DATA_DIR}/RenderingTestData/rgbImage.png) add_test(mitkImageWriterTest_rgbaPNGImage ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} mitkImageWriterTest ${MITK_DATA_DIR}/RenderingTestData/rgbaImage.png) set_property(TEST mitkImageWriterTest_nrrdImage PROPERTY LABELS MITK-Core) set_property(TEST mitkImageWriterTest_2DPNGImage PROPERTY LABELS MITK-Core) set_property(TEST mitkImageWriterTest_rgbPNGImage PROPERTY LABELS MITK-Core) set_property(TEST mitkImageWriterTest_rgbaPNGImage PROPERTY LABELS MITK-Core) add_subdirectory(DICOMTesting) diff --git a/Core/Code/Testing/mitkDICOMLocaleTest.cpp b/Core/Code/Testing/mitkDICOMLocaleTest.cpp index 8890ef1428..7c62936cab 100644 --- a/Core/Code/Testing/mitkDICOMLocaleTest.cpp +++ b/Core/Code/Testing/mitkDICOMLocaleTest.cpp @@ -1,131 +1,147 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ /* This test is meant to reproduce the following error: - The machine or current user has a German locale. - This esp. means that stream IO expects the decimal separator as a comma: "," - DICOM files use a point "." as the decimal separator to be locale independent - The parser used by MITK (ITK's GDCM) seems to use the current locale instead of the "C" or "POSIX" locale - This leads to spacings (and probably other numbers) being trimmed/rounded, e.g. the correct spacing of 0.314 is read as 1.0 etc. */ #include "mitkDataNodeFactory.h" #include "mitkStandardFileLocations.h" #include "mitkDicomSeriesReader.h" #include "mitkTestingMacros.h" +#include "mitkTestFixture.h" #include #include #include -bool mitkDICOMLocaleTestChangeLocale(const std::string& locale) +class mitkDICOMLocaleTestSuite : public mitk::TestFixture { - try - { - MITK_TEST_OUTPUT(<< " ** Changing locale from " << setlocale(LC_ALL, NULL) << " to '" << locale << "'"); - setlocale(LC_ALL, locale.c_str()); - std::locale l( locale.c_str() ); - std::cin.imbue(l); - return true; - } - catch(...) - { - MITK_TEST_OUTPUT(<< "Could not activate locale " << locale); - return false; - } + CPPUNIT_TEST_SUITE(mitkDICOMLocaleTestSuite); + CPPUNIT_TEST_SUITE_ADD_CUSTOM_TESTS(addDICOMLocaleWithReferenceImageTests); + CPPUNIT_TEST_SUITE_END(); -} +private: -void mitkDICOMLocaleTestWithReferenceImage(std::string filename) -{ - mitk::Image::Pointer image; - mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New(); - factory->SetFileName( filename ); - factory->Update(); - MITK_TEST_CONDITION_REQUIRED(factory->GetNumberOfOutputs() > 0, "file " << filename << " loaded"); - - mitk::DataNode::Pointer node = factory->GetOutput( 0 ); - image = dynamic_cast(node->GetData()); - if(image.IsNull()) + // A custom method for adding a combination of filename and locale tests + static void addDICOMLocaleWithReferenceImageTests(TestSuiteBuilderContextType& context) { - MITK_TEST_FAILED_MSG(<< "File "<< filename << " is not an image - test will not be applied." ); - - return; + std::vector fileArgs; + fileArgs.push_back("spacing-ok-ct.dcm"); + fileArgs.push_back("spacing-ok-mr.dcm"); + fileArgs.push_back("spacing-ok-sc.dcm"); + + // load a reference DICOM file with German locales being set + std::vector localeArgs; + localeArgs.push_back("C"); + localeArgs.push_back("de_DE"); + localeArgs.push_back("de_DE.utf8"); + localeArgs.push_back("de_DE.UTF8"); + localeArgs.push_back("de_DE@euro"); + localeArgs.push_back("German_Germany"); + + for (std::size_t fileIndex = 0; fileIndex < fileArgs.size(); ++fileIndex) + { + for (std::size_t localeIndex = 0; localeIndex < localeArgs.size(); ++localeIndex) + { + MITK_PARAMETERIZED_TEST_2(testLocaleWithReferenceImage, fileArgs[fileIndex], localeArgs[localeIndex]); + } + } } - // note importance of minor differences in spacings: - // DICOM has order y-spacing, x-spacing, while in MITK we assume x-spacing, y-spacing (both meant for 0 and 1 index in array) - MITK_TEST_CONDITION_REQUIRED(mitk::Equal(image->GetGeometry()->GetSpacing()[0], 0.3141592, 0.000001), "correct x spacing? found " - << image->GetGeometry()->GetSpacing()[0]); - MITK_TEST_CONDITION_REQUIRED(mitk::Equal(image->GetGeometry()->GetSpacing()[1], 0.3411592, 0.000001), "correct y spacing? found " - << image->GetGeometry()->GetSpacing()[1]); -} +private: -int mitkDICOMLocaleTest(int argc, char* argv[]) -{ - MITK_TEST_BEGIN("DICOMLocaleTest"); + std::string m_FileName; + std::string m_Locale; + bool m_SkipImageTest; - MITK_TEST_CONDITION_REQUIRED(argc >= 2, "File to load has been specified on commandline"); + char* m_OldLocale; - MITK_TEST_OUTPUT(<< "Configuration: \n" << mitk::DicomSeriesReader::GetConfigurationString() ); + void SetTestParameter() + { + std::vector parameter = GetTestParameter(); + CPPUNIT_ASSERT(parameter.size() == 2); + m_FileName = GetTestDataFilePath(parameter[0]); + m_Locale = parameter[1]; + } - std::string filename = argv[1]; +public: - // load a reference DICOM file with the "C" locale being set - mitkDICOMLocaleTestChangeLocale("C"); - mitkDICOMLocaleTestWithReferenceImage(filename); - // load a reference DICOM file with German locales being set - typedef std::list StringList; - StringList alllocales; - alllocales.push_back("de_DE"); - alllocales.push_back("de_DE.utf8"); - alllocales.push_back("de_DE.UTF8"); - alllocales.push_back("de_DE@euro"); - alllocales.push_back("German_Germany"); + mitkDICOMLocaleTestSuite() : m_OldLocale(NULL) {} - // supressing this test to be run on MacOS X - // See bug #3894 -#if defined (__APPLE__) || defined(MACOSX) - alllocales.push_back("C"); -#endif - unsigned int numberOfTestedGermanLocales(0); - for (StringList::iterator iter = alllocales.begin(); - iter != alllocales.end(); - ++iter) + // Change the current locale to m_Locale + void setUp() { - if ( mitkDICOMLocaleTestChangeLocale(*iter) ) + m_SkipImageTest = false; + m_OldLocale = NULL; + SetTestParameter(); + + try + { + m_OldLocale = setlocale(LC_ALL, NULL); + MITK_TEST_OUTPUT(<< " ** Changing locale from " << m_OldLocale << " to '" << m_Locale << "'") + setlocale(LC_ALL, m_Locale.c_str()); + std::cin.imbue(std::locale(m_Locale.c_str())); + } + catch(...) { - ++numberOfTestedGermanLocales; - mitkDICOMLocaleTestWithReferenceImage(filename); + MITK_TEST_OUTPUT(<< "Could not activate locale " << m_Locale) + m_SkipImageTest = true; } } - if(numberOfTestedGermanLocales == 0) + void tearDown() { - MITK_TEST_OUTPUT(<< "Warning: No German locale was found on the system."); + if (m_OldLocale) + { + setlocale(LC_ALL, m_OldLocale); + std::cin.imbue(std::locale(m_OldLocale)); + } } - //MITK_TEST_CONDITION_REQUIRED( numberOfTestedGermanLocales > 0, "Verify that at least one German locale has been tested."); - MITK_TEST_END(); -} + void testLocaleWithReferenceImage() + { + if (m_SkipImageTest) return; + + mitk::Image::Pointer image; + mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New(); + factory->SetFileName( m_FileName ); + factory->Update(); + CPPUNIT_ASSERT(factory->GetNumberOfOutputs() > 0); + + mitk::DataNode::Pointer node = factory->GetOutput( 0 ); + image = dynamic_cast(node->GetData()); + CPPUNIT_ASSERT(image.IsNotNull()); + + // note importance of minor differences in spacings: + // DICOM has order y-spacing, x-spacing, while in MITK we assume x-spacing, y-spacing (both meant for 0 and 1 index in array) + CPPUNIT_ASSERT_MESSAGE("incorrect x spacing", mitk::Equal(image->GetGeometry()->GetSpacing()[0], 0.3141592)); + CPPUNIT_ASSERT_MESSAGE("incorrect y spacing ", mitk::Equal(image->GetGeometry()->GetSpacing()[1], 0.3411592)); + } +}; +MITK_TEST_SUITE_REGISTRATION(mitkDICOMLocale) diff --git a/Core/Code/Testing/mitkGeometry3DEqualTest.cpp b/Core/Code/Testing/mitkGeometry3DEqualTest.cpp index 38467b6576..3a0b591113 100644 --- a/Core/Code/Testing/mitkGeometry3DEqualTest.cpp +++ b/Core/Code/Testing/mitkGeometry3DEqualTest.cpp @@ -1,126 +1,125 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkGeometry3D.h" #include "mitkTestingMacros.h" +#include "mitkTestFixture.h" -/** Members used inside the different (sub-)tests. All members are initialized via Setup().*/ -mitk::Geometry3D::Pointer m_Geometry3D; -mitk::Geometry3D::Pointer m_AnotherGeometry3D; - -/** -* @brief Setup Always call this method before each Test-case to ensure correct and new intialization of the used members for a new test case. (If the members are not used in a test, the method does not need to be called). -*/ -static void Setup() -{ - m_Geometry3D = mitk::Geometry3D::New(); - m_Geometry3D->Initialize(); - m_AnotherGeometry3D = m_Geometry3D->Clone(); -} - -static void Equal_CloneAndOriginal_ReturnsTrue() -{ - Setup(); - MITK_TEST_EQUAL( m_Geometry3D, m_AnotherGeometry3D, "A clone should be equal to its original."); -} - -static void Equal_DifferentOrigin_ReturnsFalse() -{ - Setup(); - - mitk::Point3D origin; - origin[0] = 0.0; - origin[1] = 0.0; - origin[2] = 1.0 + 2*mitk::eps; - m_AnotherGeometry3D->SetOrigin(origin); - - MITK_TEST_NOT_EQUAL( m_Geometry3D, m_AnotherGeometry3D, "Origin was modified. Result should be false."); -} - -static void Equal_DifferentIndexToWorldTransform_ReturnsFalse() -{ - Setup(); - - //Create another index to world transform and make it different somehow - mitk::AffineTransform3D::Pointer differentIndexToWorldTransform = mitk::AffineTransform3D::New(); - - mitk::AffineTransform3D::MatrixType differentMatrix; - differentMatrix.SetIdentity(); - differentMatrix(1,1) = 2; - - differentIndexToWorldTransform->SetMatrix( differentMatrix ); - m_AnotherGeometry3D->SetIndexToWorldTransform(differentIndexToWorldTransform); - - MITK_TEST_NOT_EQUAL( m_Geometry3D, m_AnotherGeometry3D, "IndexToWorldTransform was modified. Result should be false."); -} - -static void Equal_DifferentSpacing_ReturnsFalse() -{ - Setup(); - - mitk::Vector3D differentSpacing; - differentSpacing[0] = 1.0; - differentSpacing[1] = 1.0 + 2*mitk::eps; - differentSpacing[2] = 1.0; - - m_AnotherGeometry3D->SetSpacing(differentSpacing); - - MITK_TEST_NOT_EQUAL( m_Geometry3D, m_AnotherGeometry3D, "Spacing was modified. Result should be false."); -} - -static void Equal_InputIsNull_ReturnsFalse() +class mitkGeometry3DEqualTestSuite : public mitk::TestFixture { - mitk::Geometry3D::Pointer geometry3D = NULL; - MITK_TEST_NOT_EQUAL( geometry3D, geometry3D, "Input is NULL. Result should be false."); -} -static void Equal_DifferentImageGeometry_ReturnsFalse() -{ - Setup(); + CPPUNIT_TEST_SUITE(mitkGeometry3DEqualTestSuite); + MITK_TEST(Equal_CloneAndOriginal_ReturnsTrue); + MITK_TEST(Equal_DifferentOrigin_ReturnsFalse); + MITK_TEST(Equal_DifferentIndexToWorldTransform_ReturnsFalse); + MITK_TEST(Equal_DifferentSpacing_ReturnsFalse); + MITK_TEST(Equal_InputIsNull_ReturnsFalse); + MITK_TEST(Equal_DifferentImageGeometry_ReturnsFalse); + MITK_TEST(Equal_DifferentBoundingBox_ReturnsFalse); + CPPUNIT_TEST_SUITE_END(); - m_AnotherGeometry3D->SetImageGeometry(true); +private: - MITK_TEST_NOT_EQUAL( m_Geometry3D, m_AnotherGeometry3D, "One Geometry is image, the other is not. Result should be false."); -} + /** Members used inside the different test methods. All members are initialized via setUp().*/ + mitk::Geometry3D::Pointer m_Geometry3D; + mitk::Geometry3D::Pointer m_AnotherGeometry3D; -static void Equal_DifferentBoundingBox_ReturnsFalse() -{ - Setup(); +public: + /** +* @brief Setup Always call this method before each Test-case to ensure correct and new intialization of the used members for a new test case. (If the members are not used in a test, the method does not need to be called). +*/ + void setUp() + { + m_Geometry3D = mitk::Geometry3D::New(); + m_Geometry3D->Initialize(); + m_AnotherGeometry3D = m_Geometry3D->Clone(); + } + + void tearDown() + { + m_Geometry3D = NULL; + m_AnotherGeometry3D = NULL; + } + + void Equal_CloneAndOriginal_ReturnsTrue() + { + MITK_ASSERT_EQUAL( m_Geometry3D, m_AnotherGeometry3D, "A clone should be equal to its original."); + } + + void Equal_DifferentOrigin_ReturnsFalse() + { + mitk::Point3D origin; + origin[0] = 0.0; + origin[1] = 0.0; + origin[2] = 1.0 + 2*mitk::eps; + m_AnotherGeometry3D->SetOrigin(origin); + + MITK_ASSERT_NOT_EQUAL( m_Geometry3D, m_AnotherGeometry3D, "Origin was modified. Result should be false."); + } + + void Equal_DifferentIndexToWorldTransform_ReturnsFalse() + { + //Create another index to world transform and make it different somehow + mitk::AffineTransform3D::Pointer differentIndexToWorldTransform = mitk::AffineTransform3D::New(); + + mitk::AffineTransform3D::MatrixType differentMatrix; + differentMatrix.SetIdentity(); + differentMatrix(1,1) = 2; + + differentIndexToWorldTransform->SetMatrix( differentMatrix ); + m_AnotherGeometry3D->SetIndexToWorldTransform(differentIndexToWorldTransform); + + MITK_ASSERT_NOT_EQUAL( m_Geometry3D, m_AnotherGeometry3D, "IndexToWorldTransform was modified. Result should be false."); + } + + void Equal_DifferentSpacing_ReturnsFalse() + { + mitk::Vector3D differentSpacing; + differentSpacing[0] = 1.0; + differentSpacing[1] = 1.0 + 2*mitk::eps; + differentSpacing[2] = 1.0; + + m_AnotherGeometry3D->SetSpacing(differentSpacing); + + MITK_ASSERT_NOT_EQUAL( m_Geometry3D, m_AnotherGeometry3D, "Spacing was modified. Result should be false."); + } + + void Equal_InputIsNull_ReturnsFalse() + { + mitk::Geometry3D::Pointer geometry3D = NULL; + MITK_ASSERT_NOT_EQUAL( geometry3D, geometry3D, "Input is NULL. Result should be false."); + } + + void Equal_DifferentImageGeometry_ReturnsFalse() + { + m_AnotherGeometry3D->SetImageGeometry(true); + + MITK_ASSERT_NOT_EQUAL( m_Geometry3D, m_AnotherGeometry3D, "One Geometry is image, the other is not. Result should be false."); + } + + void Equal_DifferentBoundingBox_ReturnsFalse() + { //create different bounds to make the comparison false mitk::ScalarType bounds[ ] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; m_AnotherGeometry3D->SetBounds(bounds); - MITK_TEST_NOT_EQUAL( m_Geometry3D, m_AnotherGeometry3D, "Bounds are different. Result should be false."); -} + MITK_ASSERT_NOT_EQUAL( m_Geometry3D, m_AnotherGeometry3D, "Bounds are different. Result should be false."); + } -/** - * @brief mitkGeometry3DEqualTest A test class for Equal methods in mitk::Geometry3D. - */ -int mitkGeometry3DEqualTest(int /*argc*/, char* /*argv*/[]) -{ - MITK_TEST_BEGIN(mitkGeometry3DEqualTest); - - Equal_CloneAndOriginal_ReturnsTrue(); - Equal_InputIsNull_ReturnsFalse(); - Equal_DifferentSpacing_ReturnsFalse(); - Equal_DifferentImageGeometry_ReturnsFalse(); - Equal_DifferentOrigin_ReturnsFalse(); - Equal_DifferentIndexToWorldTransform_ReturnsFalse(); - Equal_DifferentBoundingBox_ReturnsFalse(); - - MITK_TEST_END(); -} +}; + +MITK_TEST_SUITE_REGISTRATION(mitkGeometry3DEqual) diff --git a/Core/Code/Testing/mitkIOUtilTest.cpp b/Core/Code/Testing/mitkIOUtilTest.cpp index 8fd4858f4a..5eb29dcf85 100644 --- a/Core/Code/Testing/mitkIOUtilTest.cpp +++ b/Core/Code/Testing/mitkIOUtilTest.cpp @@ -1,134 +1,174 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkTestingMacros.h" #include +#include + #include #include #include -void TestTempMethods() -{ - std::string tmpPath = mitk::IOUtil::GetTempPath(); - MITK_TEST_CONDITION_REQUIRED(!tmpPath.empty(), "Get temporary path") - - std::ofstream tmpFile; - std::string tmpFilePath = mitk::IOUtil::CreateTemporaryFile(tmpFile); - MITK_TEST_CONDITION_REQUIRED(tmpFile && tmpFile.is_open(), "Temp file stream"); - MITK_TEST_CONDITION_REQUIRED(tmpFilePath.size() > tmpPath.size(), "Temp file path size") - MITK_TEST_CONDITION(tmpFilePath.substr(0, tmpPath.size()) == tmpPath, "Temp file is in temp path") - - tmpFile.close(); - MITK_TEST_CONDITION(std::remove(tmpFilePath.c_str()) == 0, "Remove temp file") - - std::string programPath = mitk::IOUtil::GetProgramPath(); - MITK_TEST_CONDITION_REQUIRED(!programPath.empty(), "Get program file path") - std::ofstream tmpFile2; - std::string tmpFilePath2 = mitk::IOUtil::CreateTemporaryFile(tmpFile2, "my-XXXXXX", programPath); - MITK_TEST_CONDITION_REQUIRED(tmpFile2 && tmpFile2.is_open(), "Temp file 2 stream") - MITK_TEST_CONDITION_REQUIRED(tmpFilePath2.size() > programPath.size(), "Temp file 2 path size") - MITK_TEST_CONDITION(tmpFilePath2.substr(0, programPath.size()) == programPath, "Temp file 2 is in program path") - tmpFile2.close(); - MITK_TEST_CONDITION(std::remove(tmpFilePath2.c_str()) == 0, "Remove temp file 2") - - std::ofstream tmpFile3; - std::string tmpFilePath3 = mitk::IOUtil::CreateTemporaryFile(tmpFile3, std::ios_base::binary, - "my-XXXXXX.TXT", programPath); - MITK_TEST_CONDITION_REQUIRED(tmpFile3 && tmpFile3.is_open(), "Temp file 3 stream") - MITK_TEST_CONDITION_REQUIRED(tmpFilePath3.size() > programPath.size(), "Temp file 3 path size") - MITK_TEST_CONDITION(tmpFilePath3.substr(0, programPath.size()) == programPath, "Temp file 23 is in program path") - MITK_TEST_CONDITION(tmpFilePath3.substr(tmpFilePath3.size() - 13, 3) == "my-", "Temp file 3 starts with 'my-'") - MITK_TEST_CONDITION(tmpFilePath3.substr(tmpFilePath3.size() - 4) == ".TXT", "Temp file 3 ends with '.TXT'") - tmpFile3.close(); - //MITK_TEST_CONDITION(std::remove(tmpFilePath3.c_str()) == 0, "Remove temp file 3") - - MITK_TEST_FOR_EXCEPTION(mitk::Exception&, mitk::IOUtil::CreateTemporaryFile(tmpFile2, "XX")) - - std::string tmpDir = mitk::IOUtil::CreateTemporaryDirectory(); - MITK_TEST_CONDITION_REQUIRED(tmpDir.size() > tmpPath.size(), "Temp dir size") - MITK_TEST_CONDITION(tmpDir.substr(0, tmpPath.size()) == tmpPath, "Temp dir is in temp path") - MITK_TEST_CONDITION(itksys::SystemTools::RemoveADirectory(tmpDir.c_str()), "Remove temp dir") - - std::string tmpDir2 = mitk::IOUtil::CreateTemporaryDirectory("my-XXXXXX", programPath); - MITK_TEST_CONDITION_REQUIRED(tmpDir2.size() > programPath.size(), "Temp dir 2 size") - MITK_TEST_CONDITION(tmpDir2.substr(0, programPath.size()) == programPath, "Temp dir 2 is in temp path") - MITK_TEST_CONDITION(itksys::SystemTools::RemoveADirectory(tmpDir2.c_str()), "Remove temp dir 2") -} - -int mitkIOUtilTest(int argc , char* argv[]) +class mitkIOUtilTestSuite : public mitk::TestFixture { - // always start with this! - MITK_TEST_BEGIN("mitkIOUtilTest"); - MITK_TEST_CONDITION_REQUIRED( argc >= 4, "Testing if input parameters are set."); - - TestTempMethods(); - - std::string pathToImage = argv[1]; - std::string pathToPointSet = argv[2]; - std::string pathToSurface = argv[3]; - - mitk::Image::Pointer img1 = mitk::IOUtil::LoadImage(pathToImage); - MITK_TEST_CONDITION( img1.IsNotNull(), "Testing if image 1 could be loaded"); - mitk::PointSet::Pointer pointset = mitk::IOUtil::LoadPointSet(pathToPointSet); - MITK_TEST_CONDITION( pointset.IsNotNull(), "Testing if pointset could be loaded"); - mitk::Surface::Pointer surface = mitk::IOUtil::LoadSurface(pathToSurface); - MITK_TEST_CONDITION( surface.IsNotNull(), "Testing if surface could be loaded"); - - std::string outDir = MITK_TEST_OUTPUT_DIR; - std::string imagePath = outDir+"/diffpic3d.nrrd"; - std::string imagePath2 = outDir+"/diffpic3d.nii.gz"; - std::string pointSetPath = outDir + "/diffpointset.mps"; - std::string surfacePath = outDir + "/diffsurface.stl"; - std::string pointSetPathWithDefaultExtension = outDir + "/diffpointset2.mps"; - std::string pointSetPathWithoutDefaultExtension = outDir + "/diffpointset2.xXx"; + + CPPUNIT_TEST_SUITE(mitkIOUtilTestSuite); + MITK_TEST(TestTempMethods); + MITK_TEST(TestLoadAndSaveImage); + MITK_TEST(TestLoadAndSavePointSet); + MITK_TEST(TestLoadAndSaveSurface); + CPPUNIT_TEST_SUITE_END(); + +private: + + std::string m_ImagePath; + std::string m_SurfacePath; + std::string m_PointSetPath; + +public: + + void setUp() + { + m_ImagePath = GetTestDataFilePath("Pic3D.nrrd"); + m_SurfacePath = GetTestDataFilePath("binary.stl"); + m_PointSetPath = GetTestDataFilePath("pointSet.mps"); + } + + void TestTempMethods() + { + std::string tmpPath = mitk::IOUtil::GetTempPath(); + CPPUNIT_ASSERT(!tmpPath.empty()); + + std::ofstream tmpFile; + std::string tmpFilePath = mitk::IOUtil::CreateTemporaryFile(tmpFile); + CPPUNIT_ASSERT(tmpFile && tmpFile.is_open()); + CPPUNIT_ASSERT(tmpFilePath.size() > tmpPath.size()); + CPPUNIT_ASSERT(tmpFilePath.substr(0, tmpPath.size()) == tmpPath); + + tmpFile.close(); + CPPUNIT_ASSERT(std::remove(tmpFilePath.c_str()) == 0); + + std::string programPath = mitk::IOUtil::GetProgramPath(); + CPPUNIT_ASSERT(!programPath.empty()); + std::ofstream tmpFile2; + std::string tmpFilePath2 = mitk::IOUtil::CreateTemporaryFile(tmpFile2, "my-XXXXXX", programPath); + CPPUNIT_ASSERT(tmpFile2 && tmpFile2.is_open()); + CPPUNIT_ASSERT(tmpFilePath2.size() > programPath.size()); + CPPUNIT_ASSERT(tmpFilePath2.substr(0, programPath.size()) == programPath); + tmpFile2.close(); + CPPUNIT_ASSERT(std::remove(tmpFilePath2.c_str()) == 0); + + std::ofstream tmpFile3; + std::string tmpFilePath3 = mitk::IOUtil::CreateTemporaryFile(tmpFile3, std::ios_base::binary, + "my-XXXXXX.TXT", programPath); + CPPUNIT_ASSERT(tmpFile3 && tmpFile3.is_open()); + CPPUNIT_ASSERT(tmpFilePath3.size() > programPath.size()); + CPPUNIT_ASSERT(tmpFilePath3.substr(0, programPath.size()) == programPath); + CPPUNIT_ASSERT(tmpFilePath3.substr(tmpFilePath3.size() - 13, 3) == "my-"); + CPPUNIT_ASSERT(tmpFilePath3.substr(tmpFilePath3.size() - 4) == ".TXT"); + tmpFile3.close(); + //CPPUNIT_ASSERT(std::remove(tmpFilePath3.c_str()) == 0) + + CPPUNIT_ASSERT_THROW(mitk::IOUtil::CreateTemporaryFile(tmpFile2, "XX"), mitk::Exception); + + std::string tmpDir = mitk::IOUtil::CreateTemporaryDirectory(); + CPPUNIT_ASSERT(tmpDir.size() > tmpPath.size()); + CPPUNIT_ASSERT(tmpDir.substr(0, tmpPath.size()) == tmpPath); + CPPUNIT_ASSERT(itksys::SystemTools::RemoveADirectory(tmpDir.c_str())); + + std::string tmpDir2 = mitk::IOUtil::CreateTemporaryDirectory("my-XXXXXX", programPath); + CPPUNIT_ASSERT(tmpDir2.size() > programPath.size()); + CPPUNIT_ASSERT(tmpDir2.substr(0, programPath.size()) == programPath); + CPPUNIT_ASSERT(itksys::SystemTools::RemoveADirectory(tmpDir2.c_str())); + } + + void TestLoadAndSaveImage() + { + mitk::Image::Pointer img1 = mitk::IOUtil::LoadImage(m_ImagePath); + CPPUNIT_ASSERT( img1.IsNotNull()); + + std::ofstream tmpStream; + std::string imagePath = mitk::IOUtil::CreateTemporaryFile(tmpStream, "diffpic3d-XXXXXX.nrrd"); + tmpStream.close(); + std::string imagePath2 = mitk::IOUtil::CreateTemporaryFile(tmpStream, "diffpic3d-XXXXXX.nii.gz"); + tmpStream.close(); + + // the cases where no exception should be thrown + CPPUNIT_ASSERT(mitk::IOUtil::SaveImage(img1, imagePath)); + CPPUNIT_ASSERT(mitk::IOUtil::SaveBaseData(img1.GetPointer(), imagePath2)); + + //load data which does not exist + CPPUNIT_ASSERT_THROW(mitk::IOUtil::LoadImage("fileWhichDoesNotExist.nrrd"), mitk::Exception); + + //delete the files after the test is done + std::remove(imagePath.c_str()); + std::remove(imagePath2.c_str()); + + mitk::Image::Pointer relativImage = mitk::ImageGenerator::GenerateGradientImage(4,4,4,1); + std::string imagePath3 = mitk::IOUtil::CreateTemporaryFile(tmpStream, "XXXXXX.nrrd"); + tmpStream.close(); + mitk::IOUtil::SaveImage(relativImage, imagePath3); + CPPUNIT_ASSERT_NO_THROW(mitk::IOUtil::LoadImage(imagePath3)); + std::remove(imagePath3.c_str()); + } + + void TestLoadAndSavePointSet() + { + mitk::PointSet::Pointer pointset = mitk::IOUtil::LoadPointSet(m_PointSetPath); + CPPUNIT_ASSERT( pointset.IsNotNull()); + + std::ofstream tmpStream; + std::string pointSetPath = mitk::IOUtil::CreateTemporaryFile(tmpStream, "XXXXXX.mps"); + tmpStream.close(); + std::string pointSetPathWithDefaultExtension = mitk::IOUtil::CreateTemporaryFile(tmpStream, "XXXXXX.mps"); + tmpStream.close(); + std::string pointSetPathWithoutDefaultExtension = mitk::IOUtil::CreateTemporaryFile(tmpStream, "XXXXXX.xXx"); + tmpStream.close(); // the cases where no exception should be thrown - MITK_TEST_CONDITION(mitk::IOUtil::SaveImage(img1, imagePath), "Testing if the image could be saved"); - MITK_TEST_CONDITION(mitk::IOUtil::SaveBaseData(img1.GetPointer(), imagePath2), "Testing if the image could be saved"); - MITK_TEST_CONDITION(mitk::IOUtil::SavePointSet(pointset, pointSetPath), "Testing if the pointset could be saved"); - MITK_TEST_CONDITION(mitk::IOUtil::SaveSurface(surface, surfacePath), "Testing if the surface could be saved"); + CPPUNIT_ASSERT(mitk::IOUtil::SavePointSet(pointset, pointSetPathWithDefaultExtension)); // test if defaultextension is inserted if no extension is present - MITK_TEST_CONDITION(mitk::IOUtil::SavePointSet(pointset, pointSetPathWithoutDefaultExtension.c_str()), "Testing if the pointset could be saved"); + CPPUNIT_ASSERT(mitk::IOUtil::SavePointSet(pointset, pointSetPathWithoutDefaultExtension.c_str())); + + //delete the files after the test is done + std::remove(pointSetPath.c_str()); + std::remove(pointSetPathWithDefaultExtension.c_str()); + std::remove(pointSetPathWithoutDefaultExtension.c_str()); + } + + void TestLoadAndSaveSurface() + { + mitk::Surface::Pointer surface = mitk::IOUtil::LoadSurface(m_SurfacePath); + CPPUNIT_ASSERT( surface.IsNotNull()); + + std::ofstream tmpStream; + std::string surfacePath = mitk::IOUtil::CreateTemporaryFile(tmpStream, "diffsurface-XXXXXX.stl"); + + // the cases where no exception should be thrown + CPPUNIT_ASSERT(mitk::IOUtil::SaveSurface(surface, surfacePath)); // test if exception is thrown as expected on unknown extsension - MITK_TEST_FOR_EXCEPTION(mitk::Exception, mitk::IOUtil::SaveSurface(surface,"testSurface.xXx")); - //load data which does not exist - MITK_TEST_FOR_EXCEPTION(mitk::Exception, mitk::IOUtil::LoadImage("fileWhichDoesNotExist.nrrd")); + CPPUNIT_ASSERT_THROW(mitk::IOUtil::SaveSurface(surface,"testSurface.xXx"), mitk::Exception); //delete the files after the test is done - remove(imagePath.c_str()); - remove(pointSetPath.c_str()); - remove(surfacePath.c_str()); - //remove the pointset with default extension and not the one without - remove(pointSetPathWithDefaultExtension.c_str()); + std::remove(surfacePath.c_str()); + } - mitk::Image::Pointer relativImage = mitk::ImageGenerator::GenerateGradientImage(4,4,4,1); - mitk::IOUtil::SaveImage(relativImage, "tempfile.nrrd"); - try - { - mitk::IOUtil::LoadImage("tempfile.nrrd"); - MITK_TEST_CONDITION(true, "Temporary image is in right place"); - remove("tempfile.nrrd"); - } - catch (mitk::Exception &e) - { - MITK_TEST_CONDITION(false, "Temporary image is in right place"); - } - - MITK_TEST_END(); -} +}; + +MITK_TEST_SUITE_REGISTRATION(mitkIOUtil) diff --git a/Core/Code/Testing/mitkImageEqualTest.cpp b/Core/Code/Testing/mitkImageEqualTest.cpp index f4cf2f1612..4d2d80125c 100644 --- a/Core/Code/Testing/mitkImageEqualTest.cpp +++ b/Core/Code/Testing/mitkImageEqualTest.cpp @@ -1,119 +1,120 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkImage.h" #include "mitkImageGenerator.h" #include "mitkTestingMacros.h" #include "mitkImageSliceSelector.h" -/** Members used inside the different (sub-)tests. All members are initialized via Setup().*/ -mitk::Image::Pointer m_Image; -mitk::Image::Pointer m_AnotherImage; +#include "mitkTestFixture.h" -/** -* @brief Setup Always call this method before each Test-case to ensure correct and new intialization of the used members for a new test case. (If the members are not used in a test, the method does not need to be called). -*/ -static void Setup() -{ - //generate a gradient test image - m_Image = mitk::ImageGenerator::GenerateGradientImage(3u, 3u, 1u); - m_AnotherImage = m_Image->Clone(); -} - -void Equal_CloneAndOriginal_ReturnsTrue() +class mitkImageEqualTestSuite : public mitk::TestFixture { - Setup(); - MITK_TEST_EQUAL( m_Image, m_AnotherImage, "A clone should be equal to its original."); -} -static void Equal_InputIsNull_ReturnsFalse() -{ - mitk::Image::Pointer image = NULL; - MITK_TEST_NOT_EQUAL( image, image, "Input is NULL. Result should be false."); -} - -static void Equal_DifferentImageGeometry_ReturnsFalse() -{ - Setup(); + CPPUNIT_TEST_SUITE(mitkImageEqualTestSuite); + MITK_TEST(Equal_CloneAndOriginal_ReturnsTrue); + MITK_TEST(Equal_InputIsNull_ReturnsFalse); + MITK_TEST(Equal_DifferentImageGeometry_ReturnsFalse); + MITK_TEST(Equal_DifferentPixelTypes_ReturnsFalse); + MITK_TEST(Equal_DifferentDimensions_ReturnsFalse); + MITK_TEST(Equal_DifferentDimensionalities_ReturnsFalse); + MITK_TEST(Equal_DifferentPixelValues_ReturnsFalse); + CPPUNIT_TEST_SUITE_END(); - mitk::Point3D origin; - origin[0] = 0.0; - origin[1] = 0.0; - origin[2] = mitk::eps * 1.01; +private: - m_AnotherImage->GetGeometry()->SetOrigin(origin); + /** Members used inside the different (sub-)tests. All members are initialized via setUp().*/ + mitk::Image::Pointer m_Image; + mitk::Image::Pointer m_AnotherImage; - MITK_TEST_NOT_EQUAL( m_Image, m_AnotherImage, "One origin was modified. Result should be false."); -} - -static void Equal_DifferentPixelTypes_ReturnsFalse() -{ - Setup(); - - m_AnotherImage = mitk::ImageGenerator::GenerateGradientImage(3u, 3u, 1u); - - MITK_TEST_NOT_EQUAL( m_Image, m_AnotherImage, "One pixel type is float, the other unsigned char. Result should be false."); -} - -static void Equal_DifferentDimensions_ReturnsFalse() -{ - Setup(); +public: - m_AnotherImage = mitk::ImageGenerator::GenerateGradientImage(5u, 7u, 3u); - - MITK_TEST_NOT_EQUAL( m_Image, m_AnotherImage, "Dimensions of first image are: (3, 3, 1). Dimensions of second image are: (5, 7, 3). Result should be false."); -} - -static void Equal_DifferentDimensionalities_ReturnsFalse() -{ - Setup(); - - //Select the first slice of a 2D image and compare it to the 3D original - mitk::ImageSliceSelector::Pointer sliceSelector = mitk::ImageSliceSelector::New(); - sliceSelector->SetInput( m_Image ); - sliceSelector->SetSliceNr( 0 ); - sliceSelector->Update(); - m_AnotherImage = sliceSelector->GetOutput(); - - MITK_TEST_NOT_EQUAL( m_Image, m_AnotherImage, "First image is 3D. Second image is 2D. Result should be false."); -} - -static void Equal_DifferentPixelValues_ReturnsFalse() -{ - //todo: Replace the random images via simpler images with fixed values. - m_Image = mitk::ImageGenerator::GenerateRandomImage(3u, 3u); - m_AnotherImage = mitk::ImageGenerator::GenerateRandomImage(3u, 3u); - - MITK_TEST_NOT_EQUAL( m_Image, m_AnotherImage, "We compare two random images. Result should be false."); -} - -/** - * @brief mitkImageAreEqualTest A test class for Equal methods in mitk::Image. - */ -int mitkImageEqualTest(int /*argc*/, char* /*argv*/[]) -{ - MITK_TEST_BEGIN(mitkImageAreEqualTest); - - Equal_CloneAndOriginal_ReturnsTrue(); - Equal_InputIsNull_ReturnsFalse(); - Equal_DifferentImageGeometry_ReturnsFalse(); - Equal_DifferentPixelTypes_ReturnsFalse(); - Equal_DifferentDimensions_ReturnsFalse(); - Equal_DifferentDimensionalities_ReturnsFalse(); - Equal_DifferentPixelValues_ReturnsFalse(); - - MITK_TEST_END(); -} + /** +* @brief Setup Always call this method before each Test-case to ensure correct and new intialization of the used members for a new test case. (If the members are not used in a test, the method does not need to be called). +*/ + void setUp() + { + //generate a gradient test image + m_Image = mitk::ImageGenerator::GenerateGradientImage(3u, 3u, 1u); + m_AnotherImage = m_Image->Clone(); + } + + void tearDown() + { + m_Image = NULL; + m_AnotherImage = NULL; + } + + void Equal_CloneAndOriginal_ReturnsTrue() + { + MITK_ASSERT_EQUAL( m_Image, m_Image->Clone(), "A clone should be equal to its original."); + } + + void Equal_InputIsNull_ReturnsFalse() + { + mitk::Image::Pointer image = NULL; + MITK_ASSERT_NOT_EQUAL( image, image, "Input is NULL. Result should be false."); + } + + void Equal_DifferentImageGeometry_ReturnsFalse() + { + mitk::Point3D origin; + origin[0] = 0.0; + origin[1] = 0.0; + origin[2] = mitk::eps * 1.01; + + m_AnotherImage->GetGeometry()->SetOrigin(origin); + + MITK_ASSERT_NOT_EQUAL( m_Image, m_AnotherImage, "One origin was modified. Result should be false."); + } + + void Equal_DifferentPixelTypes_ReturnsFalse() + { + m_AnotherImage = mitk::ImageGenerator::GenerateGradientImage(3u, 3u, 1u); + + MITK_ASSERT_NOT_EQUAL( m_Image, m_AnotherImage, "One pixel type is float, the other unsigned char. Result should be false."); + } + + void Equal_DifferentDimensions_ReturnsFalse() + { + m_AnotherImage = mitk::ImageGenerator::GenerateGradientImage(5u, 7u, 3u); + + MITK_ASSERT_NOT_EQUAL( m_Image, m_AnotherImage, "Dimensions of first image are: (3, 3, 1). Dimensions of second image are: (5, 7, 3). Result should be false."); + } + + void Equal_DifferentDimensionalities_ReturnsFalse() + { + //Select the first slice of a 2D image and compare it to the 3D original + mitk::ImageSliceSelector::Pointer sliceSelector = mitk::ImageSliceSelector::New(); + sliceSelector->SetInput( m_Image ); + sliceSelector->SetSliceNr( 0 ); + sliceSelector->Update(); + m_AnotherImage = sliceSelector->GetOutput(); + + MITK_ASSERT_NOT_EQUAL( m_Image, m_AnotherImage, "First image is 3D. Second image is 2D. Result should be false."); + } + + void Equal_DifferentPixelValues_ReturnsFalse() + { + //todo: Replace the random images via simpler images with fixed values. + m_Image = mitk::ImageGenerator::GenerateRandomImage(3u, 3u); + m_AnotherImage = mitk::ImageGenerator::GenerateRandomImage(3u, 3u); + + MITK_ASSERT_NOT_EQUAL( m_Image, m_AnotherImage, "We compare two random images. Result should be false."); + } +}; + +MITK_TEST_SUITE_REGISTRATION(mitkImageEqual) diff --git a/Core/Code/Testing/mitkPointSetEqualTest.cpp b/Core/Code/Testing/mitkPointSetEqualTest.cpp index bf98632e93..f308310832 100644 --- a/Core/Code/Testing/mitkPointSetEqualTest.cpp +++ b/Core/Code/Testing/mitkPointSetEqualTest.cpp @@ -1,105 +1,114 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ +#include "mitkPointSet.h" #include "mitkTestingMacros.h" -#include +#include "mitkTestFixture.h" -/** Members used inside the different (sub-)tests. All members are initialized via Setup().*/ -mitk::PointSet::Pointer m_PointSet; -mitk::PointSet::Pointer m_AnotherPointSet; /** -* @brief Setup Always call this method before each Test-case to ensure correct and new intialization of the used members for a new test case. (If the members are not used in a test, the method does not need to be called). -*/ -static void Setup() -{ - m_PointSet = mitk::PointSet::New(); - m_AnotherPointSet = m_PointSet->Clone(); -} - -static void Equal_CloneAndOriginal_ReturnsTrue() -{ - Setup(); - MITK_TEST_EQUAL( m_PointSet, m_AnotherPointSet, "A clone should be equal to its original."); -} - -static void Equal_DifferentGeometries_ReturnsFalse() -{ - Setup(); - - mitk::Point3D origin; - origin[0] = 0.0; - origin[1] = 0.0; - origin[2] = 1.0 + 2*mitk::eps; - m_AnotherPointSet->GetGeometry()->SetOrigin(origin); - - MITK_TEST_NOT_EQUAL( m_PointSet, m_AnotherPointSet, "Origin was modified. Result should be false."); -} - -static void Equal_InputIsNull_ReturnsFalse() -{ - mitk::PointSet::Pointer pointSet = NULL; - MITK_TEST_NOT_EQUAL( pointSet, pointSet, "Input is NULL. Result should be false."); -} - -static void Equal_DifferentNumberOfPoints_ReturnsFalse() -{ - Setup(); - mitk::Point3D tmpPoint; - tmpPoint[0] = 1.0; - tmpPoint[1] = 1.0; - tmpPoint[2] = 1.0; - - m_PointSet->InsertPoint( 1, tmpPoint ); - m_PointSet->InsertPoint( 2, tmpPoint ); - - m_AnotherPointSet->InsertPoint( 1, tmpPoint ); - - MITK_TEST_NOT_EQUAL( m_PointSet, m_AnotherPointSet, "One pointset has two points the other has one. Result should be false."); -} + * @brief mitkPointSetEqualTestSuite A test class for Equal methods in mitk::PointSet. + */ -static void Equal_DifferentPoints_ReturnsFalse() +class mitkPointSetEqualTestSuite : public mitk::TestFixture { - Setup(); - - mitk::Point3D tmpPoint; - tmpPoint[0] = 1.0; - tmpPoint[1] = 1.0; - tmpPoint[2] = 1.0; - m_PointSet->InsertPoint( 1, tmpPoint ); + CPPUNIT_TEST_SUITE(mitkPointSetEqualTestSuite); + MITK_TEST(Equal_CloneAndOriginal_ReturnsTrue); + MITK_TEST(Equal_DifferentGeometries_ReturnsFalse); + MITK_TEST(Equal_DifferentNumberOfPoints_ReturnsFalse); + MITK_TEST(Equal_DifferentPoints_ReturnsFalse); + MITK_TEST(Equal_InputIsNull_ReturnsFalse); + CPPUNIT_TEST_SUITE_END(); - tmpPoint[0] = 1.0 + 2*mitk::eps; - m_AnotherPointSet->InsertPoint( 1, tmpPoint ); +private: - MITK_TEST_NOT_EQUAL( m_PointSet, m_AnotherPointSet, "Two pointsets with different points. Result should be false."); -} + /** Members used inside the different (sub-)tests. All members are initialized via setUp().*/ + mitk::PointSet::Pointer m_PointSet; + mitk::PointSet::Pointer m_AnotherPointSet; -/** - * @brief mitkPointSetEqualTest A test class for Equal methods in mitk::PointSet. - */ -int mitkPointSetEqualTest(int /*argc*/, char* /*argv*/[]) -{ - MITK_TEST_BEGIN(mitkPointSetEqualTest); +public: - Equal_CloneAndOriginal_ReturnsTrue(); - Equal_InputIsNull_ReturnsFalse(); - Equal_DifferentGeometries_ReturnsFalse(); - Equal_DifferentNumberOfPoints_ReturnsFalse(); - Equal_DifferentPoints_ReturnsFalse(); - - MITK_TEST_END(); -} + /** +* @brief Setup Always call this method before each Test-case to ensure correct and new intialization of the used members for a new test case. (If the members are not used in a test, the method does not need to be called). +*/ + void setUp() + { + m_PointSet = mitk::PointSet::New(); + m_AnotherPointSet = m_PointSet->Clone(); + } + + void tearDown() + { + m_PointSet = NULL; + m_AnotherPointSet = NULL; + } + + void Equal_CloneAndOriginal_ReturnsTrue() + { + mitk::PointSet::Pointer newPointSet = mitk::PointSet::New(); + MITK_ASSERT_EQUAL( newPointSet, newPointSet->Clone(), "A clone should be equal to its original."); + } + + void Equal_DifferentGeometries_ReturnsFalse() + { + mitk::Point3D origin; + origin[0] = 0.0; + origin[1] = 0.0; + origin[2] = 1.0 + 2*mitk::eps; + m_AnotherPointSet->GetGeometry()->SetOrigin(origin); + + MITK_ASSERT_NOT_EQUAL( m_PointSet, m_AnotherPointSet, "Origin was modified. Result should be false."); + } + + void Equal_InputIsNull_ReturnsFalse() + { + mitk::PointSet::Pointer pointSet = NULL; + MITK_ASSERT_NOT_EQUAL( pointSet, pointSet, "Input is NULL. Result should be false."); + } + + void Equal_DifferentNumberOfPoints_ReturnsFalse() + { + mitk::Point3D tmpPoint; + tmpPoint[0] = 1.0; + tmpPoint[1] = 1.0; + tmpPoint[2] = 1.0; + + m_PointSet->InsertPoint( 1, tmpPoint ); + m_PointSet->InsertPoint( 2, tmpPoint ); + + m_AnotherPointSet->InsertPoint( 1, tmpPoint ); + + MITK_ASSERT_NOT_EQUAL( m_PointSet, m_AnotherPointSet, "One pointset has two points the other has one. Result should be false."); + } + + void Equal_DifferentPoints_ReturnsFalse() + { + mitk::Point3D tmpPoint; + tmpPoint[0] = 1.0; + tmpPoint[1] = 1.0; + tmpPoint[2] = 1.0; + + m_PointSet->InsertPoint( 1, tmpPoint ); + + tmpPoint[0] = 1.0 + 2*mitk::eps; + m_AnotherPointSet->InsertPoint( 1, tmpPoint ); + + MITK_ASSERT_NOT_EQUAL( m_PointSet, m_AnotherPointSet, "Two pointsets with different points. Result should be false."); + } +}; + +MITK_TEST_SUITE_REGISTRATION(mitkPointSetEqual) diff --git a/Core/Code/Testing/mitkSurfaceEqualTest.cpp b/Core/Code/Testing/mitkSurfaceEqualTest.cpp index 072abba9f6..d13124b39f 100644 --- a/Core/Code/Testing/mitkSurfaceEqualTest.cpp +++ b/Core/Code/Testing/mitkSurfaceEqualTest.cpp @@ -1,181 +1,191 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkSurface.h" #include "mitkTestingMacros.h" #include #include #include #include #include -/** Members used inside the different (sub-)tests. All members are initialized via Setup().*/ -mitk::Surface::Pointer m_Surface3D; -mitk::Surface::Pointer m_Surface3DTwoTimeSteps; +#include "mitkTestFixture.h" -vtkSmartPointer m_PointsOne; -vtkSmartPointer m_PointsTwo; -vtkSmartPointer m_PolygonArrayTwo; -vtkSmartPointer m_PolyDataOne; /** -* @brief Setup Always call this method before each Test-case to ensure correct and new intialization of the used members for a new test case. (If the members are not used in a test, the method does not need to be called). -*/ -static void Setup() -{ - //generate two sets of points - m_PointsOne = vtkSmartPointer::New(); - m_PointsOne->InsertNextPoint( 0.0, 0.0, 0.0 ); - m_PointsOne->InsertNextPoint( 1.0, 0.0, 0.0 ); - m_PointsOne->InsertNextPoint( 0.0, 1.0, 0.0 ); - m_PointsOne->InsertNextPoint( 1.0, 1.0, 0.0 ); - - m_PointsTwo = vtkSmartPointer::New(); - m_PointsTwo->InsertNextPoint( 0.0, 0.0, 0.0 ); - m_PointsTwo->InsertNextPoint( 0.0, 0.0, 2.0 ); - m_PointsTwo->InsertNextPoint( 0.0, 1.0, 0.0 ); - m_PointsTwo->InsertNextPoint( 0.0, 1.0, 2.0 ); - - //generate two polygons - vtkSmartPointer polygonOne = vtkSmartPointer::New(); - polygonOne->GetPointIds()->SetNumberOfIds(4); - polygonOne->GetPointIds()->SetId(0,0); - polygonOne->GetPointIds()->SetId(1,1); - polygonOne->GetPointIds()->SetId(2,2); - polygonOne->GetPointIds()->SetId(3,3); - - vtkSmartPointer polygonTwo = vtkSmartPointer::New(); - polygonTwo->GetPointIds()->SetNumberOfIds(4); - polygonTwo->GetPointIds()->SetId(0,3); - polygonTwo->GetPointIds()->SetId(1,2); - polygonTwo->GetPointIds()->SetId(2,0); - polygonTwo->GetPointIds()->SetId(3,1); - - //generate polydatas - vtkSmartPointer polygonArrayOne = vtkSmartPointer::New(); - polygonArrayOne->InsertNextCell(polygonOne); - - m_PolyDataOne = vtkSmartPointer::New(); - m_PolyDataOne->SetPoints(m_PointsOne); - m_PolyDataOne->SetPolys(polygonArrayOne); - - m_PolygonArrayTwo = vtkSmartPointer::New(); - m_PolygonArrayTwo->InsertNextCell(polygonTwo); - - vtkSmartPointer polyDataTwo = vtkSmartPointer::New(); - polyDataTwo->SetPoints(m_PointsOne); - polyDataTwo->SetPolys(m_PolygonArrayTwo); - - //generate surfaces - m_Surface3D = mitk::Surface::New(); - m_Surface3D->SetVtkPolyData( m_PolyDataOne ); - - m_Surface3DTwoTimeSteps = mitk::Surface::New(); - m_Surface3DTwoTimeSteps->SetVtkPolyData( m_PolyDataOne, 0 ); - m_Surface3DTwoTimeSteps->SetVtkPolyData( polyDataTwo, 1 ); -} - -static void Equal_InputIsNull_ReturnsFalse() -{ - mitk::Surface::Pointer surface = NULL; - MITK_TEST_NOT_EQUAL( surface, surface, "Input is NULL. Result should be false."); -} - -static void Equal_CloneAndOriginalOneTimestep_ReturnsTrue() -{ - Setup(); - MITK_TEST_EQUAL( m_Surface3D, m_Surface3D->Clone(), "A one timestep clone should be equal to its original."); -} - -static void Equal_CloneAndOriginalTwoTimesteps_ReturnsTrue() -{ - Setup(); - MITK_TEST_EQUAL( m_Surface3DTwoTimeSteps, m_Surface3DTwoTimeSteps->Clone(), "A two timestep clone should be equal to its original."); -} - -static void Equal_OneTimeStepVSTwoTimeStep_ReturnsFalse() -{ - Setup(); - MITK_TEST_NOT_EQUAL( m_Surface3D, m_Surface3DTwoTimeSteps, "A one timestep and two timestep surface should not be equal."); -} + * @brief mitkPointSetEqualTestSuite A test class for Equal methods in mitk::PointSet. + */ -static void Equal_TwoTimeStepsDifferentPoints_ReturnsFalse() +class mitkSurfaceEqualTestSuite : public mitk::TestFixture { - Setup(); - - vtkSmartPointer polyDataDifferentPoints = vtkSmartPointer::New(); - polyDataDifferentPoints->SetPoints(m_PointsTwo); - polyDataDifferentPoints->SetPolys(m_PolygonArrayTwo); - - mitk::Surface::Pointer surface3DTwoTimeStepsDifferentPoints = mitk::Surface::New(); - surface3DTwoTimeStepsDifferentPoints->SetVtkPolyData( m_PolyDataOne, 0 ); - surface3DTwoTimeStepsDifferentPoints->SetVtkPolyData( polyDataDifferentPoints, 1 ); - - //The geometry also changes, because the second pointset has a different geometry/extent. - MITK_TEST_NOT_EQUAL( surface3DTwoTimeStepsDifferentPoints, m_Surface3DTwoTimeSteps, "A surface with the same timesteps and different points should not be equal."); -} - -static void Equal_SurfaceWithPolygonSurfaceWithPolyLine_ReturnsFalse() -{ - Setup(); - - //generate a line - vtkSmartPointer polyLineOne = vtkSmartPointer::New(); - polyLineOne->GetPointIds()->SetNumberOfIds(2); - polyLineOne->GetPointIds()->SetId(0,0); - polyLineOne->GetPointIds()->SetId(1,1); - - vtkSmartPointer polyLineArrayOne = vtkSmartPointer::New(); - polyLineArrayOne->InsertNextCell(polyLineOne); - - vtkSmartPointer polyDataLine = vtkSmartPointer::New(); - polyDataLine->SetPoints(m_PointsOne); - polyDataLine->SetLines(polyLineArrayOne); - - mitk::Surface::Pointer surface3DLine = mitk::Surface::New(); - surface3DLine->SetVtkPolyData( polyDataLine ); - - MITK_TEST_NOT_EQUAL( m_Surface3D, surface3DLine, "A surface with the same timesteps and points and the same number of cells, but different types of cells should not be equal."); -} - -static void Equal_DifferentPoints_ReturnsFalse() -{ - Setup(); - mitk::Surface::Pointer surfaceWithADifferentPoint = m_Surface3D->Clone(); - //modify points. m_Surface3D contains m_PointsOne - surfaceWithADifferentPoint->GetVtkPolyData()->SetPoints( m_PointsTwo ); - - MITK_TEST_NOT_EQUAL( m_Surface3D, surfaceWithADifferentPoint, "A surface with a single timestep and different points should not be equal."); -} - -/** -* @brief mitkSurfaceEqualTest A test class for Equal methods in mitk::Surface. + CPPUNIT_TEST_SUITE(mitkSurfaceEqualTestSuite); + MITK_TEST(Equal_InputIsNull_ReturnsFalse); + MITK_TEST(Equal_CloneAndOriginalOneTimestep_ReturnsTrue); + MITK_TEST(Equal_CloneAndOriginalTwoTimesteps_ReturnsTrue); + MITK_TEST(Equal_OneTimeStepVSTwoTimeStep_ReturnsFalse); + MITK_TEST(Equal_TwoTimeStepsDifferentPoints_ReturnsFalse); + MITK_TEST(Equal_DifferentPoints_ReturnsFalse); + MITK_TEST(Equal_SurfaceWithPolygonSurfaceWithPolyLine_ReturnsFalse); + CPPUNIT_TEST_SUITE_END(); + +private: + + /** Members used inside the different (sub-)tests. All members are initialized via setUp().*/ + mitk::Surface::Pointer m_Surface3D; + mitk::Surface::Pointer m_Surface3DTwoTimeSteps; + + vtkSmartPointer m_PointsOne; + vtkSmartPointer m_PointsTwo; + vtkSmartPointer m_PolygonArrayTwo; + vtkSmartPointer m_PolyDataOne; + +public: + + /** +* @brief Setup Always call this method before each Test-case to ensure correct and new intialization of the used members for a new test case. (If the members are not used in a test, the method does not need to be called). */ -int mitkSurfaceEqualTest(int /*argc*/, char* /*argv*/[]) -{ - MITK_TEST_BEGIN(mitkSurfaceEqualTest); - - Equal_InputIsNull_ReturnsFalse(); - Equal_CloneAndOriginalOneTimestep_ReturnsTrue(); - Equal_CloneAndOriginalTwoTimesteps_ReturnsTrue(); - Equal_OneTimeStepVSTwoTimeStep_ReturnsFalse(); - Equal_TwoTimeStepsDifferentPoints_ReturnsFalse(); - Equal_DifferentPoints_ReturnsFalse(); - Equal_SurfaceWithPolygonSurfaceWithPolyLine_ReturnsFalse(); - - MITK_TEST_END(); -} + void setUp() + { + //generate two sets of points + m_PointsOne = vtkSmartPointer::New(); + m_PointsOne->InsertNextPoint( 0.0, 0.0, 0.0 ); + m_PointsOne->InsertNextPoint( 1.0, 0.0, 0.0 ); + m_PointsOne->InsertNextPoint( 0.0, 1.0, 0.0 ); + m_PointsOne->InsertNextPoint( 1.0, 1.0, 0.0 ); + + m_PointsTwo = vtkSmartPointer::New(); + m_PointsTwo->InsertNextPoint( 0.0, 0.0, 0.0 ); + m_PointsTwo->InsertNextPoint( 0.0, 0.0, 2.0 ); + m_PointsTwo->InsertNextPoint( 0.0, 1.0, 0.0 ); + m_PointsTwo->InsertNextPoint( 0.0, 1.0, 2.0 ); + + //generate two polygons + vtkSmartPointer polygonOne = vtkSmartPointer::New(); + polygonOne->GetPointIds()->SetNumberOfIds(4); + polygonOne->GetPointIds()->SetId(0,0); + polygonOne->GetPointIds()->SetId(1,1); + polygonOne->GetPointIds()->SetId(2,2); + polygonOne->GetPointIds()->SetId(3,3); + + vtkSmartPointer polygonTwo = vtkSmartPointer::New(); + polygonTwo->GetPointIds()->SetNumberOfIds(4); + polygonTwo->GetPointIds()->SetId(0,3); + polygonTwo->GetPointIds()->SetId(1,2); + polygonTwo->GetPointIds()->SetId(2,0); + polygonTwo->GetPointIds()->SetId(3,1); + + //generate polydatas + vtkSmartPointer polygonArrayOne = vtkSmartPointer::New(); + polygonArrayOne->InsertNextCell(polygonOne); + + m_PolyDataOne = vtkSmartPointer::New(); + m_PolyDataOne->SetPoints(m_PointsOne); + m_PolyDataOne->SetPolys(polygonArrayOne); + + m_PolygonArrayTwo = vtkSmartPointer::New(); + m_PolygonArrayTwo->InsertNextCell(polygonTwo); + + vtkSmartPointer polyDataTwo = vtkSmartPointer::New(); + polyDataTwo->SetPoints(m_PointsOne); + polyDataTwo->SetPolys(m_PolygonArrayTwo); + + //generate surfaces + m_Surface3D = mitk::Surface::New(); + m_Surface3D->SetVtkPolyData( m_PolyDataOne ); + + m_Surface3DTwoTimeSteps = mitk::Surface::New(); + m_Surface3DTwoTimeSteps->SetVtkPolyData( m_PolyDataOne, 0 ); + m_Surface3DTwoTimeSteps->SetVtkPolyData( polyDataTwo, 1 ); + } + + void tearDown() + { + m_Surface3D = NULL; + m_Surface3DTwoTimeSteps = NULL; + m_PolyDataOne = NULL; + m_PolygonArrayTwo = NULL; + m_PointsOne = NULL; + m_PointsTwo = NULL; + } + + void Equal_InputIsNull_ReturnsFalse() + { + mitk::Surface::Pointer surface = NULL; + MITK_ASSERT_NOT_EQUAL( surface, surface, "Input is NULL. Result should be false."); + } + + void Equal_CloneAndOriginalOneTimestep_ReturnsTrue() + { + MITK_ASSERT_EQUAL( m_Surface3D, m_Surface3D->Clone(), "A one timestep clone should be equal to its original."); + } + + void Equal_CloneAndOriginalTwoTimesteps_ReturnsTrue() + { + MITK_ASSERT_EQUAL( m_Surface3DTwoTimeSteps, m_Surface3DTwoTimeSteps->Clone(), "A two timestep clone should be equal to its original."); + } + + void Equal_OneTimeStepVSTwoTimeStep_ReturnsFalse() + { + MITK_ASSERT_NOT_EQUAL( m_Surface3D, m_Surface3DTwoTimeSteps, "A one timestep and two timestep surface should not be equal."); + } + + void Equal_TwoTimeStepsDifferentPoints_ReturnsFalse() + { + vtkSmartPointer polyDataDifferentPoints = vtkSmartPointer::New(); + polyDataDifferentPoints->SetPoints(m_PointsTwo); + polyDataDifferentPoints->SetPolys(m_PolygonArrayTwo); + + mitk::Surface::Pointer surface3DTwoTimeStepsDifferentPoints = mitk::Surface::New(); + surface3DTwoTimeStepsDifferentPoints->SetVtkPolyData( m_PolyDataOne, 0 ); + surface3DTwoTimeStepsDifferentPoints->SetVtkPolyData( polyDataDifferentPoints, 1 ); + + //The geometry also changes, because the second pointset has a different geometry/extent. + MITK_ASSERT_NOT_EQUAL( surface3DTwoTimeStepsDifferentPoints, m_Surface3DTwoTimeSteps, "A surface with the same timesteps and different points should not be equal."); + } + + void Equal_SurfaceWithPolygonSurfaceWithPolyLine_ReturnsFalse() + { + //generate a line + vtkSmartPointer polyLineOne = vtkSmartPointer::New(); + polyLineOne->GetPointIds()->SetNumberOfIds(2); + polyLineOne->GetPointIds()->SetId(0,0); + polyLineOne->GetPointIds()->SetId(1,1); + + vtkSmartPointer polyLineArrayOne = vtkSmartPointer::New(); + polyLineArrayOne->InsertNextCell(polyLineOne); + + vtkSmartPointer polyDataLine = vtkSmartPointer::New(); + polyDataLine->SetPoints(m_PointsOne); + polyDataLine->SetLines(polyLineArrayOne); + + mitk::Surface::Pointer surface3DLine = mitk::Surface::New(); + surface3DLine->SetVtkPolyData( polyDataLine ); + + MITK_ASSERT_NOT_EQUAL( m_Surface3D, surface3DLine, "A surface with the same timesteps and points and the same number of cells, but different types of cells should not be equal."); + } + + void Equal_DifferentPoints_ReturnsFalse() + { + mitk::Surface::Pointer surfaceWithADifferentPoint = m_Surface3D->Clone(); + //modify points. m_Surface3D contains m_PointsOne + surfaceWithADifferentPoint->GetVtkPolyData()->SetPoints( m_PointsTwo ); + + MITK_ASSERT_NOT_EQUAL( m_Surface3D, surfaceWithADifferentPoint, "A surface with a single timestep and different points should not be equal."); + } +}; + +MITK_TEST_SUITE_REGISTRATION(mitkSurfaceEqual) diff --git a/Core/Code/files.cmake b/Core/Code/files.cmake index 0bc4743957..5da2d77692 100644 --- a/Core/Code/files.cmake +++ b/Core/Code/files.cmake @@ -1,409 +1,412 @@ set(H_FILES Algorithms/itkImportMitkImageContainer.h Algorithms/itkImportMitkImageContainer.txx Algorithms/itkLocalVariationImageFilter.h Algorithms/itkLocalVariationImageFilter.txx Algorithms/itkMITKScalarImageToHistogramGenerator.h Algorithms/itkMITKScalarImageToHistogramGenerator.txx Algorithms/itkTotalVariationDenoisingImageFilter.h Algorithms/itkTotalVariationDenoisingImageFilter.txx Algorithms/itkTotalVariationSingleIterationImageFilter.h Algorithms/itkTotalVariationSingleIterationImageFilter.txx Algorithms/mitkBilateralFilter.h Algorithms/mitkBilateralFilter.cpp Algorithms/mitkInstantiateAccessFunctions.h Algorithms/mitkPixelTypeList.h Algorithms/mitkPPArithmeticDec.h Algorithms/mitkPPArgCount.h Algorithms/mitkPPCat.h Algorithms/mitkPPConfig.h Algorithms/mitkPPControlExprIIf.h Algorithms/mitkPPControlIf.h Algorithms/mitkPPControlIIf.h Algorithms/mitkPPDebugError.h Algorithms/mitkPPDetailAutoRec.h Algorithms/mitkPPDetailDMCAutoRec.h Algorithms/mitkPPExpand.h Algorithms/mitkPPFacilitiesEmpty.h Algorithms/mitkPPFacilitiesExpand.h Algorithms/mitkPPLogicalBool.h Algorithms/mitkPPRepetitionDetailDMCFor.h Algorithms/mitkPPRepetitionDetailEDGFor.h Algorithms/mitkPPRepetitionDetailFor.h Algorithms/mitkPPRepetitionDetailMSVCFor.h Algorithms/mitkPPRepetitionFor.h Algorithms/mitkPPSeqElem.h Algorithms/mitkPPSeqForEach.h Algorithms/mitkPPSeqForEachProduct.h Algorithms/mitkPPSeq.h Algorithms/mitkPPSeqEnum.h Algorithms/mitkPPSeqSize.h Algorithms/mitkPPSeqToTuple.h Algorithms/mitkPPStringize.h Algorithms/mitkPPTupleEat.h Algorithms/mitkPPTupleElem.h Algorithms/mitkPPTupleRem.h Algorithms/mitkClippedSurfaceBoundsCalculator.h Algorithms/mitkExtractSliceFilter.h Algorithms/mitkConvert2Dto3DImageFilter.h Algorithms/mitkPlaneClipping.h + Common/mitkCommon.h Common/mitkExceptionMacro.h Common/mitkServiceBaseObject.h - Common/mitkTestingMacros.h + Common/mitkTestCaller.h + Common/mitkTestFixture.h Common/mitkTesting.h + Common/mitkTestingMacros.h DataManagement/mitkProportionalTimeGeometry.h DataManagement/mitkTimeGeometry.h DataManagement/mitkImageAccessByItk.h DataManagement/mitkImageCast.h DataManagement/mitkImagePixelAccessor.h DataManagement/mitkImagePixelReadAccessor.h DataManagement/mitkImagePixelWriteAccessor.h DataManagement/mitkImageReadAccessor.h DataManagement/mitkImageWriteAccessor.h DataManagement/mitkITKImageImport.h DataManagement/mitkITKImageImport.txx DataManagement/mitkImageToItk.h DataManagement/mitkImageToItk.txx DataManagement/mitkTimeSlicedGeometry.h # Deprecated, empty for compatibilty reasons. Interactions/mitkEventMapperAddOn.h Interfaces/mitkIDataNodeReader.h Rendering/mitkLocalStorageHandler.h IO/mitkPixelTypeTraits.h ) set(CPP_FILES Algorithms/mitkBaseDataSource.cpp Algorithms/mitkCompareImageDataFilter.cpp Algorithms/mitkMultiComponentImageDataComparisonFilter.cpp Algorithms/mitkDataNodeSource.cpp Algorithms/mitkGeometry2DDataToSurfaceFilter.cpp Algorithms/mitkHistogramGenerator.cpp Algorithms/mitkImageChannelSelector.cpp Algorithms/mitkImageSliceSelector.cpp Algorithms/mitkImageSource.cpp Algorithms/mitkImageTimeSelector.cpp Algorithms/mitkImageToImageFilter.cpp Algorithms/mitkImageToSurfaceFilter.cpp Algorithms/mitkPointSetSource.cpp Algorithms/mitkPointSetToPointSetFilter.cpp Algorithms/mitkRGBToRGBACastImageFilter.cpp Algorithms/mitkSubImageSelector.cpp Algorithms/mitkSurfaceSource.cpp Algorithms/mitkSurfaceToImageFilter.cpp Algorithms/mitkSurfaceToSurfaceFilter.cpp Algorithms/mitkUIDGenerator.cpp Algorithms/mitkVolumeCalculator.cpp Algorithms/mitkClippedSurfaceBoundsCalculator.cpp Algorithms/mitkExtractSliceFilter.cpp Algorithms/mitkConvert2Dto3DImageFilter.cpp Controllers/mitkBaseController.cpp Controllers/mitkCallbackFromGUIThread.cpp Controllers/mitkCameraController.cpp Controllers/mitkCameraRotationController.cpp Controllers/mitkCoreActivator.cpp Controllers/mitkFocusManager.cpp Controllers/mitkLimitedLinearUndo.cpp Controllers/mitkOperationEvent.cpp Controllers/mitkPlanePositionManager.cpp Controllers/mitkProgressBar.cpp Controllers/mitkRenderingManager.cpp Controllers/mitkSliceNavigationController.cpp Controllers/mitkSlicesCoordinator.cpp Controllers/mitkSlicesRotator.cpp Controllers/mitkSlicesSwiveller.cpp Controllers/mitkStatusBar.cpp Controllers/mitkStepper.cpp Controllers/mitkTestManager.cpp Controllers/mitkUndoController.cpp Controllers/mitkVerboseLimitedLinearUndo.cpp Controllers/mitkVtkInteractorCameraController.cpp Controllers/mitkVtkLayerController.cpp DataManagement/mitkProportionalTimeGeometry.cpp DataManagement/mitkTimeGeometry.cpp DataManagement/mitkAbstractTransformGeometry.cpp DataManagement/mitkAnnotationProperty.cpp DataManagement/mitkApplicationCursor.cpp DataManagement/mitkBaseData.cpp DataManagement/mitkBaseProperty.cpp DataManagement/mitkClippingProperty.cpp DataManagement/mitkChannelDescriptor.cpp DataManagement/mitkColorProperty.cpp DataManagement/mitkDataStorage.cpp # DataManagement/mitkDataTree.cpp DataManagement/mitkDataNode.cpp DataManagement/mitkDataNodeFactory.cpp # DataManagement/mitkDataTreeStorage.cpp DataManagement/mitkDisplayGeometry.cpp DataManagement/mitkEnumerationProperty.cpp DataManagement/mitkGeometry2D.cpp DataManagement/mitkGeometry2DData.cpp DataManagement/mitkGeometry3D.cpp DataManagement/mitkGeometryData.cpp DataManagement/mitkGroupTagProperty.cpp DataManagement/mitkImage.cpp DataManagement/mitkImageAccessorBase.cpp DataManagement/mitkImageCaster.cpp DataManagement/mitkImageCastPart1.cpp DataManagement/mitkImageCastPart2.cpp DataManagement/mitkImageCastPart3.cpp DataManagement/mitkImageCastPart4.cpp DataManagement/mitkImageDataItem.cpp DataManagement/mitkImageDescriptor.cpp DataManagement/mitkImageVtkAccessor.cpp DataManagement/mitkImageStatisticsHolder.cpp DataManagement/mitkLandmarkBasedCurvedGeometry.cpp DataManagement/mitkLandmarkProjectorBasedCurvedGeometry.cpp DataManagement/mitkLandmarkProjector.cpp DataManagement/mitkLevelWindow.cpp DataManagement/mitkLevelWindowManager.cpp DataManagement/mitkLevelWindowPreset.cpp DataManagement/mitkLevelWindowProperty.cpp DataManagement/mitkLookupTable.cpp DataManagement/mitkLookupTables.cpp # specializations of GenericLookupTable DataManagement/mitkMemoryUtilities.cpp DataManagement/mitkModalityProperty.cpp DataManagement/mitkModeOperation.cpp DataManagement/mitkNodePredicateAnd.cpp DataManagement/mitkNodePredicateBase.cpp DataManagement/mitkNodePredicateCompositeBase.cpp DataManagement/mitkNodePredicateData.cpp DataManagement/mitkNodePredicateDataType.cpp DataManagement/mitkNodePredicateDimension.cpp DataManagement/mitkNodePredicateFirstLevel.cpp DataManagement/mitkNodePredicateNot.cpp DataManagement/mitkNodePredicateOr.cpp DataManagement/mitkNodePredicateProperty.cpp DataManagement/mitkNodePredicateSource.cpp DataManagement/mitkPlaneOrientationProperty.cpp DataManagement/mitkPlaneGeometry.cpp DataManagement/mitkPlaneOperation.cpp DataManagement/mitkPointOperation.cpp DataManagement/mitkPointSet.cpp DataManagement/mitkProperties.cpp DataManagement/mitkPropertyList.cpp DataManagement/mitkRestorePlanePositionOperation.cpp DataManagement/mitkRotationOperation.cpp DataManagement/mitkSlicedData.cpp DataManagement/mitkSlicedGeometry3D.cpp DataManagement/mitkSmartPointerProperty.cpp DataManagement/mitkStandaloneDataStorage.cpp DataManagement/mitkStateTransitionOperation.cpp DataManagement/mitkStringProperty.cpp DataManagement/mitkSurface.cpp DataManagement/mitkSurfaceOperation.cpp DataManagement/mitkThinPlateSplineCurvedGeometry.cpp DataManagement/mitkTransferFunction.cpp DataManagement/mitkTransferFunctionProperty.cpp DataManagement/mitkTransferFunctionInitializer.cpp DataManagement/mitkVector.cpp DataManagement/mitkVtkInterpolationProperty.cpp DataManagement/mitkVtkRepresentationProperty.cpp DataManagement/mitkVtkResliceInterpolationProperty.cpp DataManagement/mitkVtkScalarModeProperty.cpp DataManagement/mitkVtkVolumeRenderingProperty.cpp DataManagement/mitkWeakPointerProperty.cpp DataManagement/mitkRenderingModeProperty.cpp DataManagement/mitkShaderProperty.cpp DataManagement/mitkResliceMethodProperty.cpp DataManagement/mitkMaterial.cpp DataManagement/mitkPointSetShapeProperty.cpp DataManagement/mitkFloatPropertyExtension.cpp DataManagement/mitkIntPropertyExtension.cpp DataManagement/mitkPropertyExtension.cpp DataManagement/mitkPropertyFilter.cpp DataManagement/mitkPropertyAliases.cpp DataManagement/mitkPropertyDescriptions.cpp DataManagement/mitkPropertyExtensions.cpp DataManagement/mitkPropertyFilters.cpp Interactions/mitkAction.cpp Interactions/mitkAffineInteractor.cpp Interactions/mitkBindDispatcherInteractor.cpp Interactions/mitkCoordinateSupplier.cpp Interactions/mitkDataInteractor.cpp Interactions/mitkDispatcher.cpp Interactions/mitkDisplayCoordinateOperation.cpp Interactions/mitkDisplayInteractor.cpp Interactions/mitkDisplayPositionEvent.cpp # Interactions/mitkDisplayVectorInteractorLevelWindow.cpp # legacy, prob even now unneeded # Interactions/mitkDisplayVectorInteractorScroll.cpp Interactions/mitkEvent.cpp Interactions/mitkEventConfig.cpp Interactions/mitkEventDescription.cpp Interactions/mitkEventFactory.cpp Interactions/mitkInteractionEventHandler.cpp Interactions/mitkEventMapper.cpp Interactions/mitkEventStateMachine.cpp Interactions/mitkGlobalInteraction.cpp Interactions/mitkInteractor.cpp Interactions/mitkInternalEvent.cpp Interactions/mitkInteractionEvent.cpp Interactions/mitkInteractionEventConst.cpp Interactions/mitkInteractionPositionEvent.cpp Interactions/mitkInteractionKeyEvent.cpp Interactions/mitkMousePressEvent.cpp Interactions/mitkMouseMoveEvent.cpp Interactions/mitkMouseReleaseEvent.cpp Interactions/mitkMouseWheelEvent.cpp Interactions/mitkMouseDoubleClickEvent.cpp Interactions/mitkMouseModeSwitcher.cpp Interactions/mitkMouseMovePointSetInteractor.cpp Interactions/mitkMoveBaseDataInteractor.cpp Interactions/mitkNodeDepententPointSetInteractor.cpp Interactions/mitkPointSetDataInteractor.cpp Interactions/mitkPointSetInteractor.cpp Interactions/mitkPositionEvent.cpp Interactions/mitkPositionTracker.cpp Interactions/mitkStateMachineAction.cpp Interactions/mitkStateMachineCondition.cpp Interactions/mitkStateMachineState.cpp Interactions/mitkStateMachineTransition.cpp Interactions/mitkState.cpp Interactions/mitkStateMachineContainer.cpp Interactions/mitkStateEvent.cpp Interactions/mitkStateMachine.cpp Interactions/mitkStateMachineFactory.cpp Interactions/mitkTransition.cpp Interactions/mitkWheelEvent.cpp Interactions/mitkKeyEvent.cpp Interactions/mitkVtkEventAdapter.cpp Interactions/mitkVtkInteractorStyle.cxx Interactions/mitkCrosshairPositionEvent.cpp Interfaces/mitkInteractionEventObserver.cpp Interfaces/mitkIShaderRepository.cpp Interfaces/mitkIPropertyAliases.cpp Interfaces/mitkIPropertyDescriptions.cpp Interfaces/mitkIPropertyExtensions.cpp Interfaces/mitkIPropertyFilters.cpp IO/mitkBaseDataIOFactory.cpp IO/mitkCoreDataNodeReader.cpp IO/mitkDicomSeriesReader.cpp IO/mitkDicomSR_LoadDICOMScalar.cpp IO/mitkDicomSR_LoadDICOMScalar4D.cpp IO/mitkDicomSR_LoadDICOMRGBPixel.cpp IO/mitkDicomSR_LoadDICOMRGBPixel4D.cpp IO/mitkDicomSR_ImageBlockDescriptor.cpp IO/mitkDicomSR_GantryTiltInformation.cpp IO/mitkDicomSR_SliceGroupingResult.cpp IO/mitkFileReader.cpp IO/mitkFileSeriesReader.cpp IO/mitkFileWriter.cpp # IO/mitkIpPicGet.c IO/mitkImageGenerator.cpp IO/mitkImageWriter.cpp IO/mitkImageWriterFactory.cpp IO/mitkItkImageFileIOFactory.cpp IO/mitkItkImageFileReader.cpp IO/mitkItkLoggingAdapter.cpp IO/mitkItkPictureWrite.cpp IO/mitkIOUtil.cpp IO/mitkLookupTableProperty.cpp IO/mitkOperation.cpp # IO/mitkPicFileIOFactory.cpp # IO/mitkPicFileReader.cpp # IO/mitkPicFileWriter.cpp # IO/mitkPicHelper.cpp # IO/mitkPicVolumeTimeSeriesIOFactory.cpp # IO/mitkPicVolumeTimeSeriesReader.cpp IO/mitkPixelType.cpp IO/mitkPointSetIOFactory.cpp IO/mitkPointSetReader.cpp IO/mitkPointSetWriter.cpp IO/mitkPointSetWriterFactory.cpp IO/mitkRawImageFileReader.cpp IO/mitkStandardFileLocations.cpp IO/mitkSTLFileIOFactory.cpp IO/mitkSTLFileReader.cpp IO/mitkSurfaceVtkWriter.cpp IO/mitkSurfaceVtkWriterFactory.cpp IO/mitkVtkLoggingAdapter.cpp IO/mitkVtiFileIOFactory.cpp IO/mitkVtiFileReader.cpp IO/mitkVtkImageIOFactory.cpp IO/mitkVtkImageReader.cpp IO/mitkVtkSurfaceIOFactory.cpp IO/mitkVtkSurfaceReader.cpp IO/vtkPointSetXMLParser.cpp IO/mitkLog.cpp Rendering/mitkBaseRenderer.cpp Rendering/mitkVtkMapper.cpp Rendering/mitkRenderWindowFrame.cpp Rendering/mitkGeometry2DDataMapper2D.cpp Rendering/mitkGeometry2DDataVtkMapper3D.cpp Rendering/mitkGLMapper.cpp Rendering/mitkGradientBackground.cpp Rendering/mitkManufacturerLogo.cpp Rendering/mitkMapper.cpp Rendering/mitkPointSetGLMapper2D.cpp Rendering/mitkPointSetVtkMapper2D.cpp Rendering/mitkPointSetVtkMapper3D.cpp Rendering/mitkPolyDataGLMapper2D.cpp Rendering/mitkSurfaceGLMapper2D.cpp Rendering/mitkSurfaceVtkMapper3D.cpp Rendering/mitkVolumeDataVtkMapper3D.cpp Rendering/mitkVtkPropRenderer.cpp Rendering/mitkVtkWidgetRendering.cpp Rendering/vtkMitkRectangleProp.cpp Rendering/vtkMitkRenderProp.cpp Rendering/mitkVtkEventProvider.cpp Rendering/mitkRenderWindow.cpp Rendering/mitkRenderWindowBase.cpp Rendering/mitkShaderRepository.cpp Rendering/mitkImageVtkMapper2D.cpp Rendering/vtkMitkThickSlicesFilter.cpp Rendering/vtkMitkLevelWindowFilter.cpp Rendering/vtkNeverTranslucentTexture.cpp Rendering/mitkRenderingTestHelper.cpp Rendering/mitkOverlay.cpp Rendering/mitkVtkOverlay.cpp Rendering/mitkVtkOverlay2D.cpp Rendering/mitkVtkOverlay3D.cpp Rendering/mitkOverlayManager.cpp Rendering/mitkAbstractOverlayLayouter.cpp Rendering/mitkTextOverlay2D.cpp Rendering/mitkTextOverlay3D.cpp Rendering/mitkLabelOverlay3D.cpp Rendering/mitkOverlay2DLayouter.cpp Common/mitkException.cpp Common/mitkCommon.h Common/mitkCoreObjectFactoryBase.cpp Common/mitkCoreObjectFactory.cpp Common/mitkCoreServices.cpp ) list(APPEND CPP_FILES ${CppMicroServices_SOURCES}) set(RESOURCE_FILES Interactions/globalConfig.xml Interactions/DisplayInteraction.xml Interactions/DisplayConfig.xml Interactions/DisplayConfigPACS.xml Interactions/DisplayConfigPACSPan.xml Interactions/DisplayConfigPACSScroll.xml Interactions/DisplayConfigPACSZoom.xml Interactions/DisplayConfigPACSLevelWindow.xml Interactions/DisplayConfigMITK.xml Interactions/PointSet.xml Interactions/Legacy/StateMachine.xml Interactions/Legacy/DisplayConfigMITKTools.xml Interactions/PointSetConfig.xml Shaders/mitkShaderLighting.xml mitkLevelWindowPresets.xml ) diff --git a/Modules/MitkExt/Testing/CMakeLists.txt b/Modules/MitkExt/Testing/CMakeLists.txt index 014497799f..2c448d13b6 100644 --- a/Modules/MitkExt/Testing/CMakeLists.txt +++ b/Modules/MitkExt/Testing/CMakeLists.txt @@ -1,6 +1,6 @@ -MITK_CREATE_MODULE_TESTS(EXTRA_DRIVER_INIT "RegisterCoreExtObjectFactory();;" +MITK_CREATE_MODULE_TESTS(EXTRA_DRIVER_INIT "RegisterCoreExtObjectFactory()" EXTRA_DRIVER_INCLUDE "mitkCoreExtObjectFactory.h") mitkAddCustomModuleTest(mitkLabeledImageToSurfaceFilterTest_BinaryBall mitkLabeledImageToSurfaceFilterTest ${MITK_DATA_DIR}/BallBinary30x30x30.pic.gz) mitkAddCustomModuleTest(mitkImageToSurfaceFilterTest_BinaryBall mitkImageToSurfaceFilterTest ${MITK_DATA_DIR}/BallBinary30x30x30.nrrd) diff --git a/mitkTestingConfig.h.in b/mitkTestingConfig.h.in index 3a908f70f0..8e1c8ae108 100644 --- a/mitkTestingConfig.h.in +++ b/mitkTestingConfig.h.in @@ -1,18 +1,20 @@ /* mitkTestingConfig.h this file is generated. Do not change! */ #ifndef MITKTESTINGCONFIG_H #define MITKTESTINGCONFIG_H #cmakedefine BUILD_TESTING #cmakedefine MITK_FAST_TESTING #define MITK_TEST_OUTPUT_DIR "@MITK_TEST_OUTPUT_DIR@" #ifdef CMAKE_INTDIR #define MITK_RUNTIME_OUTPUT_DIR "@CMAKE_RUNTIME_OUTPUT_DIRECTORY@/" CMAKE_INTDIR #else #define MITK_RUNTIME_OUTPUT_DIR "@CMAKE_RUNTIME_OUTPUT_DIRECTORY@" #endif +#define MITK_DATA_DIR "@MITK_DATA_DIR@" + #endif // MITKTESTINGCONFIG_H