mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-19 11:25:38 +02:00
More reformatting
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user