diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2006-04-27 02:29:29 +0000 |
|---|---|---|
| committer | joncruz <joncruz@users.sourceforge.net> | 2006-04-27 02:29:29 +0000 |
| commit | ed32af9cb2312e5f6a734be48d2b72a91c019427 (patch) | |
| tree | 14974093262851ae1acbc776406b7a177879f018 /src/MultiPrinter.h | |
| parent | write no/unset fill/stroke to current style (diff) | |
| download | inkscape-ed32af9cb2312e5f6a734be48d2b72a91c019427.tar.gz inkscape-ed32af9cb2312e5f6a734be48d2b72a91c019427.zip | |
Adding multiple test output formats.
(bzr r592)
Diffstat (limited to 'src/MultiPrinter.h')
| -rw-r--r-- | src/MultiPrinter.h | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/src/MultiPrinter.h b/src/MultiPrinter.h new file mode 100644 index 000000000..1792a744f --- /dev/null +++ b/src/MultiPrinter.h @@ -0,0 +1,113 @@ +#ifndef SEEN_MULTI_PRINTER_H +#define SEEN_MULTI_PRINTER_H + + +#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> +# include <fstream.h> +# include <string.h> +#else // !_CXXTEST_OLD_STD +# include <iostream> +# include <fstream> +# include <string> +#endif // _CXXTEST_OLD_STD + + +#include <cxxtest/TeeListener.h> +#include "TRPIFormatter.h" +#include "PylogFormatter.h" + +namespace CxxTest { + +class MultiPrinter : public TeeListener +{ +public: + MultiPrinter( const char* baseName = "result" ) : + TeeListener(), + _baseName( baseName ), + _xmlName( _baseName + ".xml" ), + _logName( _baseName + ".log" ), + _xmlFile( _xmlName.c_str(), CXXTEST_STD(ios::out)), + _logFile( _logName.c_str(), CXXTEST_STD(ios::out)), + _dstOne( new FileAdapter( CXXTEST_STD(cout) ) ), + _dstXml( new FileAdapter( _xmlFile ) ), + _dstPylog( new FileAdapter( _logFile ), _baseName.c_str() ) + { + setFirst( _dstOne ); + setSecond( _subTee ); + _subTee.setFirst( _dstXml ); + _subTee.setSecond( _dstPylog ); + } + + virtual ~MultiPrinter() + { + std::cout << "CLOSING OUT TEST" << std::endl; + _xmlFile.close(); + _logFile.close(); + } + + int run() + { + TestRunner::runAllTests( *this ); + return tracker().failedTests(); + } + +protected: + CXXTEST_STD(string) _baseName; + CXXTEST_STD(string) _xmlName; + CXXTEST_STD(string) _logName; + CXXTEST_STD(fstream) _xmlFile; + CXXTEST_STD(fstream) _logFile; + + TeeListener _subTee; + ErrorFormatter _dstOne; + TRPIFormatter _dstXml; + PylogFormatter _dstPylog; + +private: + class FileAdapter : public OutputStream + { + FileAdapter( const FileAdapter & ); + FileAdapter &operator=( const FileAdapter & ); + + CXXTEST_STD(ostream) &_o; + + public: + FileAdapter( 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; + } + }; + +}; + +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : + +#endif //SEEN_MULTI_PRINTER_H |
