More reformatting

This commit is contained in:
Phil Nash
2012-05-15 08:02:36 +01:00
parent 2efc1146bf
commit d0be9ed5d9
11 changed files with 124 additions and 396 deletions

View File

@@ -1,7 +1,4 @@
/*
* catch_stream.hpp
* Catch
*
* Created by Phil on 17/01/2011.
* Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
*
@@ -9,47 +6,33 @@
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
#ifndef TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED
#include <stdexcept>
#include <cstdio>
namespace Catch
{
namespace Catch {
template<typename WriterF, size_t bufferSize=256>
class StreamBufImpl : public StreamBufBase
{
class StreamBufImpl : public StreamBufBase {
char data[bufferSize];
WriterF m_writer;
public:
///////////////////////////////////////////////////////////////////////
StreamBufImpl
()
{
StreamBufImpl() {
setp( data, data + sizeof(data) );
}
///////////////////////////////////////////////////////////////////////
~StreamBufImpl
()
{
~StreamBufImpl() {
sync();
}
private:
///////////////////////////////////////////////////////////////////////
int overflow
(
int c
)
{
int overflow( int c ) {
sync();
if( c != EOF )
{
if( c != EOF ) {
if( pbase() == epptr() )
m_writer( std::string( 1, static_cast<char>( c ) ) );
else
@@ -58,12 +41,8 @@ namespace Catch
return 0;
}
///////////////////////////////////////////////////////////////////////
int sync
()
{
if( pbase() != pptr() )
{
int sync() {
if( pbase() != pptr() ) {
m_writer( std::string( pbase(), static_cast<std::string::size_type>( pptr() - pbase() ) ) );
setp( pbase(), epptr() );
}
@@ -71,17 +50,11 @@ namespace Catch
}
};
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
struct OutputDebugWriter
{
///////////////////////////////////////////////////////////////////////
void operator()
(
const std::string &str
)
{
struct OutputDebugWriter {
void operator()( const std::string &str ) {
writeToDebugConsole( str );
}
};