22 #pragma warning(disable : 4103) // boost code: alignment change 23 #include <boost/filesystem.hpp> 25 #include <boost/predef.h> 26 #include <cxxtest/GlobalFixture.h> 27 #include <cxxtest/TestSuite.h> 35 #include <mach-o/dyld.h> 52 class CheckXmLogFixture :
public CxxTest::GlobalFixture
55 bool setUp()
override;
56 bool tearDown()
override;
59 static CheckXmLogFixture fg_checkXmLogFixture;
60 static bool fg_checkLogForEachTest =
false;
67 bool CheckXmLogFixture::setUp()
69 if (fg_checkLogForEachTest)
73 TS_ASSERT_EQUALS(std::string(), errors);
85 bool CheckXmLogFixture::tearDown()
87 if (fg_checkLogForEachTest)
91 TS_ASSERT_EQUALS(std::string(), errors);
107 bool iFindTestFile(
const std::string& a_filePath)
112 if (fopen_s(&fp, a_filePath.c_str(),
"r") || fp ==
nullptr)
117 fp = fopen(a_filePath.c_str(),
"r");
138 : m_skippingMessages(false)
139 , m_defaultSet(false)
140 , m_defaultRetValue(0)
241 fg_checkLogForEachTest = a_setting;
249 return fg_checkLogForEachTest;
262 _TS_ASSERT_EQUALS(a_file, a_line, a_expected, errors);
278 const std::string& a_fileBase,
279 const std::string& a_extension,
280 std::string& a_baseFilePath,
281 std::string& a_outFilePath)
283 bool foundBase =
false;
288 a_baseFilePath = a_path + a_fileBase +
"_baseMacOsX" + a_extension;
289 foundBase = iFindTestFile(a_baseFilePath);
295 a_baseFilePath = a_path + a_fileBase +
"_baseLinux" + a_extension;
296 foundBase = iFindTestFile(a_baseFilePath);
300 #if defined(ENV64BIT) 304 a_baseFilePath = a_path + a_fileBase +
"_base64" + a_extension;
305 foundBase = iFindTestFile(a_baseFilePath);
307 #elif defined(ENV32BIT) 310 #error "Must define either ENV32BIT or ENV64BIT" 313 a_baseFilePath = a_path + a_fileBase +
"_base" + a_extension;
315 a_outFilePath = a_path + a_fileBase +
"_out" + a_extension;
325 const std::string& a_file2,
326 std::string& a_message)
328 std::ifstream iOut(a_file1), iBase(a_file2);
329 std::string lineOut, lineBase;
331 if (!iOut.is_open() || !iBase.is_open())
333 std::stringstream msg;
334 msg <<
"Unable to open file: " 344 a_message = msg.str();
347 while (!iOut.eof() && !iBase.eof())
349 std::getline(iOut, lineOut);
350 std::getline(iBase, lineBase);
352 lineOut.erase(lineOut.find_last_not_of(
"\n\r") + 1);
353 lineBase.erase(lineBase.find_last_not_of(
"\n\r") + 1);
354 if (lineOut != lineBase)
356 std::stringstream msg;
357 msg <<
"Files different on line " << lineCnt <<
"." 359 <<
"File: " << a_file1 <<
"." 362 <<
"File: " << a_file2 <<
"." 365 a_message = msg.str();
381 const std::string& a_file1,
382 const std::string& a_file2)
386 _TS_FAIL(a_srcFile.c_str(), a_line, msg.c_str());
397 std::istream& a_strm1,
398 std::istream& a_strm2)
400 std::string line1, line2;
401 unsigned int line_count(1);
410 while (!a_strm1.eof() && !a_strm2.eof())
412 std::getline(a_strm1, line1);
413 std::getline(a_strm2, line2);
417 std::stringstream msg;
419 msg <<
"Streams different on line " << line_count <<
".\n";
420 msg <<
"Stream1: \"" << line1 <<
"\"\n";
421 msg <<
"Stream2: \"" << line2 <<
"\"\n";
423 _TS_FAIL(a_src.c_str(), a_line, msg.str().c_str());
429 if ((a_strm1.eof() && !a_strm2.eof()) || (!a_strm1.eof() && a_strm2.eof()))
431 _TS_FAIL(a_src.c_str(), a_line,
"Streams of different lengths");
464 if ((fabs(a_x1 - a_x2) <= a_tolerance) && (fabs(a_y1 - a_y2) <= a_tolerance) &&
465 (fabs(a_z1 - a_z2) <= a_tolerance))
478 bool ttEqualPointsXY(
double a_x1,
double a_y1,
double a_x2,
double a_y2,
double a_tolerance)
480 double dx = fabs(a_x1 - a_x2);
481 double dy = fabs(a_y1 - a_y2);
482 if (dx > a_tolerance || dy > a_tolerance)
484 else if (sqrt(dx * dx + dy * dy) <= a_tolerance)
Class to allow running in batch mode without ui elements. Currently only used for testing but it can ...
bool m_defaultSet
Has a default result value been set?
ETestMessagingState()
Constructor.
void ClearDefault()
Change to no default value set.
std::string GetAndClearStackStr()
Clears the error stack and returns its contents as a string.
int GetDefault()
Get default value.
bool m_skippingMessages
Are messages being skipped?
void SetSkipping(bool a_)
Set if skipping messages.
void SetDefault(int a_)
Set default result value.
int m_defaultRetValue
Default return value.
Routines for creating and writing to logs and stacking errors.
static XmLog & Instance(bool a_delete=false, XmLog *a_new=NULL)
Get the instance of the singleton.
bool DefaultValWasSet()
Was default value set (true) or has it been cleared?
bool GetSkipping()
Get if skipping messages.