Code

Translations. French translation minor update.
[inkscape.git] / cxxtest / cxxtest / StdioFilePrinter.h
1 #ifndef __cxxtest__StdioFilePrinter_h__
2 #define __cxxtest__StdioFilePrinter_h__
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 //
11 #include <cxxtest/ErrorFormatter.h>
12 #include <stdio.h>
14 namespace CxxTest 
15 {
16     class StdioFilePrinter : public ErrorFormatter
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(); }
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; }
36             OutputStream &operator<<( Manipulator m ) { return OutputStream::operator<<( m ); }
37         };
38     };
39 }
41 #endif // __cxxtest__StdioFilePrinter_h__