Commit bb283629 authored by Emmanuel Christophe's avatar Emmanuel Christophe

ENH: improve code quality

parent 82b5a7a7
......@@ -1340,7 +1340,7 @@ bool TestHelper::isMinusSign(int i) const
return (i == 45);
}
bool TestHelper::isNumeric(std::string str) const
bool TestHelper::isNumeric(const std::string& str) const
{
int nbOfPoints = 0;
int nbOfNumbers = 0;
......@@ -1364,7 +1364,7 @@ bool TestHelper::isNumeric(std::string str) const
return result;
}
bool TestHelper::isScientificNumeric(std::string str) const
bool TestHelper::isScientificNumeric(const std::string& str) const
{
if(str.size() == 0)
{
......@@ -1416,7 +1416,7 @@ bool TestHelper::isScientificNumeric(std::string str) const
return true;
}
bool TestHelper::isToBeIgnoredForAnyComparison(std::string str) const
bool TestHelper::isToBeIgnoredForAnyComparison(const std::string& str) const
{
if (str.find("RTTI") != std::string::npos) return true;
if (str.find("Modified Time") != std::string::npos) return true;
......@@ -1424,7 +1424,7 @@ bool TestHelper::isToBeIgnoredForAnyComparison(std::string str) const
return false;
}
bool TestHelper::isHexaPointerAddress(std::string str) const
bool TestHelper::isHexaPointerAddress(const std::string& str) const
{
unsigned int size(0);
bool result(false);
......@@ -1465,7 +1465,7 @@ bool TestHelper::isHexaPointerAddress(std::string str) const
return result;
}
void TestHelper::AddWhiteSpace(std::string strIn, std::string &strOut) const
void TestHelper::AddWhiteSpace(const std::string& strIn, std::string &strOut) const
{
std::string strLine = strIn;
......@@ -1503,8 +1503,8 @@ void TestHelper::AddWhiteSpace(std::string strIn, std::string &strOut) const
strOut = strLine;
}
bool TestHelper::CompareLines(std::string strfileref,
std::string strfiletest,
bool TestHelper::CompareLines(const std::string& strfileref,
const std::string& strfiletest,
int& nbdiff,
std::ofstream& fluxfilediff,
int& numLine,
......@@ -1722,11 +1722,11 @@ bool TestHelper::CompareLines(std::string strfileref,
return differenceFoundInCurrentLine;
}
std::string TestHelper::VectorToString(otb::MetaDataKey::VectorType vector) const
std::string TestHelper::VectorToString(const otb::MetaDataKey::VectorType& vector) const
{
otb::StringStream oss;
oss.str("");
otb::MetaDataKey::VectorType::iterator it = vector.begin();
otb::MetaDataKey::VectorType::const_iterator it = vector.begin();
oss << "[";
while (it != vector.end())
{
......
......@@ -25,6 +25,7 @@
#include <string>
#include <vector>
#include "itkObject.h"
#include "otbMetaDataKey.h"
class OGRFeature;
......@@ -54,7 +55,7 @@ public:
~TestHelper(){}
int RegressionTestAllImages(const StringList& baselineFilenamesImage,
int RegressionTestAllImages(const StringList& baselineFilenamesImage,
const StringList& testFilenamesImage);
int RegressionTestAllMetaData(const StringList& baselineFilenamesMetaData,
......@@ -70,22 +71,6 @@ public:
int RegressionTestAllOgr(const StringList& baselineFilenamesOgr,
const StringList& testFilenamesOgr);
std::map<std::string, int> RegressionTestBaselines(char *baselineFilename) const;
int RegressionTestImage(int cpt, const char *testImageFilename, const char *baselineImageFilename,
const double toleranceDiffPixelImage) const;
int RegressionTestOgrFile(const char *testOgrFilename, const char *baselineOgrFilename,
const double toleranceDiffValue) const;
int RegressionTestBinaryFile(const char * testBinaryFileName, const char * baselineBinaryFileName) const;
int RegressionTestAsciiFile(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;
itkSetMacro(ReportErrors, bool);
itkBooleanMacro(ReportErrors);
itkSetMacro(IgnoreLineOrder, bool);
......@@ -96,18 +81,41 @@ public:
itkSetMacro(EpsilonBoundaryChecking, double);
private:
std::map<std::string, int> RegressionTestBaselines(char *baselineFilename) const;
int RegressionTestImage(int cpt, const char *testImageFilename,
const char *baselineImageFilename,
const double toleranceDiffPixelImage) const;
int RegressionTestOgrFile(const char *testOgrFilename,
const char *baselineOgrFilename,
const double toleranceDiffValue) const;
int RegressionTestBinaryFile(const char * testBinaryFileName,
const char * baselineBinaryFileName) const;
int RegressionTestAsciiFile(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;
bool isNumber(int i) const;
bool isHexaNumber(int i) const;
bool isPoint(int i) const;
bool isMinusSign(int i) const;
bool isNumeric(std::string str) const;
bool isScientificNumeric(std::string str) const;
bool isHexaPointerAddress(std::string str) const;
bool isToBeIgnoredForAnyComparison(std::string str) const;
std::string VectorToString(otb::MetaDataKey::VectorType vector) const;
bool isNumeric(const std::string& str) const;
bool isScientificNumeric(const std::string& str) const;
bool isHexaPointerAddress(const std::string& str) const;
bool isToBeIgnoredForAnyComparison(const std::string& str) const;
std::string VectorToString(const otb::MetaDataKey::VectorType& vector) const;
//FIXME parameters have to be cleaned up later (this is the first step of refactoring)
bool CompareLines(std::string strfileref,
std::string strfiletest,
bool CompareLines(const std::string& strfileref,
const std::string& strfiletest,
int& nbdiff,
std::ofstream& fluxfilediff,
int& numLine,
......@@ -129,7 +137,7 @@ private:
bool m_ReportErrors;
bool m_IgnoreLineOrder;
void AddWhiteSpace(std::string strIn, std::string &strOut) const;
void AddWhiteSpace(const std::string& strIn, std::string &strOut) const;
};
}
......
......@@ -18,16 +18,15 @@
#ifndef __otbTestMain_h
#define __otbTestMain_h
#include "itkWin32Header.h"
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include "itkWin32Header.h"
#include "itkMultiThreader.h"
#include "itkMacro.h"
#include "otbTestHelper.h"
#include "otbMacro.h"
typedef int (*MainFuncPointer)(int, char*[]);
std::map<std::string, MainFuncPointer> StringToTestFunctionMap;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment