diff --git a/Core/Code/Testing/files.cmake b/Core/Code/Testing/files.cmake index 5fa971e04d..b4e9a140e3 100644 --- a/Core/Code/Testing/files.cmake +++ b/Core/Code/Testing/files.cmake @@ -1,199 +1,201 @@ # tests with no extra command line parameter set(MODULE_TESTS # IMPORTANT: If you plan to deactivate / comment out a test please write a bug number to the commented out line of code. # # Example: #mitkMyTest #this test is commented out because of bug 12345 # # It is important that the bug is open and that the test will be activated again before the bug is closed. This assures that # no test is forgotten after it was commented out. If there is no bug for your current problem, please add a new one and # mark it as critical. ################## DISABLED TESTS ################################################# #mitkAbstractTransformGeometryTest.cpp #seems as tested class mitkExternAbstractTransformGeometry doesnt exist any more #mitkStateMachineContainerTest.cpp #rewrite test, indirect since no longer exported Bug 14529 #mitkRegistrationBaseTest.cpp #tested class mitkRegistrationBase doesn't exist any more #mitkSegmentationInterpolationTest.cpp #file doesn't exist! #mitkPipelineSmartPointerCorrectnessTest.cpp #file doesn't exist! #mitkITKThreadingTest.cpp #test outdated because itk::Semaphore was removed from ITK #mitkAbstractTransformPlaneGeometryTest.cpp #mitkVtkAbstractTransformPlaneGeometry doesn't exist any more #mitkTestUtilSharedLibrary.cpp #Linker problem with this test... #mitkTextOverlay2DSymbolsRenderingTest.cpp #Implementation of the tested feature is not finished yet. Ask Christoph or see bug 15104 for details. ################# RUNNING TESTS ################################################### mitkAccessByItkTest.cpp mitkCoreObjectFactoryTest.cpp mitkMaterialTest.cpp mitkActionTest.cpp mitkDispatcherTest.cpp mitkEnumerationPropertyTest.cpp mitkEventTest.cpp mitkFocusManagerTest.cpp mitkGenericPropertyTest.cpp mitkGeometry2DTest.cpp mitkGeometry3DTest.cpp mitkGeometry3DEqualTest.cpp mitkGeometryDataToSurfaceFilterTest.cpp mitkGlobalInteractionTest.cpp mitkImageEqualTest.cpp mitkImageDataItemTest.cpp mitkImageGeneratorTest.cpp mitkIOUtilTest.cpp mitkBaseDataTest.cpp mitkImportItkImageTest.cpp mitkGrabItkImageMemoryTest.cpp mitkInstantiateAccessFunctionTest.cpp mitkInteractorTest.cpp mitkLevelWindowTest.cpp mitkMessageTest.cpp mitkPixelTypeTest.cpp mitkPlaneGeometryTest.cpp + mitkPointSetTest.cpp mitkPointSetEqualTest.cpp mitkPointSetFileIOTest.cpp - mitkPointSetTest.cpp + mitkPointSetOnEmptyTest.cpp mitkPointSetWriterTest.cpp mitkPointSetReaderTest.cpp mitkPointSetInteractorTest.cpp + mitkPointSetPointOperationsTest.cpp mitkPropertyTest.cpp mitkPropertyListTest.cpp mitkSlicedGeometry3DTest.cpp mitkSliceNavigationControllerTest.cpp mitkStateMachineTest.cpp mitkStateTest.cpp mitkSurfaceTest.cpp mitkSurfaceEqualTest.cpp mitkSurfaceToSurfaceFilterTest.cpp mitkTimeGeometryTest.cpp mitkTransitionTest.cpp mitkUndoControllerTest.cpp mitkVtkWidgetRenderingTest.cpp mitkVerboseLimitedLinearUndoTest.cpp mitkWeakPointerTest.cpp mitkTransferFunctionTest.cpp mitkStepperTest.cpp mitkRenderingManagerTest.cpp vtkMitkThickSlicesFilterTest.cpp mitkNodePredicateSourceTest.cpp mitkVectorTest.cpp mitkClippedSurfaceBoundsCalculatorTest.cpp mitkExceptionTest.cpp mitkExtractSliceFilterTest.cpp mitkLogTest.cpp mitkImageDimensionConverterTest.cpp mitkLoggingAdapterTest.cpp mitkUIDGeneratorTest.cpp mitkShaderRepositoryTest.cpp mitkPlanePositionManagerTest.cpp mitkAffineTransformBaseTest.cpp mitkPropertyAliasesTest.cpp mitkPropertyDescriptionsTest.cpp mitkPropertyExtensionsTest.cpp mitkPropertyFiltersTest.cpp mitkTinyXMLTest.cpp mitkRawImageFileReaderTest.cpp mitkInteractionEventTest.cpp mitkLookupTableTest.cpp mitkSTLFileReaderTest.cpp mitkSurfaceToImageFilterTest.cpp mitkImageToSurfaceFilterTest.cpp mitkEqualTest.cpp ) if(MITK_ENABLE_RENDERING_TESTING) #since mitkInteractionTestHelper is currently creating a vtkRenderWindow set(MODULE_TESTS ${MODULE_TESTS} mitkPointSetDataInteractorTest.cpp ) endif() # test with image filename as an extra command line parameter set(MODULE_IMAGE_TESTS mitkImageTimeSelectorTest.cpp #only runs on images mitkImageAccessorTest.cpp #only runs on images mitkDataNodeFactoryTest.cpp #runs on all types of data ) set(MODULE_SURFACE_TESTS mitkSurfaceVtkWriterTest.cpp #only runs on surfaces mitkDataNodeFactoryTest.cpp #runs on all types of data ) # list of images for which the tests are run set(MODULE_TESTIMAGES US4DCyl.nrrd Pic3D.nrrd Pic2DplusT.nrrd BallBinary30x30x30.nrrd Png2D-bw.png ) set(MODULE_TESTSURFACES binary.stl ball.stl ) set(MODULE_CUSTOM_TESTS mitkDataStorageTest.cpp mitkDataNodeTest.cpp mitkDicomSeriesReaderTest.cpp mitkDICOMLocaleTest.cpp mitkEventMapperTest.cpp mitkEventConfigTest.cpp mitkNodeDependentPointSetInteractorTest.cpp mitkStateMachineFactoryTest.cpp mitkPointSetLocaleTest.cpp mitkImageTest.cpp mitkImageWriterTest.cpp mitkImageVtkMapper2DTest.cpp mitkImageVtkMapper2DLevelWindowTest.cpp mitkImageVtkMapper2DOpacityTest.cpp mitkImageVtkMapper2DResliceInterpolationPropertyTest.cpp mitkImageVtkMapper2DColorTest.cpp mitkImageVtkMapper2DSwivelTest.cpp mitkImageVtkMapper2DTransferFunctionTest.cpp mitkImageVtkMapper2DLookupTableTest.cpp mitkSurfaceVtkMapper3DTest mitkSurfaceVtkMapper3DTexturedSphereTest.cpp mitkSurfaceGLMapper2DColorTest.cpp mitkSurfaceGLMapper2DOpacityTest.cpp mitkVolumeCalculatorTest.cpp mitkLevelWindowManagerTest.cpp mitkPointSetVtkMapper2DTest.cpp mitkPointSetVtkMapper2DImageTest.cpp mitkPointSetVtkMapper2DGlyphTypeTest.cpp mitkPointSetVtkMapper2DTransformedPointsTest.cpp mitkLabelOverlay3DRendering2DTest.cpp mitkLabelOverlay3DRendering3DTest.cpp mitkTextOverlay2DRenderingTest.cpp mitkTextOverlay2DLayouterRenderingTest.cpp mitkTextOverlay3DRendering2DTest.cpp mitkTextOverlay3DRendering3DTest.cpp mitkTextOverlay3DColorRenderingTest.cpp mitkVTKRenderWindowSizeTest.cpp mitkMultiComponentImageDataComparisonFilterTest.cpp mitkImageToItkTest.cpp mitkImageSliceSelectorTest.cpp mitkSurfaceDepthPeelingTest.cpp ) set(MODULE_RESOURCE_FILES Interactions/AddAndRemovePoints.xml Interactions/globalConfig.xml Interactions/StatemachineTest.xml Interactions/StatemachineConfigTest.xml ) # Create an artificial module initializing class for # the usServiceListenerTest.cpp usFunctionGenerateExecutableInit(testdriver_init_file IDENTIFIER ${MODULE_NAME}TestDriver ) # Embed the resources set(testdriver_resources ) usFunctionEmbedResources(testdriver_resources EXECUTABLE_NAME ${MODULE_NAME}TestDriver ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Resources FILES ${MODULE_RESOURCE_FILES} ) set(TEST_CPP_FILES ${testdriver_init_file} ${testdriver_resources}) diff --git a/Core/Code/Testing/mitkPointSetOnEmptyTest.cpp b/Core/Code/Testing/mitkPointSetOnEmptyTest.cpp new file mode 100644 index 0000000000..e12e9fc405 --- /dev/null +++ b/Core/Code/Testing/mitkPointSetOnEmptyTest.cpp @@ -0,0 +1,110 @@ +/* + * mitkPointSetTestOnEmpty.cpp + * + * Created on: Apr 23, 2014 + * Author: wirkert + */ +/** + * TestSuite for PointSet which tests properties on an empty PointSet + */ + +#include "mitkTestingMacros.h" +#include "mitkTestFixture.h" + + +#include +#include +#include +#include + +#include + +class mitkPointSetOnEmptyTestSuite : public mitk::TestFixture +{ + + CPPUNIT_TEST_SUITE(mitkPointSetOnEmptyTestSuite); + + MITK_TEST(TestInstantiation); + MITK_TEST(TestIsEmpty); + MITK_TEST(TestGetITKPointSet); + MITK_TEST(TestGetSizeIsZero); + MITK_TEST(TestAddPointDirectly); + + CPPUNIT_TEST_SUITE_END(); + +private: + + mitk::PointSet::Pointer pointSet; + +public: + + void setUp() + { + //Create PointSet + pointSet = mitk::PointSet::New(); + } + + void tearDown() + { + pointSet = NULL; + } + + void TestInstantiation() + { + CPPUNIT_ASSERT_EQUAL_MESSAGE("Testing instantiation", + true, pointSet.IsNotNull()); + } + + void TestGetITKPointSet() + { + //try to get the itkPointSet + mitk::PointSet::DataType::Pointer itkdata = NULL; + itkdata = pointSet->GetPointSet(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("try to get the itkPointSet from a newly created PointSet", + true, itkdata.IsNotNull()); + } + + void TestGetSizeIsZero() + { + //fresh PointSet has to be empty! + CPPUNIT_ASSERT_EQUAL_MESSAGE("check if the PointSet size is 0 ", + true, pointSet->GetSize() == 0); + } + + void TestIsEmpty() + { + CPPUNIT_ASSERT_EQUAL_MESSAGE("check if the PointSet is empty", + true, pointSet->IsEmptyTimeStep(0)); + } + + void TestAddPointDirectly() + { + //add a point directly + int id=0; + mitk::Point3D point; + mitk::FillVector3D(point, 1.0, 2.0, 3.0); + ++id; + pointSet->GetPointSet()->GetPoints()->InsertElement(id, point); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check if added points exists", + true, pointSet->GetSize()==1 ||pointSet->IndexExists(id)); + + mitk::Point3D tempPoint; + + tempPoint.Fill(0); + tempPoint = pointSet->GetPoint(id); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check if added point contains real value", + true, point == tempPoint); + } + + + +}; + +MITK_TEST_SUITE_REGISTRATION(mitkPointSetOnEmpty) + + + + + diff --git a/Core/Code/Testing/mitkPointSetPointOperationsTest.cpp b/Core/Code/Testing/mitkPointSetPointOperationsTest.cpp new file mode 100644 index 0000000000..6516ce348c --- /dev/null +++ b/Core/Code/Testing/mitkPointSetPointOperationsTest.cpp @@ -0,0 +1,291 @@ +/* + * mitkPoinSetPointOperationsTest.cpp + * + * Created on: Apr 23, 2014 + * Author: wirkert + */ + + +#include "mitkTestingMacros.h" +#include "mitkTestFixture.h" + + +#include +#include +#include +#include + +#include + + +/** + * TestSuite for all PointSet manipulations done by PointOperations + */ +class mitkPointSetPointOperationsTestSuite : public mitk::TestFixture +{ + CPPUNIT_TEST_SUITE(mitkPointSetPointOperationsTestSuite); + + MITK_TEST(TestCreateOperationAndAddPoint); + MITK_TEST(TestPointOperationOpMove); + MITK_TEST(TestPointOperationOpRemove); + MITK_TEST(TestPointOperationOpSelectPoint); + MITK_TEST(TestOpDeselectPoint); + MITK_TEST(TestOpMovePointUp); + MITK_TEST(TestOpMovePointDown); + MITK_TEST(TestOpMovePointUpOnFirstPoint); + + CPPUNIT_TEST_SUITE_END(); + +private: + + mitk::PointSet::Pointer pointSet; + mitk::PointOperation* doOp; + +public: + + void setUp() + { + //Create PointSet + pointSet = mitk::PointSet::New(); + + // add some points + mitk::Point3D point2, point3, point4; + point2.Fill(3); + point3.Fill(4); + point4.Fill(5); + pointSet->InsertPoint(2,point2); + pointSet->InsertPoint(3,point3); + pointSet->InsertPoint(4,point4); + } + + void tearDown() + { + pointSet = NULL; + delete doOp; + } + + void TestCreateOperationAndAddPoint() + { + int id = 0; + mitk::Point3D point; + point.Fill(1); + + doOp = new mitk::PointOperation(mitk::OpINSERT, point, id); + + pointSet->ExecuteOperation(doOp); + CPPUNIT_ASSERT_EQUAL_MESSAGE("check if added points exists", + true, pointSet->GetSize()==4 && pointSet->IndexExists(id)); + + + mitk::Point3D tempPoint; + tempPoint.Fill(0); + + tempPoint = pointSet->GetPoint(id); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check if added point contains real value", + true, point == tempPoint); + } + + + void TestPointOperationOpMove() + { + //check opMOVE ExecuteOperation + int id=1; + mitk::Point3D point1; + mitk::Point3D tempPoint; + point1.Fill(2); + + doOp = new mitk::PointOperation(mitk::OpMOVE, point1, id); + + pointSet->ExecuteOperation(doOp); + tempPoint = pointSet->GetPoint(id); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpMove ", + true, tempPoint == point1); + + /* + if (tempPoint != point1) + { + std::cout<<"[FAILED]"<GetPoint(id); + + doOp = new mitk::PointOperation(mitk::OpREMOVE, point, id); + + pointSet->ExecuteOperation(doOp); + tempPoint = pointSet->GetPoint(id); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpREMOVE ", + false, pointSet->IndexExists(id) ); + + /* + if(pointSet->IndexExists(id)) + { + std::cout<<"[FAILED]"<ExecuteOperation(doOp); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpSELECTPOINT ", + true, pointSet->GetSelectInfo(3)); + + /* + if (!pointSet->GetSelectInfo(4)) + { + std::cout<<"[FAILED]"<ExecuteOperation(doOp); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpDESELECTPOINT ", + false, pointSet->GetSelectInfo(4)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("check GetNumeberOfSelected ", + true, pointSet->GetNumberOfSelected() == 0 ); + + /* + if (pointSet->GetSelectInfo(4)) + { + std::cout<<"[FAILED]"<GetNumberOfSelected() != 0) + { + std::cout<<"[FAILED]"<GetPoint(id); + + doOp = new mitk::PointOperation(mitk::OpMOVEPOINTUP, point4, id); + + pointSet->ExecuteOperation(doOp); + tempPoint = pointSet->GetPoint(id-1); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpMOVEPOINTUP ", + true, tempPoint == point); + + /* + if (tempPoint != point) + { + std::cout<<"[FAILED]"<GetPoint(id); + doOp = new mitk::PointOperation(mitk::OpMOVEPOINTDOWN, point2, id); + pointSet->ExecuteOperation(doOp); + tempPoint = pointSet->GetPoint(id+1); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpMOVEPOINTDOWN ", + true, tempPoint == point); + + /* + if (tempPoint != point) + { + std::cout<<"[FAILED]"<GetPoint(1); + mitk::PointSet::PointType p2 = pointSet->GetPoint(2); + + doOp = new mitk::PointOperation(mitk::OpMOVEPOINTUP, p1, 1); + + pointSet->ExecuteOperation(doOp); + + + mitk::PointSet::PointType newP1 = pointSet->GetPoint(1); + mitk::PointSet::PointType newP2 = pointSet->GetPoint(2); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpMOVEPOINTUP for point id 1: ", + true, ((newP1 == p1) && (newP2 == p2))); + + /* + if (((newP1 == p1) && (newP2 == p2)) == false) + { + std::cout<<"[FAILED]"< #include #include #include #include -/** - * TestSuite for PointSet which tests properties on an empty PointSet - */ -class mitkPointSetBasicsTestSuite : public mitk::TestFixture -{ - - CPPUNIT_TEST_SUITE(mitkPointSetBasicsTestSuite); - - MITK_TEST(TestInstantiation); - MITK_TEST(TestIsEmpty); - MITK_TEST(TestGetITKPointSet); - MITK_TEST(TestGetSizeIsZero); - MITK_TEST(TestAddPointDirectly); - - CPPUNIT_TEST_SUITE_END(); - -private: - - mitk::PointSet::Pointer pointSet; - -public: - - void Setup() - { - //Create PointSet - pointSet = mitk::PointSet::New(); - } - - void TearDown() - { - pointSet = NULL; - } - - void TestInstantiation() - { - MITK_TEST_CONDITION_REQUIRED(pointSet.IsNotNull(),"Testing instantiation") - } - - void TestGetITKPointSet() - { - //try to get the itkPointSet - mitk::PointSet::DataType::Pointer itkdata = NULL; - itkdata = pointSet->GetPointSet(); - MITK_TEST_CONDITION( itkdata.IsNotNull(), "try to get the itkPointSet from a newly created PointSet" ) - } - - void TestGetSizeIsZero() - { - //fresh PointSet has to be empty! - MITK_TEST_CONDITION( pointSet->GetSize() == 0, "check if the PointSet size is 0 " ) - } - - void TestIsEmpty() - { - MITK_TEST_CONDITION(pointSet->IsEmptyTimeStep(0), "check if the PointSet is empty" ) - } - - void TestAddPointDirectly() - { - //add a point directly - int id=0; - mitk::Point3D point; - mitk::FillVector3D(point, 1.0, 2.0, 3.0); - ++id; - pointSet->GetPointSet()->GetPoints()->InsertElement(id, point); - - MITK_TEST_CONDITION( pointSet->GetSize()==1 ||pointSet->IndexExists(id), "check if added points exists" ) - - mitk::Point3D tempPoint; - - tempPoint.Fill(0); - tempPoint = pointSet->GetPoint(id); - - MITK_TEST_CONDITION( point == tempPoint, "check if added point contains real value" ) - } - - - -}; - -MITK_TEST_SUITE_REGISTRATION(mitkPointSetBasics) - /** * TestSuite for PointSet stuff not only operating on an empty PointSet */ -class mitkPointSetAdvancedTestSuite : public mitk::TestFixture +class mitkPointSetTestSuite : public mitk::TestFixture { - CPPUNIT_TEST_SUITE(mitkPointSetAdvancedTestSuite); + CPPUNIT_TEST_SUITE(mitkPointSetTestSuite); MITK_TEST(TestIsNotEmpty); MITK_TEST(TestSetSelectInfo); MITK_TEST(TestGetNumberOfSelected); MITK_TEST(TestSearchSelectedPoint); MITK_TEST(TestGetPointIfExists); MITK_TEST(TestSwapPointPositionUpwards); MITK_TEST(TestSwapPointPositionUpwardsNotPossible); MITK_TEST(TestSwapPointPositionDownwards); MITK_TEST(TestSwapPointPositionDownwardsNotPossible); MITK_TEST(TestCreateHoleInThePointIDs); MITK_TEST(TestInsertPointWithPointSpecification); CPPUNIT_TEST_SUITE_END(); private: mitk::PointSet::Pointer pointSet; static const mitk::PointSet::PointIdentifier selectedPointId = 2; public: - void Setup() + void setUp() { //Create PointSet pointSet = mitk::PointSet::New(); // add some points mitk::Point3D point2, point3, point4; point2.Fill(3); point3.Fill(4); point4.Fill(5); pointSet->InsertPoint(2,point2); pointSet->InsertPoint(3,point3); pointSet->InsertPoint(4,point4); mitk::Point3D point1; mitk::FillVector3D(point1, 1.0, 2.0, 3.0); pointSet->InsertPoint(1, point1); mitk::Point3D point0; point0.Fill(1); pointSet->InsertPoint(0, point0); // select point with id 2 pointSet->SetSelectInfo(2, true); } - void TearDown() + void tearDown() { pointSet = NULL; } void TestIsNotEmpty() { //PointSet can not be empty! - CPPUNIT_ASSERT_EQUAL_MESSAGE( "check if the PointSet is not empty ", true, !pointSet->IsEmptyTimeStep(0) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "check if the PointSet is not empty ", + true, !pointSet->IsEmptyTimeStep(0) ); /* std::cout << "check if the PointSet is not empty "; if (pointSet->IsEmpty(0)) { std::cout<<"[FAILED]"<SetSelectInfo(4, true); - MITK_TEST_CONDITION(pointSet->GetSelectInfo(4) , "check SetSelectInfo" ) + CPPUNIT_ASSERT_EQUAL_MESSAGE("check SetSelectInfo", + true, pointSet->GetSelectInfo(4)); /* if (!pointSet->GetSelectInfo(2)) { std::cout<<"[FAILED]"<SearchSelectedPoint() == (int) selectedPointId , "check SearchSelectedPoint " ) + CPPUNIT_ASSERT_EQUAL_MESSAGE("check SearchSelectedPoint ", + true, pointSet->SearchSelectedPoint() == (int) selectedPointId); /* if( pointSet->SearchSelectedPoint() != 4) { std::cout<<"[FAILED]"<GetNumberOfSelected() == 1 , "check GetNumeberOfSelected " ) + CPPUNIT_ASSERT_EQUAL_MESSAGE("check GetNumeberOfSelected ", + true, pointSet->GetNumberOfSelected() == 1); + /* if(pointSet->GetNumberOfSelected() != 1) { std::cout<<"[FAILED]"<GetPointIfExists(4, &tmpPoint); - MITK_TEST_CONDITION(tmpPoint == point4, "check GetPointIfExists: " ) + CPPUNIT_ASSERT_EQUAL_MESSAGE("check GetPointIfExists: ", + true, tmpPoint == point4); /* if (tmpPoint != point5) { std::cout<<"[FAILED]"<GetPoint(1); pointSet->SwapPointPosition(1, true); tempPoint = pointSet->GetPoint(0); - MITK_TEST_CONDITION( point == tempPoint, "check SwapPointPosition upwards" ) + CPPUNIT_ASSERT_EQUAL_MESSAGE("check SwapPointPosition upwards", + true, point == tempPoint); /* if(point != tempPoint) { std::cout<<"[FAILED]"<SwapPointPosition(0, true)==false, "check SwapPointPosition upwards not possible" ) + CPPUNIT_ASSERT_EQUAL_MESSAGE("check SwapPointPosition upwards not possible", + false, pointSet->SwapPointPosition(0, true)); /* if(pointSet->SwapPointPosition(0, true)) { std::cout<<"[FAILED]"<GetPoint(0); pointSet->SwapPointPosition(0, false); tempPoint = pointSet->GetPoint(1); - MITK_TEST_CONDITION( point == tempPoint, "check SwapPointPosition down" ) + CPPUNIT_ASSERT_EQUAL_MESSAGE("check SwapPointPosition down", + true, point == tempPoint); /* if(point != tempPoint) { std::cout<<"[FAILED]"<SetPoint(id, point); //Check SwapPointPosition downwards not possible - MITK_TEST_CONDITION(!pointSet2->SwapPointPosition(id, false), "check SwapPointPosition downwards not possible" ) + CPPUNIT_ASSERT_EQUAL_MESSAGE("check SwapPointPosition downwards not possible", + false, pointSet2->SwapPointPosition(id, false)); /* if(pointSet->SwapPointPosition(1, false)) { std::cout<<"[FAILED]"<InsertPoint(10, p10); pointSet->InsertPoint(11, p11); pointSet->InsertPoint(12, p12); - MITK_TEST_CONDITION((pointSet->IndexExists(10) == true) || (pointSet->IndexExists(11) == true) || (pointSet->IndexExists(12) == true), "add points with id 10, 11, 12: " ) + CPPUNIT_ASSERT_EQUAL_MESSAGE("add points with id 10, 11, 12: ", + true, (pointSet->IndexExists(10) == true) || (pointSet->IndexExists(11) == true) || (pointSet->IndexExists(12) == true)); //check OpREMOVE ExecuteOperation int id = 11; mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpREMOVE, point, id); pointSet->ExecuteOperation(doOp); - MITK_TEST_CONDITION(!pointSet->IndexExists(id), "remove point id 11: ") + CPPUNIT_ASSERT_EQUAL_MESSAGE( "remove point id 11: ", + false, pointSet->IndexExists(id)); /* if(pointSet->IndexExists(id)) { std::cout<<"[FAILED]"<ExecuteOperation(doOp); delete doOp; //check OpMOVEPOINTUP ExecuteOperation doOp = new mitk::PointOperation(mitk::OpMOVEPOINTUP, p12, 12); pointSet->ExecuteOperation(doOp); delete doOp; mitk::PointSet::PointType newP10 = pointSet->GetPoint(10); mitk::PointSet::PointType newP12 = pointSet->GetPoint(12); - MITK_TEST_CONDITION(((newP10 == p12) && (newP12 == p10)) == true, "check PointOperation OpMOVEPOINTUP for point id 12:" ) + CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpMOVEPOINTUP for point id 12:", + true, ((newP10 == p12) && (newP12 == p10))); //check OpMOVEPOINTDOWN ExecuteOperation doOp = new mitk::PointOperation(mitk::OpMOVEPOINTDOWN, p10, 10); pointSet->ExecuteOperation(doOp); delete doOp; newP10 = pointSet->GetPoint(10); newP12 = pointSet->GetPoint(12); - MITK_TEST_CONDITION(((newP10 == p10) && (newP12 == p12)) == true, "check PointOperation OpMOVEPOINTDOWN for point id 10: ") + CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpMOVEPOINTDOWN for point id 10: ", + true, ((newP10 == p10) && (newP12 == p12))); } void TestInsertPointWithPointSpecification() { //check InsertPoint with PointSpecification mitk::Point3D point5; mitk::Point3D tempPoint; point5.Fill(7); pointSet->SetPoint(5, point5, mitk::PTEDGE ); tempPoint = pointSet->GetPoint(5); - MITK_TEST_CONDITION(tempPoint == point5, "check InsertPoint with PointSpecification" ) + CPPUNIT_ASSERT_EQUAL_MESSAGE("check InsertPoint with PointSpecification" , + true, tempPoint == point5); /* if (tempPoint != point5) { std::cout<<"[FAILED]"<InsertPoint(2,point2); - pointSet->InsertPoint(3,point3); - pointSet->InsertPoint(4,point4); - } - - void TearDown() - { - pointSet = NULL; - } - - void TestCreateOperationAndAddPoint() - { - int id = 0; - mitk::Point3D point; - point.Fill(1); - - mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpINSERT, point, id); - pointSet->ExecuteOperation(doOp); - MITK_TEST_CONDITION( pointSet->GetSize()==1 && pointSet->IndexExists(id), "check if added points exists" ) - - delete doOp; - - mitk::Point3D tempPoint; - tempPoint.Fill(0); - - tempPoint = pointSet->GetPoint(id); - - MITK_TEST_CONDITION( point == tempPoint, "check if added point contains real value" ) - } - - - void TestPointOperationOpMove() - { - //check opMOVE ExecuteOperation - int id=1; - mitk::Point3D point1; - mitk::Point3D tempPoint; - point1.Fill(2); - - mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpMOVE, point1, id); - pointSet->ExecuteOperation(doOp); - tempPoint = pointSet->GetPoint(id); - - MITK_TEST_CONDITION(tempPoint == point1 , "check PointOperation OpMove " ) - delete doOp; - /* - if (tempPoint != point1) - { - std::cout<<"[FAILED]"<GetPoint(id); - mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpREMOVE, point, id); - pointSet->ExecuteOperation(doOp); - tempPoint = pointSet->GetPoint(id); - - MITK_TEST_CONDITION(!pointSet->IndexExists(id) , "check PointOperation OpREMOVE " ) - delete doOp; - /* - if(pointSet->IndexExists(id)) - { - std::cout<<"[FAILED]"<ExecuteOperation(doOp); - - MITK_TEST_CONDITION(pointSet->GetSelectInfo(3) , "check PointOperation OpSELECTPOINT " ) - delete doOp; - /* - if (!pointSet->GetSelectInfo(4)) - { - std::cout<<"[FAILED]"<ExecuteOperation(doOp); - - MITK_TEST_CONDITION(!pointSet->GetSelectInfo(4) , "check PointOperation OpDESELECTPOINT " ) - MITK_TEST_CONDITION(pointSet->GetNumberOfSelected() == 0 , "check GetNumeberOfSelected " ) - delete doOp; - /* - if (pointSet->GetSelectInfo(4)) - { - std::cout<<"[FAILED]"<GetNumberOfSelected() != 0) - { - std::cout<<"[FAILED]"<GetPoint(id); - mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpMOVEPOINTUP, point4, id); - pointSet->ExecuteOperation(doOp); - tempPoint = pointSet->GetPoint(id-1); - - MITK_TEST_CONDITION(tempPoint == point , "check PointOperation OpMOVEPOINTUP " ) - delete doOp; - /* - if (tempPoint != point) - { - std::cout<<"[FAILED]"<GetPoint(id); - mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpMOVEPOINTDOWN, point2, id); - pointSet->ExecuteOperation(doOp); - tempPoint = pointSet->GetPoint(id+1); - - MITK_TEST_CONDITION(tempPoint == point , "check PointOperation OpMOVEPOINTDOWN " ) - delete doOp; - /* - if (tempPoint != point) - { - std::cout<<"[FAILED]"<GetPoint(1); - mitk::PointSet::PointType p2 = pointSet->GetPoint(2); - mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpMOVEPOINTUP, p1, 1); - pointSet->ExecuteOperation(doOp); - delete doOp; - - mitk::PointSet::PointType newP1 = pointSet->GetPoint(1); - mitk::PointSet::PointType newP2 = pointSet->GetPoint(2); - - MITK_TEST_CONDITION(((newP1 == p1) && (newP2 == p2)) == true, "check PointOperation OpMOVEPOINTUP for point id 1: ") - - /* - if (((newP1 == p1) && (newP2 == p2)) == false) - { - std::cout<<"[FAILED]"<InsertPoint(17, point); // pointSet->SetPoint(4, point); // pointSet->SetPoint(7, point); // pointSet->SetPoint(2, point); // pointSet->SwapPointPosition(7, true); // pointSet->SwapPointPosition(3, true); // pointSet->SwapPointPosition(2, false); // mitkPointSetTestClass::TestPointContainerPointDataContainer(pointSet); // // MITK_TEST_OUTPUT(<< "Test OpREMOVE"); // mitk::PointOperation op1(mitk::OpREMOVE, mitk::Point3D(), 2); // existing index // pointSet->ExecuteOperation(&op1); // mitk::PointOperation op1b(mitk::OpREMOVE, mitk::Point3D(), 112); // non existing index // pointSet->ExecuteOperation(&op1b); // mitkPointSetTestClass::TestPointContainerPointDataContainer(pointSet); // // MITK_TEST_OUTPUT(<< "Test OpMove"); // mitk::PointOperation op2(mitk::OpMOVE, mitk::Point3D(), 4); // existing index // pointSet->ExecuteOperation(&op2); // mitk::PointOperation op3(mitk::OpMOVE, mitk::Point3D(), 34); // non existing index // pointSet->ExecuteOperation(&op3); // mitkPointSetTestClass::TestPointContainerPointDataContainer(pointSet); // // MITK_TEST_OUTPUT(<< "Test OpINSERT"); // mitk::PointOperation op4(mitk::OpINSERT, mitk::Point3D(), 38); // non existing index // pointSet->ExecuteOperation(&op4); // mitk::PointOperation op5(mitk::OpINSERT, mitk::Point3D(), 17); // existing index // pointSet->ExecuteOperation(&op5); // mitkPointSetTestClass::TestPointContainerPointDataContainer(pointSet); // // // // pointSet = mitk::PointSet::New(); // pointSet->Expand(3); // mitk::Point3D new0, new1, new2; // new0.Fill(0); // new1.Fill(1); // new2.Fill(2); // pointSet->InsertPoint(5,new0, mitk::PTCORNER,0); // pointSet->InsertPoint(112,new1,0); // pointSet->InsertPoint(2,new2,0); // pointSet->InsertPoint(2,new0,1); // pointSet->InsertPoint(1,new1,1); // pointSet->InsertPoint(0,new2,1); // pointSet->InsertPoint(0,new0,2); // pointSet->InsertPoint(2,new1,2); // pointSet->InsertPoint(1,new2,2); // // MITK_TEST_OUTPUT( << "... pointset ts: " << pointSet->GetTimeSteps() ) // mitk::PointSet::Pointer clonePS = pointSet->Clone(); // MITK_TEST_OUTPUT( << "... clone pointset ts: " << clonePS->GetTimeSteps() ) // // for (unsigned int t=0; t< pointSet->GetTimeSteps(); t++) // { // MITK_TEST_OUTPUT( << "testing timestep: " << t ) // MITK_TEST_CONDITION_REQUIRED(pointSet->GetSize(t) == clonePS->GetSize(t), "Clone has same size") // // // test for equal point coordinates // for (mitk::PointSet::PointsConstIterator i = pointSet->Begin(), j = clonePS->Begin(); // i != pointSet->End() && j != clonePS->End(); ++i, ++j) // { // MITK_TEST_CONDITION_REQUIRED(i.Index() == j.Index() && mitk::Equal(i.Value(),j.Value()), "Cloned PS and PS have same points") // } // // // test for equal point data // mitk::PointSet::PointDataContainer* pointDataCont = pointSet->GetPointSet(t)->GetPointData(); // mitk::PointSet::PointDataContainer* clonePointDataCont = clonePS->GetPointSet(t)->GetPointData(); // MITK_TEST_CONDITION_REQUIRED(pointDataCont && clonePointDataCont, "Valid point data container") // MITK_TEST_CONDITION_REQUIRED(pointDataCont->Size() == clonePointDataCont->Size(), "Cloned point data container has same size") // for (mitk::PointSet::PointDataConstIterator i = pointDataCont->Begin(), j = clonePointDataCont->Begin(); // i != pointDataCont->End() && j != clonePointDataCont->End(); ++i, ++j) // { // MITK_TEST_CONDITION_REQUIRED(i.Index() == j.Index() && i.Value() == j.Value(), "Cloned PS and PS have same point data") // } // } // // // mitkPointSetTestClass::TestIsNotEmpty(clonePS); // MITK_TEST_CONDITION_REQUIRED(clonePS->GetPointSetSeriesSize() == pointSet->GetPointSetSeriesSize(), "Testing cloned point set's size!"); // MITK_TEST_CONDITION_REQUIRED(clonePS.GetPointer() != pointSet.GetPointer(), "Testing that the clone is not the source PS!"); // MITK_TEST_CONDITION_REQUIRED(clonePS->GetGeometry()->GetCenter() == pointSet->GetGeometry()->GetCenter() , "Testing if the geometry is cloned correctly!"); // MITK_TEST_CONDITION_REQUIRED(clonePS->GetPropertyList()->GetMap()->size() == pointSet->GetPropertyList()->GetMap()->size() , "Testing if the property list is cloned correctly!"); // // Also testing, that clone is independent from original // mitk::Point3D p, p2; // p.Fill(42); // p2.Fill(84); // clonePS->InsertPoint(0,p); // pointSet->InsertPoint(0,p2); // p = clonePS->GetPoint(0); // p2 = pointSet->GetPoint(0); // MITK_TEST_CONDITION_REQUIRED(p != p2, "Testing that the clone is independent from source!"); // // // MITK_TEST_END(); //} // // //class mitkPointSetTestClass { public: // //static void TestGetITKPointSet(mitk::PointSet *pointSet) //{ // //try to get the itkPointSet // mitk::PointSet::DataType::Pointer itkdata = NULL; // itkdata = pointSet->GetPointSet(); // MITK_TEST_CONDITION( itkdata.IsNotNull(), "try to get the itkPointSet from a newly created PointSet" ) //} // //static void TestGetSizeIsZero(mitk::PointSet *pointSet) //{ // //fresh PointSet has to be empty! // MITK_TEST_CONDITION( pointSet->GetSize() == 0, "check if the PointSet size is 0 " ) //} // //static void TestIsEmpty(mitk::PointSet *pointSet) //{ // MITK_TEST_CONDITION(pointSet->IsEmptyTimeStep(0), "check if the PointSet is empty" ) //} // //static void TestCreateOperationAndAddPoint(mitk::PointSet *pointSet) //{ // int id = 0; // mitk::Point3D point; // point.Fill(1); // // mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpINSERT, point, id); // pointSet->ExecuteOperation(doOp); // MITK_TEST_CONDITION( pointSet->GetSize()==1 && pointSet->IndexExists(id), "check if added points exists" ) // // delete doOp; // // mitk::Point3D tempPoint; // tempPoint.Fill(0); // // tempPoint = pointSet->GetPoint(id); // // MITK_TEST_CONDITION( point == tempPoint, "check if added point contains real value" ) //} // // // // // // // // // //static void TestPointContainerPointDataContainer(mitk::PointSet* ps) //{ // mitk::PointSet::PointsContainer* pc = ps->GetPointSet()->GetPoints(); // mitk::PointSet::PointDataContainer* pd = ps->GetPointSet()->GetPointData(); // MITK_TEST_CONDITION_REQUIRED(pc->Size() == pd->Size(), "PointContainer and PointDataContainer have same size"); // mitk::PointSet::PointsContainer::ConstIterator pIt = pc->Begin(); // mitk::PointSet::PointDataContainer::ConstIterator dIt = pd->Begin(); // bool failed = false; // for (; pIt != pc->End(); ++pIt, ++dIt) // if (pIt->Index() != dIt->Index()) // { // failed = true; // break; // } // MITK_TEST_CONDITION(failed == false, "Indices in PointContainer and PointDataContainer are equal"); //} //};