Loading...
Searching...
No Matches
ErrorPrinter.h
Go to the documentation of this file.
#ifndef __cxxtest__ErrorPrinter_h__
#define __cxxtest__ErrorPrinter_h__
//
// The ErrorPrinter is a simple TestListener that
// just prints "OK" if everything goes well, otherwise
// reports the error in the format of compiler messages.
// The ErrorPrinter uses std::cout
//
#include <cxxtest/Flags.h>
#ifndef _CXXTEST_HAVE_STD
# define _CXXTEST_HAVE_STD
#endif // _CXXTEST_HAVE_STD
#include <cxxtest/ErrorFormatter.h>
#include <cxxtest/StdValueTraits.h>
#ifdef _CXXTEST_OLD_STD
# include <iostream.h>
#else // !_CXXTEST_OLD_STD
# include <iostream>
#endif // _CXXTEST_OLD_STD
namespace CxxTest
{
class ErrorPrinter : public ErrorFormatter
{
public:
ErrorPrinter( CXXTEST_STD(ostream) &o = CXXTEST_STD(cout), const char *preLine = ":", const char *postLine = "" ) :
ErrorFormatter( new Adapter(o), preLine, postLine ) {}
virtual ~ErrorPrinter() { delete outputStream(); }
private:
class Adapter : public OutputStream
{
CXXTEST_STD(ostream) &_o;
public:
Adapter( CXXTEST_STD(ostream) &o ) : _o(o) {}
void flush() { _o.flush(); }
OutputStream &operator<<( const char *s ) { _o << s; return *this; }
OutputStream &operator<<( Manipulator m ) { return OutputStream::operator<<( m ); }
OutputStream &operator<<( unsigned i )
{
char s[1 + 3 * sizeof(unsigned)];
numberToString( i, s );
_o << s;
return *this;
}
};
};
}
#endif // __cxxtest__ErrorPrinter_h__
ErrorFormatter.h
Flags.h
StdValueTraits.h
CXXTEST_STD
#define CXXTEST_STD(x)
Definition StdValueTraits.h:16
m
int m
Definition cfEzgcd.cc:128
i
int i
Definition cfEzgcd.cc:132
CxxTest::ErrorFormatter::_o
OutputStream * _o
Definition ErrorFormatter.h:275
CxxTest::ErrorFormatter::outputStream
OutputStream * outputStream() const
Definition ErrorFormatter.h:208
CxxTest::ErrorFormatter::ErrorFormatter
ErrorFormatter(OutputStream *o, const char *preLine=":", const char *postLine="")
Definition ErrorFormatter.h:36
CxxTest::ErrorPrinter::Adapter
Definition ErrorPrinter.h:37
CxxTest::ErrorPrinter::Adapter::operator<<
OutputStream & operator<<(const char *s)
Definition ErrorPrinter.h:42
CxxTest::ErrorPrinter::Adapter::Adapter
Adapter(CXXTEST_STD(ostream) &o)
Definition ErrorPrinter.h:40
CxxTest::ErrorPrinter::Adapter::operator<<
OutputStream & operator<<(Manipulator m)
Definition ErrorPrinter.h:43
CxxTest::ErrorPrinter::Adapter::operator<<
OutputStream & operator<<(unsigned i)
Definition ErrorPrinter.h:44
CxxTest::ErrorPrinter::Adapter::flush
void flush()
Definition ErrorPrinter.h:41
CxxTest::ErrorPrinter::Adapter::CXXTEST_STD
CXXTEST_STD(ostream) &_o
CxxTest::ErrorPrinter::ErrorPrinter
ErrorPrinter(CXXTEST_STD(ostream) &o=CXXTEST_STD(cout), const char *preLine=":", const char *postLine="")
Definition ErrorPrinter.h:31
CxxTest::ErrorPrinter::~ErrorPrinter
virtual ~ErrorPrinter()
Definition ErrorPrinter.h:33
CxxTest::OutputStream
Definition ErrorFormatter.h:20
CxxTest::OutputStream::operator<<
virtual OutputStream & operator<<(unsigned)
Definition ErrorFormatter.h:24
CxxTest::OutputStream::Manipulator
void(* Manipulator)(OutputStream &)
Definition ErrorFormatter.h:27
CxxTest
Definition Descriptions.cpp:7
CxxTest::s
char * s
Definition ValueTraits.h:143