70fd8f7de4994668eeb9f532d0523266a176e795joncruz#ifndef PYLOG_FORMATTER_H_SEEN
70fd8f7de4994668eeb9f532d0523266a176e795joncruz#define PYLOG_FORMATTER_H_SEEN
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
69340304f32eac4d438c67b5e1f6bc2f0a05ea22pjrm#include <cstring>
70fd8f7de4994668eeb9f532d0523266a176e795joncruz#include <cxxtest/Flags.h>
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz#ifndef _CXXTEST_HAVE_STD
70fd8f7de4994668eeb9f532d0523266a176e795joncruz# define _CXXTEST_HAVE_STD
70fd8f7de4994668eeb9f532d0523266a176e795joncruz#endif // _CXXTEST_HAVE_STD
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz#include <cxxtest/ErrorFormatter.h>
70fd8f7de4994668eeb9f532d0523266a176e795joncruz#include <cxxtest/StdValueTraits.h>
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz#ifdef _CXXTEST_OLD_STD
70fd8f7de4994668eeb9f532d0523266a176e795joncruz# include <iostream.h>
70fd8f7de4994668eeb9f532d0523266a176e795joncruz#else // !_CXXTEST_OLD_STD
70fd8f7de4994668eeb9f532d0523266a176e795joncruz# include <iostream>
70fd8f7de4994668eeb9f532d0523266a176e795joncruz#endif // _CXXTEST_OLD_STD
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruznamespace CxxTest
70fd8f7de4994668eeb9f532d0523266a176e795joncruz{
70fd8f7de4994668eeb9f532d0523266a176e795joncruzclass PylogFormatter : public TestListener
70fd8f7de4994668eeb9f532d0523266a176e795joncruz{
70fd8f7de4994668eeb9f532d0523266a176e795joncruzpublic:
70fd8f7de4994668eeb9f532d0523266a176e795joncruz PylogFormatter( OutputStream *o, const char* name = "test" ) :
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _o(o),
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _base( _chompPath( name ) ),
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _runPassed(true),
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _suiteIndex(-1),
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _testIndex(-1)
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {}
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual ~PylogFormatter() { delete outputStream(); }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
6ad76e4c8e1862d23d04bb34a3fbc330e6b8cd30joncruz virtual void enterWorld( const WorldDescription & /*desc*/ )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << "**************************************************" << endl;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _o->flush();
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void leaveWorld( const WorldDescription & desc )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
69340304f32eac4d438c67b5e1f6bc2f0a05ea22pjrm using std::strlen;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz unsigned int skippedCount = 0;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz unsigned int failedCount = 0;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz unsigned int warnedCount = 0;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz unsigned int passedCount = 0;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz for ( unsigned int i = 0; i < desc.numSuites(); i++ ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const SuiteDescription& suite = desc.suiteDescription(i);
70fd8f7de4994668eeb9f532d0523266a176e795joncruz for ( unsigned int j = 0; j < suite.numTests(); j++ ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const TestDescription& test = suite.testDescription(j);
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz // Test Name
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << _base.c_str() << "_";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _padOut( i, 3 );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << "_";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _padOut( j, 3);
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << " ";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz // Test Description
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << test.suiteName() << "_|_" << test.testName();
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << " ";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
69340304f32eac4d438c67b5e1f6bc2f0a05ea22pjrm unsigned const sent = strlen( test.suiteName() ) + strlen( test.testName() ) + 1;
69340304f32eac4d438c67b5e1f6bc2f0a05ea22pjrm for ( unsigned z = sent; z < 56; z++ ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << " ";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << " : ";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz switch ( _status[i][j] ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz case OK:
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << "PASS";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz passedCount++;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz break;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz case SKIPPED:
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << "OMIT";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz skippedCount++;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz break;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz case WARNING:
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << "WARNING";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz warnedCount++;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz break;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz case ERROR:
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << "FAILURE";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz failedCount++;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz break;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << endl;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz for ( CXXTEST_STD(vector)<CXXTEST_STD(string)>::iterator it = _messages[i][j].begin(); it < _messages[i][j].end(); ++it ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << " " << (*it).c_str() << endl;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << "**************************************************" << endl;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << "Command line asked for " << desc.numTotalTests() << " of " << desc.numTotalTests() << " tests" << endl;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << "Of those: "
70fd8f7de4994668eeb9f532d0523266a176e795joncruz << skippedCount << " Skipped, "
70fd8f7de4994668eeb9f532d0523266a176e795joncruz << failedCount << " Failed, "
70fd8f7de4994668eeb9f532d0523266a176e795joncruz << warnedCount << " Warned, "
70fd8f7de4994668eeb9f532d0523266a176e795joncruz << passedCount << " Passed"
70fd8f7de4994668eeb9f532d0523266a176e795joncruz << endl;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void enterSuite( const SuiteDescription & desc )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (void)desc;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _suiteIndex++;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _testIndex = -1;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz while ( (_suiteIndex >= 0) && ((int)_status.size() <= _suiteIndex) ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(vector)<ErrorLevel> tmp;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _status.push_back(tmp);
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(vector)<CXXTEST_STD(vector)<CXXTEST_STD(string)> > tmp2;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _messages.push_back(tmp2);
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void leaveSuite( const SuiteDescription & desc )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (void)desc;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void enterTest( const TestDescription & desc )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (void)desc;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz if ( _suiteIndex >= 0 && (int)_status.size() > _suiteIndex ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _testIndex++;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz while ( (_testIndex >= 0) && ((int)_status[_suiteIndex].size() <= _testIndex) ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz ErrorLevel tmp = OK;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _status[_suiteIndex].push_back(tmp);
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(vector)<CXXTEST_STD(string)> tmp2;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _messages[_suiteIndex].push_back(tmp2);
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void leaveTest( const TestDescription & desc )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (void)desc;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void trace( const char * file, unsigned line,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * expression )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(string)tmp(expression);
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _traceCurrent( file, line, tmp );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void warning( const char * file, unsigned line,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * expression )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(string)tmp(expression);
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _warnCurrent( file, line, tmp );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void failedTest( const char * file, unsigned line,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * expression )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(string)tmp(expression);
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _failCurrent( file, line, tmp );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void failedAssert( const char * file, unsigned line,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * expression )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(string)tmp(expression);
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _failCurrent( file, line, tmp );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void failedAssertEquals( const char * file, unsigned line,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * xStr, const char * yStr,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * x, const char * y )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(string)tmp;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += "Expected (";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += xStr;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += " == ";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += yStr;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += "), found (";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += x;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += " != ";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += y;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += ")";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _failCurrent( file, line, tmp );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void failedAssertSameData( const char * file, unsigned line,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * /*xStr*/, const char * /*yStr*/,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * /*sizeStr*/, const void * /*x*/,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const void * /*y*/, unsigned /*size*/ )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(string)tmp("TODO - fill in error details");
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _failCurrent( file, line, tmp );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void failedAssertDelta( const char * file, unsigned line,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * /*xStr*/, const char * /*yStr*/,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * /*dStr*/, const char * /*x*/,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * /*y*/, const char * /*d*/ )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(string)tmp("TODO - fill in error details");
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _failCurrent( file, line, tmp );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void failedAssertDiffers( const char * file, unsigned line,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * xStr, const char * yStr,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * value )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(string)tmp;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += "Expected (";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += xStr;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += " != ";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += yStr;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += "), found (";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += value;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += ")";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _failCurrent( file, line, tmp );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void failedAssertLessThan( const char * file, unsigned line,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * xStr, const char * yStr,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * x, const char * y )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(string)tmp;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += "Expected (";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += xStr;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += " < ";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += yStr;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += "), found (";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += x;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += " >= ";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += y;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += ")";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _failCurrent( file, line, tmp );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void failedAssertLessThanEquals( const char * file, unsigned line,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * xStr, const char * yStr,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * x, const char * y )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(string)tmp;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += "Expected (";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += xStr;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += " <= ";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += yStr;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += "), found (";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += x;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += " > ";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += y;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp += ")";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _failCurrent( file, line, tmp );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void failedAssertPredicate( const char * file, unsigned line,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * /*predicate*/, const char * /*xStr*/, const char * /*x*/ )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(string)tmp("TODO - fill in error details");
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _failCurrent( file, line, tmp );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void failedAssertRelation( const char * file, unsigned line,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * /*relation*/, const char * /*xStr*/, const char * /*yStr*/,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * /*x*/, const char * /*y*/ )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(string)tmp("TODO - fill in error details");
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _failCurrent( file, line, tmp);
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void failedAssertThrows( const char * file, unsigned line,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * /*expression*/, const char * /*type*/,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz bool /*otherThrown*/ )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(string)tmp("TODO - fill in error details");
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _failCurrent( file, line, tmp );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz virtual void failedAssertThrowsNot( const char * file, unsigned line,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz const char * expression )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(string)tmp(expression);
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _failCurrent( file, line, tmp );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruzprotected:
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz enum ErrorLevel {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz OK,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz SKIPPED,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz WARNING,
70fd8f7de4994668eeb9f532d0523266a176e795joncruz ERROR
70fd8f7de4994668eeb9f532d0523266a176e795joncruz };
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz OutputStream *outputStream() const
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz return _o;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
6ad76e4c8e1862d23d04bb34a3fbc330e6b8cd30joncruz void _traceCurrent( const char* /*file*/, unsigned /*line*/, const CXXTEST_STD(string)& errMsg ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _runPassed = false;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz if ( _suiteIndex < (int)_status.size() ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz if ( _testIndex < (int)_status[_suiteIndex].size() ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _messages[_suiteIndex][_testIndex].push_back( errMsg );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
6ad76e4c8e1862d23d04bb34a3fbc330e6b8cd30joncruz void _warnCurrent( const char* /*file*/, unsigned /*line*/, const CXXTEST_STD(string)& errMsg ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _runPassed = false;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz if ( _suiteIndex < (int)_status.size() ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz if ( _testIndex < (int)_status[_suiteIndex].size() ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz if ( _status[_suiteIndex][_testIndex] != ERROR ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _status[_suiteIndex][_testIndex] = WARNING;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _messages[_suiteIndex][_testIndex].push_back( errMsg );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
6ad76e4c8e1862d23d04bb34a3fbc330e6b8cd30joncruz void _failCurrent( const char* /*file*/, unsigned /*line*/, const CXXTEST_STD(string)& errMsg ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _runPassed = false;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz if ( _suiteIndex < (int)_status.size() ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz if ( _testIndex < (int)_status[_suiteIndex].size() ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _status[_suiteIndex][_testIndex] = ERROR;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz _messages[_suiteIndex][_testIndex].push_back( errMsg );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz void _padOut( unsigned int num, int digits )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz int match = 1;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz for ( int j = 1; j < digits; j++ ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz match *= 10;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz for ( unsigned int i = match; i > 1 && i > num; i /= 10 )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << "0";
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz (*_o) << num;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruzprivate:
70fd8f7de4994668eeb9f532d0523266a176e795joncruz static void endl( OutputStream &o )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz OutputStream::endl( o );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz static CXXTEST_STD(string) _chompPath( const char* str )
70fd8f7de4994668eeb9f532d0523266a176e795joncruz {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(string) tmp( str );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz if ( tmp.length() > 2 && tmp[0] == '.' && tmp[1] == '/' ) {
70fd8f7de4994668eeb9f532d0523266a176e795joncruz tmp = tmp.substr( 2 );
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz return tmp;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz }
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz OutputStream *_o;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(string) _base;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(vector)< CXXTEST_STD(vector)<ErrorLevel> > _status;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz CXXTEST_STD(vector)< CXXTEST_STD(vector)< CXXTEST_STD(vector)<CXXTEST_STD(string)> > > _messages;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz bool _runPassed;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz int _suiteIndex;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz int _testIndex;
70fd8f7de4994668eeb9f532d0523266a176e795joncruz};
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz} // namespace CxxTest
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz/*
70fd8f7de4994668eeb9f532d0523266a176e795joncruz Local Variables:
70fd8f7de4994668eeb9f532d0523266a176e795joncruz mode:c++
70fd8f7de4994668eeb9f532d0523266a176e795joncruz c-file-style:"stroustrup"
70fd8f7de4994668eeb9f532d0523266a176e795joncruz c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
70fd8f7de4994668eeb9f532d0523266a176e795joncruz indent-tabs-mode:nil
70fd8f7de4994668eeb9f532d0523266a176e795joncruz fill-column:99
70fd8f7de4994668eeb9f532d0523266a176e795joncruz End:
70fd8f7de4994668eeb9f532d0523266a176e795joncruz*/
a4030d5ca449e7e384bc699cd249ee704faaeab0Chris Morgan// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
70fd8f7de4994668eeb9f532d0523266a176e795joncruz
70fd8f7de4994668eeb9f532d0523266a176e795joncruz#endif // PYLOG_FORMATTER_H_SEEN