Skip to content
Snippets Groups Projects
Commit e38b319d authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

Merge branch 'diff_compare' into develop

parents 0e22ac32 304fcfbe
No related branches found
No related tags found
No related merge requests found
......@@ -36,7 +36,7 @@ otb_add_test(NAME prTeOrthoRectificationExampleXSTest COMMAND ${OTB_TEST_DRIVER}
)
otb_add_test(NAME prTeMapProjectionExampleTest COMMAND ${OTB_TEST_DRIVER}
--compare-ascii ${NOTOL}
--compare-ascii ${EPSILON_7}
${BASELINE}/mapProjectionExample.txt
${TEMP}/mapProjectionExample.txt
Execute $<TARGET_FILE:MapProjectionExample>
......
......@@ -90,7 +90,7 @@ set(knn_parameters "")
set(sharkrf_parameters "")
# Validation depending on mode
set(ascii_comparison --compare-ascii ${NOTOL})
set(ascii_comparison --compare-ascii ${EPSILON_6})
set(raster_comparison --compare-image ${NOTOL})
set(raster_comparison_two --compare-n-images ${NOTOL} 2)
......@@ -650,7 +650,7 @@ otb_test_application(NAME apTvClTrainSVMImagesClassifierQB1_allOpt_InXML
-classifier.libsvm.opt true
-rand 121212
-io.out ${TEMP}/clsvmModelQB1_allOpt_InXML.svm
VALID --compare-ascii ${NOTOL}
VALID ${ascii_comparison}
${OTBAPP_BASELINE_FILES}/clsvmModelQB1.svm
${TEMP}/clsvmModelQB1_allOpt_InXML.svm)
......@@ -664,7 +664,7 @@ otb_test_application(NAME apTvClTrainSVMImagesClassifierQB1_OutXML
-io.out ${TEMP}/clsvmModelQB1_OutXML.svm
-rand 121212
-outxml ${TEMP}/clsvmModelQB1_OutXML.xml
VALID --compare-ascii ${NOTOL}
VALID ${ascii_comparison}
${OTBAPP_BASELINE_FILES}/clsvmModelQB1.svm
${TEMP}/clsvmModelQB1_OutXML.svm)
......@@ -695,7 +695,7 @@ otb_test_application(NAME apTvClTrainSVMImagesClassifierQB1
-classifier.libsvm.opt true
-io.out ${TEMP}/clsvmModelQB1.svm
-rand 121212
VALID --compare-ascii ${NOTOL}
VALID ${ascii_comparison}
${OTBAPP_BASELINE_FILES}/clsvmModelQB1.svm
${TEMP}/clsvmModelQB1.svm)
......@@ -730,7 +730,7 @@ otb_test_application(NAME apTvClTrainSVMImagesClassifierQB1_allOpt
-classifier.libsvm.opt true
-rand 121212
-io.out ${TEMP}/clsvmModelQB1_allOpt.svm
VALID --compare-ascii ${NOTOL}
VALID ${ascii_comparison}
${OTBAPP_BASELINE_FILES}/clsvmModelQB1.svm
${TEMP}/clsvmModelQB1_allOpt.svm)
endif()
......@@ -852,7 +852,7 @@ otb_test_application(NAME apTvClTrainRegressionTest_monovar
-classifier.rf.ra 0.0001
-classifier.rf.max 6
-classifier.rf.acc 0.0005
VALID --compare-ascii ${NOTOL}
VALID ${ascii_comparison}
${OTBAPP_BASELINE_FILES}/apTvClTrainRegressionTest_monovar.rf
${TEMP}/apTvClTrainRegressionTest_monovar.rf)
......@@ -917,7 +917,7 @@ if(OTB_USE_OPENCV)
-classifier rf
-io.confmatout ${TEMP}/apTvClTrainVectorClassifierConfMat.txt
-io.out ${TEMP}/apTvClTrainVectorClassifierModel.rf
VALID --compare-ascii ${NOTOL}
VALID ${ascii_comparison}
${OTBAPP_BASELINE_FILES}/apTvClTrainVectorClassifierModel.rf
${TEMP}/apTvClTrainVectorClassifierModel.rf)
endif()
......
......@@ -26,6 +26,7 @@
#include <vector>
#include "itkObject.h"
#include "itkObjectFactory.h"
#include "otbStringUtils.h"
#include "otbMetaDataKey.h"
......@@ -64,7 +65,10 @@ public:
m_ReportErrors(false),
m_IgnoreLineOrder(false),
m_MaxArea(1024*1024)
{}
{
m_SpecialTokens.push_back(std::pair<std::string,std::string>(
std::string("Integer"),std::string("Integer64")));
}
~TestHelper() ITK_OVERRIDE{}
......@@ -78,6 +82,10 @@ public:
const StringList& testFilenamesAscii,
const StringList& ignoredLines);
int RegressionTestAllDiff(const StringList& baselineFilenamesAscii,
const StringList& testFilenamesAscii,
const StringList& ignoredLines);
int RegressionTestAllBinary(const StringList& baselineFilenamesBinary,
const StringList& testFilenamesBinary);
......@@ -113,6 +121,11 @@ private:
const double epsilon,
std::vector<std::string> ignoredLines) const;
int RegressionTestDiffFile(const char * testAsciiFileName,
const char * baselineAsciiFileName,
const double epsilon,
std::vector<std::string> ignoredLines) const;
int RegressionTestMetaData(const char *testImageFilename,
const char *baselineImageFilename,
const double toleranceDiffPixelImage) const;
......@@ -121,11 +134,19 @@ private:
bool isHexaNumber(int i) const;
bool isPoint(int i) const;
bool isMinusSign(int i) const;
bool isAlphaNum(int i) const;
bool isNumeric(const std::string& str) const;
bool isScientificNumeric(const std::string& str) const;
bool isHexaPointerAddress(const std::string& str) const;
bool isHexaPointerAddress(const std::string& str, size_t pos, size_t size) const;
bool isToBeIgnoredForAnyComparison(const std::string& str) const;
std::string VectorToString(const otb::MetaDataKey::VectorType& vector) const;
int TokenizeLine(const std::string &line, StringList &tokens) const;
static bool IsTokenEmpty(boost::iterator_range<std::string::const_iterator> &token);
// TODO : maybe merge this function with isToBeIgnoredForAnyComparison
bool IsLineValid(const std::string& str, const StringList &ignoredLines) const;
//FIXME parameters have to be cleaned up later (this is the first step of refactoring)
bool CompareLines(const std::string& strfileref,
const std::string& strfiletest,
......@@ -152,6 +173,8 @@ private:
const unsigned int m_MaxArea;
void AddWhiteSpace(const std::string& strIn, std::string &strOut) const;
std::vector<std::pair<std::string, std::string> > m_SpecialTokens;
};
}
......
......@@ -380,7 +380,8 @@ int main(int ac, char* av[])
// Non regression test for ascii files
if ((baselineFilenamesAscii.size() > 0) && (testFilenamesAscii.size() > 0))
{
result += testHelper->RegressionTestAllAscii(baselineFilenamesAscii, testFilenamesAscii, ignoredLines);
//result += testHelper->RegressionTestAllAscii(baselineFilenamesAscii, testFilenamesAscii, ignoredLines);
result += testHelper->RegressionTestAllDiff(baselineFilenamesAscii, testFilenamesAscii, ignoredLines);
}
/******************************************************************************/
// Non regression test for binary files
......
This diff is collapsed.
......@@ -4,6 +4,7 @@ set(OTBTestKernelTests
otbCompareAsciiTests3.cxx
otbCompareAsciiTests4.cxx
otbCompareAsciiTests5.cxx
otbCompareAsciiTests6.cxx
otbCompareAsciiTestScientificNotation.cxx
otbCompareAsciiTests.cxx
otbCompareAsciiTestsEpsilon3_WhiteSpace.cxx
......@@ -114,3 +115,11 @@ otb_add_test(NAME tsTvCompareAsciiepsilon3_WhiteSpaceKO COMMAND otbTestKernelTes
${TEMP}/tsTvCompareAsciiEpsilon3_TestKO.txt
)
set_property(TEST tsTvCompareAsciiepsilon3_WhiteSpaceKO PROPERTY WILL_FAIL true)
otb_add_test(NAME tsTvCompareAscii6 COMMAND otbTestKernelTestDriver
--compare-ascii ${EPSILON_3}
${TEMP}/tsTvCompareAscii6_ref.txt
${TEMP}/tsTvCompareAscii6_test.txt
otbCompareAsciiTests6
${TEMP}/tsTvCompareAscii6_ref.txt
${TEMP}/tsTvCompareAscii6_test.txt
)
/*=========================================================================
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 "otbMacro.h"
int otbCompareAsciiTests6(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 << "ImageRegion (0x7fff1639a860)\n";
fileRef << "0x7fff1639a860\n";
fileRef << "0.142355\t:230\n";
fileRef.close();
std::ofstream fileTest;
fileTest.open(argv[2]);
fileTest << "ImageRegion (00C3F798)\n";
fileTest << "000000001AF56D20\n";
fileTest << "0.142356\t:230\n";
fileTest.close();
return EXIT_SUCCESS;
}
......@@ -5,6 +5,7 @@ void RegisterTests()
REGISTER_TEST(otbCompareAsciiTests3);
REGISTER_TEST(otbCompareAsciiTests4);
REGISTER_TEST(otbCompareAsciiTests5);
REGISTER_TEST(otbCompareAsciiTests6);
REGISTER_TEST(otbCompareAsciiTestScientificNotation);
REGISTER_TEST(otbCompareAsciiTests);
REGISTER_TEST(otbCompareAsciiTestsEpsilon3_WhiteSpace);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment