diff --git a/Testing/Code/Common/CMakeLists.txt b/Testing/Code/Common/CMakeLists.txt index 78ffdffec72eb7b7061616f11b138a25e5d4ba56..3f66f690f06c124b0efa30da6e4540e46f7cc0e8 100644 --- a/Testing/Code/Common/CMakeLists.txt +++ b/Testing/Code/Common/CMakeLists.txt @@ -14,6 +14,14 @@ SET(TOL 0.0) SET(COMMON_TESTS ${CXX_TEST_PATH}/otbCommonTests) +# ------- otb::System ------------- +ADD_TEST(coTuSystemTests_IsA_Methods ${COMMON_TESTS} + otbSystemTest + ${OTB_DATA_ROOT}/OTBData.readme + ${OTB_DATA_ROOT} + ) + + # ------- otb::CommandLibneArgumentParser ------------- ADD_TEST(coTuCmdLineArgParserHelpWithArg ${COMMON_TESTS} @@ -208,6 +216,7 @@ ADD_TEST(coTuImageToLineSpatialObjectListNew ${COMMON_TESTS} # ------- Fichiers sources CXX ----------------------------------- SET(BasicCommon_SRCS +otbSystemTest.cxx otbTestCommandLineArgumentParser.cxx otbTestCommandLineArgumentParserHelp.cxx otbTestCommandLineArgumentParserList.cxx diff --git a/Testing/Code/Common/otbCommonTests.cxx b/Testing/Code/Common/otbCommonTests.cxx index b51432533e776d908cb76f75d7c4f44969aa30bf..e24dab82f6a99f7423aae2a4bf17cafcf468bc6c 100644 --- a/Testing/Code/Common/otbCommonTests.cxx +++ b/Testing/Code/Common/otbCommonTests.cxx @@ -26,6 +26,7 @@ void RegisterTests() { +REGISTER_TEST(otbSystemTest); REGISTER_TEST(otbTestCommandLineArgumentParser); REGISTER_TEST(otbTestCommandLineArgumentParserHelp); REGISTER_TEST(otbTestCommandLineArgumentParserList); diff --git a/Testing/Code/Common/otbSystemTest.cxx b/Testing/Code/Common/otbSystemTest.cxx new file mode 100755 index 0000000000000000000000000000000000000000..1579f2dd077f4b4cb0531fd9fc6487dad65a5509 --- /dev/null +++ b/Testing/Code/Common/otbSystemTest.cxx @@ -0,0 +1,71 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt 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. + +=========================================================================*/ + +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "itkExceptionObject.h" +#include <iostream> + +#include "itkMacro.h" +#include "otbSystem.h" + + +int otbSystemTest( int argc, char* argv[] ) +{ + try + { + const char * inputFileName = argv[1]; + const char * inputDirName = argv[2]; + itk::OStringStream msg; + + if( otb::System::IsAFileName( inputFileName ) == false ) + { + itkGenericExceptionMacro( <<"System::IsAFileName() error : the filename "<<inputFileName<<" is not detected."); + } + if( otb::System::IsADirName( inputFileName ) == true ) + { + itkGenericExceptionMacro( <<"System::IsADirName() error : the filename "<<inputFileName<<" is detected."); + } + if( otb::System::IsAFileName( inputDirName ) == true ) + { + itkGenericExceptionMacro(<< "System::IsAFileName() error : the dirname "<<inputDirName<<" is detected!!"); + } + if( otb::System::IsADirName( inputDirName ) == false ) + { + itkGenericExceptionMacro(<< "System::IsADirName() error : the dirname "<<inputDirName<<" is not detected!!"); + } + + } + catch( itk::ExceptionObject & err ) + { + std::cout << "Exception itk::ExceptionObject levee !" << std::endl; + std::cout << err << std::endl; + return EXIT_FAILURE; + } + catch( ... ) + { + std::cout << "Exception levee inconnue !" << std::endl; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} + +