diff --git a/Core/Code/Testing/CMakeLists.txt b/Core/Code/Testing/CMakeLists.txt index 1033612d76..98dce547ee 100644 --- a/Core/Code/Testing/CMakeLists.txt +++ b/Core/Code/Testing/CMakeLists.txt @@ -1,17 +1,19 @@ MITK_CREATE_MODULE_TESTS(LABELS MITK-Core) # MITK_INSTALL_TARGETS(EXECUTABLES MitkTestDriver) mitkAddCustomModuleTest(mitkPicFileReaderTest_emptyFile mitkPicFileReaderTest ${CMAKE_CURRENT_SOURCE_DIR}/Data/emptyFile.pic) mitkAddCustomModuleTest(mitkPicFileReaderTest_emptyGzipFile mitkPicFileReaderTest ${CMAKE_CURRENT_SOURCE_DIR}/Data/emptyFile.pic.gz) mitkAddCustomModuleTest(mitkDICOMLocaleTest mitkDICOMLocaleTest ${MITK_DATA_DIR}/spacing-ok.dcm) mitkAddCustomModuleTest(mitkEventMapperTest mitkEventMapperTest ${MITK_DATA_DIR}/TestStateMachine1.xml ${MITK_DATA_DIR}/TestStateMachine2.xml) mitkAddCustomModuleTest(mitkNodeDependentPointSetInteractorTest mitkNodeDependentPointSetInteractorTest ${MITK_DATA_DIR}/Pic3D.pic.gz ${MITK_DATA_DIR}/BallBinary30x30x30.pic.gz) mitkAddCustomModuleTest(mitkDataStorageTest_US4DCyl mitkDataStorageTest ${MITK_DATA_DIR}/US4DCyl.pic.gz) mitkAddCustomModuleTest(mitkStateMachineFactoryTest_TestStateMachine1_2 mitkStateMachineFactoryTest ${MITK_DATA_DIR}/TestStateMachine1.xml ${MITK_DATA_DIR}/TestStateMachine2.xml) +ADD_TEST(mitkPointSetLocaleTest ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} mitkPointSetLocaleTest ${MITK_DATA_DIR}/pointSet.mps) +SET_PROPERTY(TEST mitkPointSetLocaleTest PROPERTY LABELS MITK-Core) diff --git a/Core/Code/Testing/files.cmake b/Core/Code/Testing/files.cmake index e3667e0a46..b72e1e37fc 100644 --- a/Core/Code/Testing/files.cmake +++ b/Core/Code/Testing/files.cmake @@ -1,92 +1,91 @@ # tests with no extra command line parameter SET(MODULE_TESTS - mitkCoreObjectFactoryTest.cpp + mitkCoreObjectFactoryTest.cpp mitkPointSetWriterTest.cpp mitkMaterialTest.cpp mitkActionTest.cpp mitkEnumerationPropertyTest.cpp mitkEventTest.cpp mitkFocusManagerTest.cpp mitkGenericPropertyTest.cpp mitkGeometry3DTest.cpp mitkGeometryDataToSurfaceFilterTest.cpp mitkGlobalInteractionTest.cpp mitkImageDataItemTest.cpp #mitkImageMapper2DTest.cpp mitkImageTest.cpp mitkImageGeneratorTest.cpp mitkBaseDataTest.cpp #mitkImageToItkTest.cpp mitkInteractorTest.cpp mitkITKThreadingTest.cpp # mitkLevelWindowManagerTest.cpp mitkLevelWindowTest.cpp mitkMessageTest.cpp #mitkPipelineSmartPointerCorrectnessTest.cpp mitkPixelTypeTest.cpp mitkPlaneGeometryTest.cpp mitkPointSetFileIOTest.cpp mitkPointSetTest.cpp mitkPointSetInteractorTest.cpp mitkPropertyListTest.cpp #mitkRegistrationBaseTest.cpp #mitkSegmentationInterpolationTest.cpp mitkSlicedGeometry3DTest.cpp mitkSliceNavigationControllerTest.cpp mitkStateMachineTest.cpp mitkStateTest.cpp mitkSurfaceTest.cpp mitkSurfaceToSurfaceFilterTest.cpp mitkTimeSlicedGeometryTest.cpp mitkTransitionTest.cpp mitkUndoControllerTest.cpp mitkVtkWidgetRenderingTest.cpp mitkVerboseLimitedLinearUndoTest.cpp mitkWeakPointerTest.cpp mitkTransferFunctionTest.cpp #mitkAbstractTransformGeometryTest.cpp #mitkPicFileIOTest.cpp mitkStepperTest.cpp itkTotalVariationDenoisingImageFilterTest.cpp - mitkPointSetLocaleTest.cpp mitkRenderingManagerTest.cpp vtkMitkThickSlicesFilterTest.cpp mitkNodePredicateSourceTest.cpp ) # test with image filename as an extra command line parameter SET(MODULE_IMAGE_TESTS mitkSurfaceVtkWriterTest.cpp mitkPicFileWriterTest.cpp mitkImageWriterTest.cpp #mitkImageSliceSelectorTest.cpp mitkImageTimeSelectorTest.cpp mitkPicFileReaderTest.cpp # mitkVtkPropRendererTest.cpp mitkDataNodeFactoryTest.cpp #mitkSTLFileReaderTest.cpp ) # list of images for which the tests are run SET(MODULE_TESTIMAGES US4DCyl.pic.gz Pic3D.pic.gz Pic2DplusT.pic.gz BallBinary30x30x30.pic.gz binary.stl ball.stl ) -SET(MODULE_CUSTOM_TESTS +SET(MODULE_CUSTOM_TESTS #mitkLabeledImageToSurfaceFilterTest.cpp #mitkExternalToolsTest.cpp mitkDataStorageTest.cpp mitkDataNodeTest.cpp mitkDicomSeriesReaderTest.cpp mitkDICOMLocaleTest.cpp mitkEventMapperTest.cpp mitkNodeDependentPointSetInteractorTest.cpp mitkStateMachineFactoryTest.cpp + mitkPointSetLocaleTest.cpp ) - diff --git a/Core/Code/Testing/mitkPointSetLocaleTest.cpp b/Core/Code/Testing/mitkPointSetLocaleTest.cpp index 32847422af..ebb61b8f8e 100644 --- a/Core/Code/Testing/mitkPointSetLocaleTest.cpp +++ b/Core/Code/Testing/mitkPointSetLocaleTest.cpp @@ -1,174 +1,178 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkPointSetReader.h" #include "mitkPointSetWriter.h" #include "mitkStandardFileLocations.h" #include "mitkTestingMacros.h" #include #include #include #include bool ChangeLocale(const std::string& locale) { try { MITK_TEST_OUTPUT(<< "\n** 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); std::cout.imbue(l); return true; } catch(...) { MITK_TEST_OUTPUT(<< "Could not activate locale" << locale << "\n"); return false; } } -void ReaderLocaleTest(mitk::Point3D & refPoint) +void ReaderLocaleTest(mitk::Point3D & refPoint, std::string filename) { MITK_TEST_OUTPUT(<< "---- Reader Test ---- "); - mitk::StandardFileLocations::Pointer locator = mitk::StandardFileLocations::GetInstance(); - MITK_TEST_CONDITION_REQUIRED(locator.IsNotNull(),"Instantiating StandardFileLocations"); - std::string filename = locator->FindFile("pointSet.mps", "Core/Code/Testing/Data/"); - + mitk::PointSetReader::Pointer reader = mitk::PointSetReader::New(); - reader -> SetFileName(filename); + reader -> SetFileName(filename.c_str()); reader -> Update(); mitk::PointSet::Pointer pointSet = reader -> GetOutput(); mitk::Point3D point; if (pointSet->GetPointIfExists(0, &point)) { MITK_TEST_CONDITION_REQUIRED(fabs(refPoint[0] - point[0]) < 0.00001, "read x correct"); MITK_TEST_CONDITION_REQUIRED(fabs(refPoint[1] - point[1]) < 0.00001, "read y correct"); MITK_TEST_CONDITION_REQUIRED(fabs(refPoint[2] - point[2]) < 0.00001, "read z correct"); }else { MITK_TEST_FAILED_MSG(<< "File "<< filename << " can not be read - test will not applied." ); return; } + } -void WriterLocaleTest(mitk::Point3D & refPoint) +void WriterLocaleTest(mitk::Point3D & refPoint, std::string filename) { MITK_TEST_OUTPUT(<< "---- Writer Test---- "); //create pointset mitk::PointSet::Pointer refPointSet = mitk::PointSet::New(); - refPointSet->SetPoint(0, refPoint); + refPointSet->InsertPoint(0,refPoint); + //SetPoint(0, refPoint); - //create locator - mitk::StandardFileLocations::Pointer locator = mitk::StandardFileLocations::GetInstance(); - MITK_TEST_CONDITION_REQUIRED(locator.IsNotNull(),"Instantiating StandardFileLocations"); - std::string filename = locator->FindFile("pointSet.mps", "Core/Code/Testing/Data/"); std::string testFileName = "testPointSet.mps"; // write point set mitk::PointSetWriter::Pointer writer = mitk::PointSetWriter::New(); - writer -> SetFileName(testFileName); + writer -> SetFileName(testFileName.c_str()); writer -> SetInput(refPointSet); writer -> Write(); //compare two .mps files std::ifstream refStream (filename.c_str()); std::ifstream stream (testFileName.c_str()); MITK_TEST_CONDITION_REQUIRED(refStream,"Read reference point set"); MITK_TEST_CONDITION_REQUIRED(stream,"Read point set"); + std::string streamLine; std::string refStreamLine; bool differ = false; if (stream.is_open() && refStream.is_open()) { std::string streamLine; std::string refStreamLine; while(!stream.eof() && ! refStream.eof()) { getline(stream, streamLine); getline(refStream, refStreamLine); if(streamLine.compare(refStreamLine) != 0) { differ = true; break; } } stream.close(); refStream.close(); } MITK_TEST_CONDITION_REQUIRED(!differ, "Write point set correct"); + } -int mitkPointSetLocaleTest(int /*argc*/, char* /*argv*/[]) +int mitkPointSetLocaleTest(int argc, char* argv[]) { MITK_TEST_BEGIN("PointSetLocaleTest"); + if (argc<2) {MITK_TEST_FAILED_MSG(<<"Error: test file name is needed as second argument.");} + + + std::string filename = argv[1]; + + MITK_INFO << filename; + //create reference point set mitk::PointSet::Pointer refPointSet = mitk::PointSet::New(); mitk::Point3D refPoint; refPoint[0] = 32.2946; refPoint[1] = -17.7359; refPoint[2] = 29.6502; refPointSet->SetPoint(0, refPoint); //create locale list std::ofstream stream; std::locale previousLocale(stream.getloc()); typedef std::list StringList; StringList alllocales; alllocales.push_back("de_DE"); alllocales.push_back("de_DE.utf8"); alllocales.push_back("de_DE.UTF-8"); alllocales.push_back("de_DE@euro"); alllocales.push_back("German_Germany"); // QuickFix for MAC OS X // See for more the Bug #3894 comments #if defined (__APPLE__) || defined(MACOSX) alllocales.push_back("C"); #endif unsigned int numberOfTestedGermanLocales(0); for (StringList::iterator iter = alllocales.begin(); iter != alllocales.end(); ++iter) { if ( ChangeLocale(*iter) ) { - ++numberOfTestedGermanLocales; - WriterLocaleTest(refPoint); - ReaderLocaleTest(refPoint); + ++numberOfTestedGermanLocales; + WriterLocaleTest(refPoint,filename); + ReaderLocaleTest(refPoint,filename); } } if(numberOfTestedGermanLocales == 0) { MITK_TEST_OUTPUT(<< "Warning: No German locale was found on the system."); } //MITK_TEST_CONDITION_REQUIRED( numberOfTestedGermanLocales > 0, "Verify that at least one German locale has been tested."); MITK_TEST_END(); }