xmscore
1.0
|
Functions for running unit or intermediate tests. More...
#include <xmscore/testing/TestTools.h>
#include <fstream>
#include <sstream>
#include <boost/filesystem.hpp>
#include <boost/predef.h>
#include <cxxtest/GlobalFixture.h>
#include <cxxtest/TestSuite.h>
#include <xmscore/misc/XmLog.h>
#include <xmscore/misc/environment.h>
#include <xmscore/points/pt.h>
Go to the source code of this file.
Functions | |
void | xms::ttByPassMessages (int a_defaultChoice) |
Bypass the ui elements and just set return value. More... | |
bool | xms::ttSkippingMessages () |
Has ttByPassMessages been called without calling ttClearSkippingMessages. More... | |
int | xms::ttByPassDefault () |
Get the default choice when skipping messages. More... | |
void | xms::ttClearSkippingMessages () |
Turn off skipping ui elements. | |
ETestMessagingState & | xms::ttTestMessagingState () |
Get the batch mode singleton. More... | |
void | xms::ttCheckXmLogForEachTest (bool a_setting) |
Set check of XM_LOG before and after each test. More... | |
bool | xms::ttCheckXmLogForEachTest () |
Turn on check of XM_LOG before and after each test. More... | |
void | xms::ttAssertStackedErrors (const char *a_file, int a_line, const std::string &a_expected) |
CXX Test assert that the stackable XM_LOG has the expected errors. More... | |
void | xms::ttGetTestFilePaths (const std::string &a_path, const std::string &a_fileBase, const std::string &a_extension, std::string &a_baseFilePath, std::string &a_outFilePath) |
Get testing base and output file using the compiled for architecture. Checks for appended "MacOsX" for Mac OS X and "64" for 64-bit builds. For example with Mac OS 64-bit build looks for test_baseMacOsX.vtu then if not found test_base64.vtu, then if neither found then uses test_base.vtu. More... | |
bool | xms::ttTextFilesEqual (const std::string &a_file1, const std::string &a_file2, std::string &a_message) |
Returns true if the two files are equal. More... | |
void | xms::ttTextFilesEqual (const std::string &a_srcFile, unsigned a_line, const std::string &a_file1, const std::string &a_file2) |
Returns true if the two files are equal. More... | |
void | xms::ttStreamsEqual (const std::string &a_src, unsigned int a_line, std::istream &a_strm1, std::istream &a_strm2) |
Returns true if the two streams are equal. More... | |
bool | xms::ttEqualPointsXYZ (const Pt3d &a_pt1, const Pt3d &a_pt2, double a_tolerance) |
Returns true if the points are equal to within tolerance. More... | |
bool | xms::ttEqualPointsXYZ (double a_x1, double a_y1, double a_z1, double a_x2, double a_y2, double a_z2, double a_tolerance) |
Returns true if the points are equal to within tolerance. More... | |
bool | xms::ttEqualPointsXY (double a_x1, double a_y1, double a_x2, double a_y2, double a_tolerance) |
Returns true if the points are equal to within tolerance. More... | |
bool | xms::ttEqualPointsXY (const Pt2d &a_pt1, const Pt2d &a_pt2, double a_tolerance) |
bool | xms::ttEqualPointsXY (const Pt3d &a_pt1, const Pt3d &a_pt2, double a_tolerance) |
Functions for running unit or intermediate tests.
Definition in file TestTools.cpp.
void xms::ttAssertStackedErrors | ( | const char * | a_file, |
int | a_line, | ||
const std::string & | a_expected | ||
) |
CXX Test assert that the stackable XM_LOG has the expected errors.
a_file | File. |
a_line | Line. |
a_expected | string |
Definition at line 257 of file TestTools.cpp.
References xms::XmLog::GetAndClearStackStr(), xms::Singleton< XmLog >::Instance(), xms::ttAssertStackedErrors(), and xms::ttCheckXmLogForEachTest().
Referenced by xms::ttAssertStackedErrors(), and xms::ttEqualWithinTolerance().
int xms::ttByPassDefault | ( | ) |
Get the default choice when skipping messages.
Definition at line 214 of file TestTools.cpp.
References xms::ETestMessagingState::GetDefault(), xms::ttByPassDefault(), and xms::ttTestMessagingState().
Referenced by xms::ttByPassDefault().
void xms::ttByPassMessages | ( | int | a_defaultChoice | ) |
Bypass the ui elements and just set return value.
a_defaultChoice | The option to use automatically when the user would otherwise be prompted for input. |
Definition at line 196 of file TestTools.cpp.
References xms::ETestMessagingState::SetDefault(), xms::ETestMessagingState::SetSkipping(), xms::ttByPassMessages(), and xms::ttTestMessagingState().
Referenced by xms::ttByPassMessages().
void xms::ttCheckXmLogForEachTest | ( | bool | a_setting | ) |
Set check of XM_LOG before and after each test.
a_setting | true to check. |
Definition at line 239 of file TestTools.cpp.
References xms::ttCheckXmLogForEachTest().
Referenced by xms::ttAssertStackedErrors(), and xms::ttCheckXmLogForEachTest().
bool xms::ttCheckXmLogForEachTest | ( | ) |
Turn on check of XM_LOG before and after each test.
Definition at line 247 of file TestTools.cpp.
References xms::ttCheckXmLogForEachTest().
bool xms::ttEqualPointsXY | ( | double | a_x1, |
double | a_y1, | ||
double | a_x2, | ||
double | a_y2, | ||
double | a_tolerance | ||
) |
Returns true if the points are equal to within tolerance.
a_x1 | x of point 1. |
a_y1 | y of point 1. |
a_x2 | x of point 2. |
a_y2 | y of point 2. |
a_tolerance | a_tolerance. |
Definition at line 478 of file TestTools.cpp.
References xms::ttEqualPointsXY().
Referenced by xms::ttEqualPointsXY(), and xms::ttEqualWithinTolerance().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
a_pt1 | Point 1. |
a_pt2 | Point 2. |
a_tolerance | tolerance. |
Definition at line 496 of file TestTools.cpp.
References xms::ttEqualPointsXY(), xms::Pt2< T >::x, and xms::Pt2< T >::y.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
a_pt1 | Point 1. |
a_pt2 | Point 2. |
a_tolerance | tolerance. |
Definition at line 507 of file TestTools.cpp.
References xms::ttEqualPointsXY(), xms::Pt3< T >::x, and xms::Pt3< T >::y.
Referenced by xms::ttAssertDeltaPt2d(), and xms::ttAssertDeltaVecPt2d().
Returns true if the points are equal to within tolerance.
a_pt1 | Point 1. |
a_pt2 | Point 2. |
a_tolerance | tolerance. |
Definition at line 441 of file TestTools.cpp.
References xms::ttEqualPointsXYZ(), xms::Pt3< T >::x, xms::Pt3< T >::y, and xms::Pt3< T >::z.
Referenced by xms::ttEqualPointsXYZ(), and xms::ttEqualWithinTolerance().
bool xms::ttEqualPointsXYZ | ( | double | a_x1, |
double | a_y1, | ||
double | a_z1, | ||
double | a_x2, | ||
double | a_y2, | ||
double | a_z2, | ||
double | a_tolerance | ||
) |
Returns true if the points are equal to within tolerance.
a_x1 | x of point 1. |
a_y1 | y of point 1. |
a_z1 | z of point 1. |
a_x2 | x of point 2. |
a_y2 | y of point 2. |
a_z2 | z of point 2. |
a_tolerance | tolerance. |
Definition at line 456 of file TestTools.cpp.
References xms::ttEqualPointsXYZ().
Referenced by xms::ttAssertDeltaPt3d(), and xms::ttAssertDeltaVecPt3d().
void xms::ttGetTestFilePaths | ( | const std::string & | a_path, |
const std::string & | a_fileBase, | ||
const std::string & | a_extension, | ||
std::string & | a_baseFilePath, | ||
std::string & | a_outFilePath | ||
) |
Get testing base and output file using the compiled for architecture. Checks for appended "MacOsX" for Mac OS X and "64" for 64-bit builds. For example with Mac OS 64-bit build looks for test_baseMacOsX.vtu then if not found test_base64.vtu, then if neither found then uses test_base.vtu.
[in] | a_path | Path to the file. |
[in] | a_fileBase | File name without extension. |
[in] | a_extension | File extension. |
[out] | a_baseFilePath | Path to base file. |
[out] | a_outFilePath | Path to output file. |
Definition at line 277 of file TestTools.cpp.
References xms::ttGetTestFilePaths().
Referenced by xms::ttEqualWithinTolerance(), and xms::ttGetTestFilePaths().
bool xms::ttSkippingMessages | ( | ) |
Has ttByPassMessages been called without calling ttClearSkippingMessages.
Definition at line 206 of file TestTools.cpp.
References xms::ETestMessagingState::GetSkipping(), xms::ttSkippingMessages(), and xms::ttTestMessagingState().
Referenced by xms::ttSkippingMessages().
void xms::ttStreamsEqual | ( | const std::string & | a_src, |
unsigned int | a_line, | ||
std::istream & | a_strm1, | ||
std::istream & | a_strm2 | ||
) |
Returns true if the two streams are equal.
[in] | a_src | Source code file where this is called from. |
[in] | a_line | Line in source code file where this is called from. |
[in] | a_strm1 | First stream. |
[in] | a_strm2 | Second stream. |
Definition at line 395 of file TestTools.cpp.
References xms::ttStreamsEqual().
Referenced by xms::ttEqualWithinTolerance(), and xms::ttStreamsEqual().
ETestMessagingState & xms::ttTestMessagingState | ( | ) |
Get the batch mode singleton.
Definition at line 230 of file TestTools.cpp.
References xms::ttTestMessagingState().
Referenced by xms::ttByPassDefault(), xms::ttByPassMessages(), xms::ttClearSkippingMessages(), xms::ttSkippingMessages(), and xms::ttTestMessagingState().
bool xms::ttTextFilesEqual | ( | const std::string & | a_file1, |
const std::string & | a_file2, | ||
std::string & | a_message | ||
) |
Returns true if the two files are equal.
[in] | a_file1 | Path to first file. |
[in] | a_file2 | Path to second file. |
[out] | a_message | Error message if the files aren't equal. |
Definition at line 324 of file TestTools.cpp.
References xms::ttTextFilesEqual().
Referenced by xms::ttEqualWithinTolerance(), and xms::ttTextFilesEqual().
void xms::ttTextFilesEqual | ( | const std::string & | a_srcFile, |
unsigned | a_line, | ||
const std::string & | a_file1, | ||
const std::string & | a_file2 | ||
) |
Returns true if the two files are equal.
[in] | a_srcFile | Source code file where this is called from. |
[in] | a_line | Line in source code file where this is called from. |
[in] | a_file1 | Path to first file. |
[in] | a_file2 | Path to second file. |
Definition at line 379 of file TestTools.cpp.
References xms::ttTextFilesEqual().