Chaste Release::3.1
|
#include <FileComparison.hpp>
Public Member Functions | |
FileComparison (std::string fileName1, std::string fileName2, bool calledCollectively=true, bool suppressOutput=false) | |
FileComparison (const FileFinder &rFileName1, const FileFinder &rFileName2, bool calledCollectively=true, bool suppressOutput=false) | |
void | SetupCommentLines () |
void | SetIgnoreCommentLines (bool ignore=true) |
void | SetIgnoreLinesBeginningWith (std::string lineStart) |
bool | CompareFiles (unsigned ignoreFirstFewLines=0, bool doTsAssert=true) |
Private Attributes | |
bool | mIgnoreCommentLines |
std::vector< std::string > | mCommentLineStarts |
Compare files to check for any differences (in numeric and/or string values).
By Default this class ignores all lines which (in both files) start with '#'.
Definition at line 45 of file FileComparison.hpp.
FileComparison::FileComparison | ( | std::string | fileName1, |
std::string | fileName2, | ||
bool | calledCollectively = true , |
||
bool | suppressOutput = false |
||
) | [inline] |
Specify two files to compare, and open them for reading. Actual comparison is done by calling CompareFiles.
fileName1 | first file |
fileName2 | second file |
calledCollectively | If true there will be a barrier before opening files, and only master compares contents. |
suppressOutput | If true then no errors will go to TS_TRACE(). Should only be set for the test of this class. |
Definition at line 68 of file FileComparison.hpp.
References SetupCommentLines().
FileComparison::FileComparison | ( | const FileFinder & | rFileName1, |
const FileFinder & | rFileName2, | ||
bool | calledCollectively = true , |
||
bool | suppressOutput = false |
||
) | [inline] |
Specify two files to compare, and open them for reading. Actual comparison is done by calling CompareFiles.
rFileName1 | first file finder |
rFileName2 | second file finder |
calledCollectively | If true there will be a barrier before opening files, and only master compares contents. |
suppressOutput | If true then no errors will go to TS_TRACE(). Should only be set for the test of this class. |
Definition at line 84 of file FileComparison.hpp.
References SetupCommentLines().
bool FileComparison::CompareFiles | ( | unsigned | ignoreFirstFewLines = 0 , |
bool | doTsAssert = true |
||
) | [inline] |
Compare the files under both relative and absolute tolerances. The comparison only fails if neither tolerance holds. The default settings effectively require numbers to match exactly.
ignoreFirstFewLines | how many lines to ignore from the comparison |
doTsAssert | Whether to throw a TS_ASSERT internally (switched off for testing only) |
Definition at line 132 of file FileComparison.hpp.
References PetscTools::AmMaster(), AbstractFileComparison::mCalledCollectively, mCommentLineStarts, AbstractFileComparison::mFilename1, AbstractFileComparison::mFilename2, mIgnoreCommentLines, AbstractFileComparison::mLineNum, AbstractFileComparison::mpFile1, AbstractFileComparison::mpFile2, AbstractFileComparison::mSuppressOutput, AbstractFileComparison::ResetFiles(), and AbstractFileComparison::SkipHeaderLines().
void FileComparison::SetIgnoreCommentLines | ( | bool | ignore = true | ) | [inline] |
Whether or not we should ignore lines starting with '#'
ignore | whether to ignore these lines (defaults to true) |
Definition at line 107 of file FileComparison.hpp.
References mIgnoreCommentLines.
void FileComparison::SetIgnoreLinesBeginningWith | ( | std::string | lineStart | ) | [inline] |
Set a line start which should be treated as a comment and ignored (and therefore switch on mIgnoreCommentLines = true)
lineStart | The beginning of a line which should be treated as a comment |
Definition at line 118 of file FileComparison.hpp.
References mCommentLineStarts, and mIgnoreCommentLines.
void FileComparison::SetupCommentLines | ( | ) | [inline] |
Set some line starts that define comments in the files.
These are ignored by default and when mIgnoreCommentLines = true.
Definition at line 96 of file FileComparison.hpp.
References mCommentLineStarts.
Referenced by FileComparison().
std::vector<std::string> FileComparison::mCommentLineStarts [private] |
A list of strings, if found at the beginning of lines when mIgnoreCommentLines is true, differences in these lines are ignored.
Definition at line 56 of file FileComparison.hpp.
Referenced by CompareFiles(), SetIgnoreLinesBeginningWith(), and SetupCommentLines().
bool FileComparison::mIgnoreCommentLines [private] |
Whether or not we should ignore lines starting with '#'. True by default.
Definition at line 49 of file FileComparison.hpp.
Referenced by CompareFiles(), SetIgnoreCommentLines(), and SetIgnoreLinesBeginningWith().