My Project
Loading...
Searching...
No Matches
ErrorPrinter.h
Go to the documentation of this file.
1#ifndef __cxxtest__ErrorPrinter_h__
2#define __cxxtest__ErrorPrinter_h__
3
4//
5// The ErrorPrinter is a simple TestListener that
6// just prints "OK" if everything goes well, otherwise
7// reports the error in the format of compiler messages.
8// The ErrorPrinter uses std::cout
9//
10
11#include <cxxtest/Flags.h>
12
13#ifndef _CXXTEST_HAVE_STD
14# define _CXXTEST_HAVE_STD
15#endif // _CXXTEST_HAVE_STD
16
19
20#ifdef _CXXTEST_OLD_STD
21# include <iostream.h>
22#else // !_CXXTEST_OLD_STD
23# include <iostream>
24#endif // _CXXTEST_OLD_STD
25
26namespace CxxTest
27{
29 {
30 public:
31 ErrorPrinter( CXXTEST_STD(ostream) &o = CXXTEST_STD(cout), const char *preLine = ":", const char *postLine = "" ) :
32 ErrorFormatter( new Adapter(o), preLine, postLine ) {}
33 virtual ~ErrorPrinter() { delete outputStream(); }
34
35 private:
36 class Adapter : public OutputStream
37 {
38 CXXTEST_STD(ostream) &_o;
39 public:
40 Adapter( CXXTEST_STD(ostream) &o ) : _o(o) {}
41 void flush() { _o.flush(); }
42 OutputStream &operator<<( const char *s ) { _o << s; return *this; }
45 {
46 char s[1 + 3 * sizeof(unsigned)];
47 numberToString( i, s );
48 _o << s;
49 return *this;
50 }
51 };
52 };
53}
54
55#endif // __cxxtest__ErrorPrinter_h__
#define CXXTEST_STD(x)
int m
Definition: cfEzgcd.cc:128
int i
Definition: cfEzgcd.cc:132
OutputStream * outputStream() const
OutputStream & operator<<(const char *s)
Definition: ErrorPrinter.h:42
Adapter(CXXTEST_STD(ostream) &o)
Definition: ErrorPrinter.h:40
OutputStream & operator<<(Manipulator m)
Definition: ErrorPrinter.h:43
OutputStream & operator<<(unsigned i)
Definition: ErrorPrinter.h:44
ErrorPrinter(CXXTEST_STD(ostream) &o=CXXTEST_STD(cout), const char *preLine=":", const char *postLine="")
Definition: ErrorPrinter.h:31
virtual void flush()
virtual OutputStream & operator<<(unsigned)
void(* Manipulator)(OutputStream &)
char * s
Definition: ValueTraits.h:143