diff --git a/Testing/Code/CMakeLists.txt b/Testing/Code/CMakeLists.txt index 77888fe525f67f0928d8ea292962582125f3c0ab..c7a9d618acba1bb8615976e59b0b5377f9cb09ef 100644 --- a/Testing/Code/CMakeLists.txt +++ b/Testing/Code/CMakeLists.txt @@ -15,6 +15,7 @@ Radiometry Fusion Markov SARPolarimetry +TestSystem ) IF(OTB_USE_VISU_GUI) diff --git a/Testing/Code/TestSystem/CMakeLists.txt b/Testing/Code/TestSystem/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..a3f4cbdb018df95b0d068f509afc10ba6cff534a --- /dev/null +++ b/Testing/Code/TestSystem/CMakeLists.txt @@ -0,0 +1,43 @@ + +IF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) + +SET(BASELINE ${OTB_DATA_ROOT}/Baseline/OTB/Images) +SET(BASELINE_FILES ${OTB_DATA_ROOT}/Baseline/OTB/Files) +SET(INPUTDATA ${OTB_DATA_ROOT}/Input) +SET(EXAMPLESDATA ${OTB_DATA_ROOT}/Examples) +IF(OTB_DATA_USE_LARGEINPUT) + SET(LARGEINPUTDATA ${OTB_DATA_LARGEINPUT_ROOT} ) +ENDIF(OTB_DATA_USE_LARGEINPUT) +SET(TEMP ${OTBTesting_BINARY_DIR}/Temporary) + + +#Tolerance sur diff pixel image +SET(NOTOL 0.0) + +#Tolerance sur la difference des valeurs numeriques dans le --compare-ascii +SET(EPS 0.001) + +SET(TESTSYSTEM_TESTS ${CXX_TEST_PATH}/otbTestSystemTests) + +ADD_TEST(tsTvCompareAscii ${TESTSYSTEM_TESTS} + --compare-ascii ${NOTOL} + ${TEMP}/tsTvCompareAsciiRef.txt + ${TEMP}/tsTvCompareAsciiTest.txt + otbCompareAsciiTests + ${TEMP}/tsTvCompareAsciiRef.txt + ${TEMP}/tsTvCompareAsciiTest.txt + ) + + + +# ------- CXX source files ----------------------------------- +SET(TESTSYSTEM_SRCS +otbTestSystemTests.cxx +otbCompareAsciiTests.cxx +) + +INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) + +OTB_ADD_EXECUTABLE(otbTestSystemTests "${TESTSYSTEM_SRCS}" "OTBTesting;OTBCommon;OTBIO") + +ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) diff --git a/Testing/Code/TestSystem/otbCompareAsciiTests.cxx b/Testing/Code/TestSystem/otbCompareAsciiTests.cxx new file mode 100644 index 0000000000000000000000000000000000000000..32303525a79e3fcaccc69b166d94efae1374aecf --- /dev/null +++ b/Testing/Code/TestSystem/otbCompareAsciiTests.cxx @@ -0,0 +1,49 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#include <iostream> +#include <fstream> + +#include "itkExceptionObject.h" +#include "otbMacro.h" + +int otbCompareAsciiTests(int argc, char * argv[]) +{ + if ( argc != 3 ) + { + std::cerr << "Usage: " << argv[0]; + std::cerr << " referenceFile testFile" << std::endl; + return EXIT_FAILURE; + } + + std::ofstream fileRef; + fileRef.open(argv[1]); + fileRef << "1\n"; + fileRef << "2\n"; + fileRef << "3\n"; + fileRef.close(); + + + std::ofstream fileTest; + fileTest.open(argv[2]); + fileTest << "1\n"; + fileTest << "2\n"; + fileTest << "3\n"; + fileTest.close(); + + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/Testing/Code/TestSystem/otbTestSystemTests.cxx b/Testing/Code/TestSystem/otbTestSystemTests.cxx new file mode 100644 index 0000000000000000000000000000000000000000..74450b6ce56b32e93607b1ecb375d97cee789252 --- /dev/null +++ b/Testing/Code/TestSystem/otbTestSystemTests.cxx @@ -0,0 +1,30 @@ +/*========================================================================= + + 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. + +=========================================================================*/ + +// this file defines the otbGISFiltersTest for the test driver +// and all it expects is that you have a function called RegisterTests +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "otbTestMain.h" + +void RegisterTests() +{ + REGISTER_TEST(otbCompareAsciiTests); +} diff --git a/Testing/Code/otbTestHelper.cxx b/Testing/Code/otbTestHelper.cxx index f212e98396dcd4fbf122d079f663352e3c9b5306..aa824b6901ef15a70282e4676cdf9d1f5afb218b 100644 --- a/Testing/Code/otbTestHelper.cxx +++ b/Testing/Code/otbTestHelper.cxx @@ -155,9 +155,10 @@ int TestHelper::RegressionTestAsciiFile(const char * testAsciiFileName, const ch //Compare the lines only if none is supposed to be ignored //Note: the iterator increment will take care of moving only the //ignored one if the order does not matter + bool differenceFoundInCurrentLine = false; if ((!ignoreCurrentLineRef) && (!ignoreCurrentLineTest)) { - CompareLines(strfileref,strfiletest, nbdiff, fluxfilediff, numLine, + differenceFoundInCurrentLine = CompareLines(strfileref,strfiletest, nbdiff, fluxfilediff, numLine, listStrDiffLineFileRef, listStrDiffLineFileTest, epsilon); } @@ -165,9 +166,19 @@ int TestHelper::RegressionTestAsciiFile(const char * testAsciiFileName, const ch { if (ignoreCurrentLineRef) ++itRef; if (ignoreCurrentLineTest) ++itTest; - - //TODO: if the lines were different, find out which one - // should progress (by comparison) + if ((!ignoreCurrentLineRef) && (!ignoreCurrentLineTest)) + { + if (differenceFoundInCurrentLine) + { + //TODO: if the lines were different, find out which one + // should progress (by comparison) + } + else + { + ++itRef; + ++itTest; + } + } } else { @@ -1592,6 +1603,8 @@ bool TestHelper::CompareLines(std::string strfileref, std::string strfiletest, i listStrDiffLineFileRef.push_back(strfileref); listStrDiffLineFileTest.push_back(strfiletest); } + + return differenceFoundInCurrentLine; } std::string TestHelper::VectorToString(otb::MetaDataKey::VectorType vector) const