blob: 47984b69b9b534d7506eae30c4c4915002374cff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#ifndef __cxxtest__StdioFilePrinter_h__
#define __cxxtest__StdioFilePrinter_h__
//
// The StdioFilePrinter is a simple TestListener that
// just prints "OK" if everything goes well, otherwise
// reports the error in the format of compiler messages.
// This class uses <stdio.h>, i.e. FILE * and fprintf().
//
#include <cxxtest/ErrorFormatter.h>
#include <stdio.h>
namespace CxxTest
{
class StdioFilePrinter : public ErrorFormatter
{
public:
StdioFilePrinter( FILE *o, const char *preLine = ":", const char *postLine = "" ) :
ErrorFormatter( new Adapter(o), preLine, postLine ) {}
virtual ~StdioFilePrinter() { delete outputStream(); }
private:
class Adapter : public OutputStream
{
Adapter( const Adapter & );
Adapter &operator=( const Adapter & );
FILE *_o;
public:
Adapter( FILE *o ) : _o(o) {}
void flush() { fflush( _o ); }
OutputStream &operator<<( unsigned i ) { fprintf( _o, "%u", i ); return *this; }
OutputStream &operator<<( const char *s ) { fputs( s, _o ); return *this; }
OutputStream &operator<<( Manipulator m ) { return OutputStream::operator<<( m ); }
};
};
}
#endif // __cxxtest__StdioFilePrinter_h__
|