22 #ifndef otbTestHelper_h
23 #define otbTestHelper_h
28 #include "itkObject.h"
29 #include "itkObjectFactory.h"
33 #include "OTBTestKernelExport.h"
47 class OTBTestKernel_EXPORT
TestHelper :
public itk::Object
80 int RegressionTestAllBinary(
const StringList& baselineFilenamesBinary,
const StringList& testFilenamesBinary);
84 itkSetMacro(ReportErrors,
bool);
85 itkBooleanMacro(ReportErrors);
86 itkSetMacro(IgnoreLineOrder,
bool);
87 itkBooleanMacro(IgnoreLineOrder);
89 itkSetMacro(EpsilonBoundaryChecking,
double);
90 itkSetMacro(ToleranceRatio,
double);
93 std::map<std::string, int> RegressionTestBaselines(
char* baselineFilename)
const;
95 int RegressionTestImage(
int cpt,
const char* testImageFilename,
const char* baselineImageFilename,
const double toleranceDiffPixelImage)
const;
97 int RegressionTestOgrFile(
const char* testOgrFilename,
const char* baselineOgrFilename,
const double toleranceDiffValue)
const;
99 int RegressionTestBinaryFile(
const char* testBinaryFileName,
const char* baselineBinaryFileName)
const;
101 int RegressionTestAsciiFile(
const char* testAsciiFileName,
const char* baselineAsciiFileName,
const double epsilon,
102 std::vector<std::string> ignoredLines)
const;
104 int RegressionTestDiffFile(
const char* testAsciiFileName,
const char* baselineAsciiFileName,
const double epsilon,
105 std::vector<std::string> ignoredLines)
const;
107 int RegressionTestMetaData(
const char* testImageFilename,
const char* baselineImageFilename,
const double toleranceDiffPixelImage)
const;
109 bool isNumber(
int i)
const;
110 bool isHexaNumber(
int i)
const;
111 bool isPoint(
int i)
const;
112 bool isMinusSign(
int i)
const;
113 bool isAlphaNum(
int i)
const;
114 bool isNumeric(
const std::string& str)
const;
115 bool isScientificNumeric(
const std::string& str)
const;
116 bool isHexaPointerAddress(
const std::string& str)
const;
117 bool isHexaPointerAddress(
const std::string& str,
size_t pos,
size_t size)
const;
118 bool isToBeIgnoredForAnyComparison(
const std::string& str)
const;
120 int TokenizeLine(
const std::string& line,
StringList& tokens)
const;
122 static bool IsTokenEmpty(boost::iterator_range<std::string::const_iterator>& token);
125 bool IsLineValid(
const std::string& str,
const StringList& ignoredLines)
const;
127 bool CompareLines(
const std::string& strfileref,
const std::string& strfiletest,
int& nbdiff, std::ofstream& fluxfilediff,
int& numLine,
128 std::vector<std::string>& listStrDiffLineFileRef, std::vector<std::string>& listStrDiffLineFileTest,
double epsilon)
const;
130 void ogrReportOnLayer(OGRLayer* ref_poLayer,
const char* ref_pszWHERE, OGRGeometry* ref_poSpatialFilter, OGRLayer* test_poLayer,
const char* test_pszWHERE,
131 OGRGeometry* test_poSpatialFilter,
int& nbdiff,
double epsilon)
const;
133 static void DumpOGRFeature(FILE* fileid, OGRFeature* feature,
char** papszOptions =
nullptr);
134 static void DumpOGRGeometry(FILE* fileid, OGRGeometry* geometry,
const char* pszPrefix,
char** papszOptions =
nullptr);
142 void AddWhiteSpace(
const std::string& strIn, std::string& strOut)
const;
144 void CheckValueTolerance(
const char* Comment,
double ref,
double test,
int& count,
bool report,
double epsilon)
const;