diff --git a/Core/Code/Testing/mitkSTLFileReaderTest.cpp b/Core/Code/Testing/mitkSTLFileReaderTest.cpp index 842bc35f98..7876cf03c6 100644 --- a/Core/Code/Testing/mitkSTLFileReaderTest.cpp +++ b/Core/Code/Testing/mitkSTLFileReaderTest.cpp @@ -1,77 +1,84 @@ /*=================================================================== 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 "mitkSTLFileReader.h" #include "mitkSlicedGeometry3D.h" #include "mitkSurface.h" #include "mitkTestingMacros.h" +#include "mitkTestFixture.h" #include #include #include #include -int mitkSTLFileReaderTest(int argc, char* argv[]) + +class mitkSTLFileReaderTestSuite : public mitk::TestFixture { - // always start with this! - MITK_TEST_BEGIN("STLFileReader") + CPPUNIT_TEST_SUITE(mitkSTLFileReaderTestSuite); + MITK_TEST(testReadFile); + CPPUNIT_TEST_SUITE_END(); - //Read STL-Image from file - mitk::STLFileReader::Pointer reader = mitk::STLFileReader::New(); +private: + + /** Members used inside the different test methods. All members are initialized via setUp().*/ + std::string m_SurfacePath; - if(argc==0) +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() { - std::cout<<"file not found - test not applied [PASSED]"<CanReadFile(argv[1], "", "")) + void tearDown() { - //std::cout<<"[FAILED]"<NumberOfPassedTests() << " tests [DONE PASSED] File is not STL!") - return EXIT_SUCCESS; } - std::cout<<"[PASSED]"<SetFileName(argv[1]); +void testReadFile() + { + //Read STL-Image from file + mitk::STLFileReader::Pointer reader = mitk::STLFileReader::New(); + if (!reader->CanReadFile(m_SurfacePath, "", "")) {CPPUNIT_FAIL("Cannot read test data STL file.");} + reader->SetFileName(m_SurfacePath); reader->Update(); - - MITK_TEST_CONDITION_REQUIRED((reader->GetOutput() != NULL),"Reader output not NULL") - mitk::Surface::Pointer surface = reader->GetOutput(); - MITK_TEST_CONDITION_REQUIRED(surface->IsInitialized(),"IsInitialized()") - MITK_TEST_CONDITION_REQUIRED((surface->GetVtkPolyData()!=NULL),"mitk::Surface::SetVtkPolyData()") - - MITK_TEST_CONDITION_REQUIRED((surface->GetGeometry()!=NULL),"Availability of geometry") + //check some basic stuff + CPPUNIT_ASSERT_MESSAGE("Reader output not NULL",surface.IsNotNull()); + CPPUNIT_ASSERT_MESSAGE("IsInitialized()",surface->IsInitialized()); + CPPUNIT_ASSERT_MESSAGE("mitk::Surface::SetVtkPolyData()",(surface->GetVtkPolyData()!=NULL)); + CPPUNIT_ASSERT_MESSAGE("Availability of geometry",(surface->GetGeometry()!=NULL)); + //use vtk stl reader for reference vtkSmartPointer myVtkSTLReader = vtkSmartPointer::New(); - myVtkSTLReader->SetFileName( argv[1] ); + myVtkSTLReader->SetFileName( m_SurfacePath.c_str() ); myVtkSTLReader->Update(); vtkSmartPointer myVtkPolyData = myVtkSTLReader->GetOutput(); - // vtkPolyData from vtkSTLReader directly + //vtkPolyData from vtkSTLReader directly int n = myVtkPolyData->GetNumberOfPoints(); - // vtkPolyData from mitkSTLFileReader + //vtkPolyData from mitkSTLFileReader int m = surface->GetVtkPolyData()->GetNumberOfPoints(); - MITK_TEST_CONDITION_REQUIRED((n == m),"Number of Points in VtkPolyData") + CPPUNIT_ASSERT_MESSAGE("Number of Points in VtkPolyData",(n == m)); + + } - // always end with this! - MITK_TEST_END() -} +}; +MITK_TEST_SUITE_REGISTRATION(mitkSTLFileReader)