StdioFilePrinter.h
Go to the documentation of this file.
1 #ifndef __cxxtest__StdioFilePrinter_h__
2 #define __cxxtest__StdioFilePrinter_h__
3 
4 //
5 // The StdioFilePrinter 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 // This class uses <stdio.h>, i.e. FILE * and fprintf().
9 //
10 
11 #include <cxxtest/ErrorFormatter.h>
12 #include <stdio.h>
13 
14 namespace CxxTest
15 {
17  {
18  public:
19  StdioFilePrinter( FILE *o, const char *preLine = ":", const char *postLine = "" ) :
20  ErrorFormatter( new Adapter(o), preLine, postLine ) {}
21  virtual ~StdioFilePrinter() { delete outputStream(); }
22 
23  private:
24  class Adapter : public OutputStream
25  {
26  Adapter( const Adapter & );
27  Adapter &operator=( const Adapter & );
28 
29  FILE *_o;
30 
31  public:
32  Adapter( FILE *o ) : _o(o) {}
33  void flush() { fflush( _o ); }
34  OutputStream &operator<<( unsigned i ) { fprintf( _o, "%u", i ); return *this; }
35  OutputStream &operator<<( const char *s ) { fputs( s, _o ); return *this; }
37  };
38  };
39 }
40 
41 #endif // __cxxtest__StdioFilePrinter_h__
OutputStream & operator<<(unsigned i)
OutputStream & operator<<(const char *s)
virtual OutputStream & operator<<(unsigned)
StdioFilePrinter(FILE *o, const char *preLine=":", const char *postLine="")
void(* Manipulator)(OutputStream &)
Adapter & operator=(const Adapter &)
char * s
Definition: ValueTraits.h:143
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
OutputStream & operator<<(Manipulator m)
OutputStream * outputStream() const