mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-17 11:12:25 +01:00
Update to build 26
This commit is contained in:
commit
04acaebe74
@ -1,6 +1,6 @@
|
|||||||
![catch logo](catch-logo-small.png)
|
![catch logo](catch-logo-small.png)
|
||||||
|
|
||||||
*v1.0 build 25 (master branch)*
|
*v1.0 build 26 (master branch)*
|
||||||
|
|
||||||
Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch)
|
Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch)
|
||||||
|
|
||||||
|
@ -8,12 +8,12 @@
|
|||||||
#ifndef TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED
|
||||||
#define TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include "internal/catch_text.h"
|
||||||
#include "internal/catch_commandline.hpp"
|
#include "internal/catch_commandline.hpp"
|
||||||
#include "internal/catch_list.hpp"
|
#include "internal/catch_list.hpp"
|
||||||
#include "internal/catch_runner_impl.hpp"
|
#include "internal/catch_runner_impl.hpp"
|
||||||
#include "internal/catch_test_spec.h"
|
#include "internal/catch_test_spec.h"
|
||||||
#include "internal/catch_version.h"
|
#include "internal/catch_version.h"
|
||||||
#include "internal/catch_text.h"
|
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
20
include/internal/catch_clara.h
Normal file
20
include/internal/catch_clara.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 10/2/2014.
|
||||||
|
* Copyright 2014 Two Blue Cubes Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef TWOBLUECUBES_CATCH_CLARA_H_INCLUDED
|
||||||
|
#define TWOBLUECUBES_CATCH_CLARA_H_INCLUDED
|
||||||
|
|
||||||
|
#define CLARA_CONFIG_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH
|
||||||
|
|
||||||
|
|
||||||
|
// Declare Clara inside the Catch namespace
|
||||||
|
#define CLICHE_CLARA_OUTER_NAMESPACE Catch
|
||||||
|
#include "clara.h"
|
||||||
|
#undef CLICHE_CLARA_OUTER_NAMESPACE
|
||||||
|
|
||||||
|
#endif // TWOBLUECUBES_CATCH_CLARA_H_INCLUDED
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include "catch_config.hpp"
|
#include "catch_config.hpp"
|
||||||
#include "catch_common.h"
|
#include "catch_common.h"
|
||||||
#include "clara.h"
|
#include "catch_clara.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include "catch_tags.hpp"
|
#include "catch_tags.hpp"
|
||||||
#include "catch_test_spec.hpp"
|
#include "catch_test_spec.hpp"
|
||||||
#include "catch_version.hpp"
|
#include "catch_version.hpp"
|
||||||
#include "catch_text.hpp"
|
|
||||||
#include "catch_message.hpp"
|
#include "catch_message.hpp"
|
||||||
#include "catch_legacy_reporter_adapter.hpp"
|
#include "catch_legacy_reporter_adapter.hpp"
|
||||||
#include "catch_timer.hpp"
|
#include "catch_timer.hpp"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Phil on 18/4/2013.
|
* Created by Phil on 10/2/2014.
|
||||||
* Copyright 2013 Two Blue Cubes Ltd. All rights reserved.
|
* Copyright 2014 Two Blue Cubes Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
@ -10,52 +10,15 @@
|
|||||||
|
|
||||||
#include "catch_config.hpp"
|
#include "catch_config.hpp"
|
||||||
|
|
||||||
#include <string>
|
#define TBC_TEXT_FORMAT_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH
|
||||||
#include <vector>
|
|
||||||
|
#define CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE Catch
|
||||||
|
#include "tbc_text_format.h"
|
||||||
|
#undef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
using Tbc::Text;
|
||||||
struct TextAttributes {
|
using Tbc::TextAttributes;
|
||||||
TextAttributes()
|
}
|
||||||
: initialIndent( std::string::npos ),
|
|
||||||
indent( 0 ),
|
|
||||||
width( CATCH_CONFIG_CONSOLE_WIDTH-1 ),
|
|
||||||
tabChar( '\t' )
|
|
||||||
{}
|
|
||||||
|
|
||||||
TextAttributes& setInitialIndent( std::size_t _value ) { initialIndent = _value; return *this; }
|
|
||||||
TextAttributes& setIndent( std::size_t _value ) { indent = _value; return *this; }
|
|
||||||
TextAttributes& setWidth( std::size_t _value ) { width = _value; return *this; }
|
|
||||||
TextAttributes& setTabChar( char _value ) { tabChar = _value; return *this; }
|
|
||||||
|
|
||||||
std::size_t initialIndent; // indent of first line, or npos
|
|
||||||
std::size_t indent; // indent of subsequent lines, or all if initialIndent is npos
|
|
||||||
std::size_t width; // maximum width of text, including indent. Longer text will wrap
|
|
||||||
char tabChar; // If this char is seen the indent is changed to current pos
|
|
||||||
};
|
|
||||||
|
|
||||||
class Text {
|
|
||||||
public:
|
|
||||||
Text( std::string const& _str, TextAttributes const& _attr = TextAttributes() );
|
|
||||||
void spliceLine( std::size_t _indent, std::string& _remainder, std::size_t _pos );
|
|
||||||
|
|
||||||
typedef std::vector<std::string>::const_iterator const_iterator;
|
|
||||||
|
|
||||||
const_iterator begin() const { return lines.begin(); }
|
|
||||||
const_iterator end() const { return lines.end(); }
|
|
||||||
std::string const& last() const { return lines.back(); }
|
|
||||||
std::size_t size() const { return lines.size(); }
|
|
||||||
std::string const& operator[]( std::size_t _index ) const { return lines[_index]; }
|
|
||||||
std::string toString() const;
|
|
||||||
|
|
||||||
friend std::ostream& operator << ( std::ostream& _stream, Text const& _text );
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string str;
|
|
||||||
TextAttributes attr;
|
|
||||||
std::vector<std::string> lines;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace Catch
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_TEXT_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_TEXT_H_INCLUDED
|
||||||
|
@ -1,95 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 20/4/2013.
|
|
||||||
* Copyright 2013 Two Blue Cubes Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
*/
|
|
||||||
#ifndef TWOBLUECUBES_CATCH_TEXT_HPP_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_TEXT_HPP_INCLUDED
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
INTERNAL_CATCH_INLINE Text::Text( std::string const& _str, TextAttributes const& _attr )
|
|
||||||
: attr( _attr )
|
|
||||||
{
|
|
||||||
std::string wrappableChars = " [({.,/|\\-";
|
|
||||||
std::size_t indent = _attr.initialIndent != std::string::npos
|
|
||||||
? _attr.initialIndent
|
|
||||||
: _attr.indent;
|
|
||||||
std::string remainder = _str;
|
|
||||||
|
|
||||||
while( !remainder.empty() ) {
|
|
||||||
if( lines.size() >= 1000 ) {
|
|
||||||
lines.push_back( "... message truncated due to excessive size" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::size_t tabPos = std::string::npos;
|
|
||||||
std::size_t width = (std::min)( remainder.size(), _attr.width - indent );
|
|
||||||
std::size_t pos = remainder.find_first_of( '\n' );
|
|
||||||
if( pos <= width ) {
|
|
||||||
width = pos;
|
|
||||||
}
|
|
||||||
pos = remainder.find_last_of( _attr.tabChar, width );
|
|
||||||
if( pos != std::string::npos ) {
|
|
||||||
tabPos = pos;
|
|
||||||
if( remainder[width] == '\n' )
|
|
||||||
width--;
|
|
||||||
remainder = remainder.substr( 0, tabPos ) + remainder.substr( tabPos+1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( width == remainder.size() ) {
|
|
||||||
spliceLine( indent, remainder, width );
|
|
||||||
}
|
|
||||||
else if( remainder[width] == '\n' ) {
|
|
||||||
spliceLine( indent, remainder, width );
|
|
||||||
if( width <= 1 || remainder.size() != 1 )
|
|
||||||
remainder = remainder.substr( 1 );
|
|
||||||
indent = _attr.indent;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
pos = remainder.find_last_of( wrappableChars, width );
|
|
||||||
if( pos != std::string::npos && pos > 0 ) {
|
|
||||||
spliceLine( indent, remainder, pos );
|
|
||||||
if( remainder[0] == ' ' )
|
|
||||||
remainder = remainder.substr( 1 );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
spliceLine( indent, remainder, width-1 );
|
|
||||||
lines.back() += "-";
|
|
||||||
}
|
|
||||||
if( lines.size() == 1 )
|
|
||||||
indent = _attr.indent;
|
|
||||||
if( tabPos != std::string::npos )
|
|
||||||
indent += tabPos;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
INTERNAL_CATCH_INLINE void Text::spliceLine( std::size_t _indent, std::string& _remainder, std::size_t _pos ) {
|
|
||||||
lines.push_back( std::string( _indent, ' ' ) + _remainder.substr( 0, _pos ) );
|
|
||||||
_remainder = _remainder.substr( _pos );
|
|
||||||
}
|
|
||||||
|
|
||||||
INTERNAL_CATCH_INLINE std::string Text::toString() const {
|
|
||||||
std::ostringstream oss;
|
|
||||||
oss << *this;
|
|
||||||
return oss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
INTERNAL_CATCH_INLINE std::ostream& operator << ( std::ostream& _stream, Text const& _text ) {
|
|
||||||
for( Text::const_iterator it = _text.begin(), itEnd = _text.end();
|
|
||||||
it != itEnd; ++it ) {
|
|
||||||
if( it != _text.begin() )
|
|
||||||
_stream << "\n";
|
|
||||||
_stream << *it;
|
|
||||||
}
|
|
||||||
return _stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace Catch
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_TEXT_HPP_INCLUDED
|
|
@ -14,7 +14,7 @@ namespace Catch {
|
|||||||
|
|
||||||
// These numbers are maintained by a script
|
// These numbers are maintained by a script
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const T LibraryVersionInfo<T>::value( 1, 0, 25, "master" );
|
const T LibraryVersionInfo<T>::value( 1, 0, 26, "master" );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
|
||||||
|
@ -463,8 +463,6 @@ private:
|
|||||||
#include "catch_assertionresult.hpp"
|
#include "catch_assertionresult.hpp"
|
||||||
#include "catch_expressionresult_builder.hpp"
|
#include "catch_expressionresult_builder.hpp"
|
||||||
#include "catch_version.hpp"
|
#include "catch_version.hpp"
|
||||||
#include "catch_text.h"
|
|
||||||
#include "catch_text.hpp"
|
|
||||||
#include "catch_runner_impl.hpp"
|
#include "catch_runner_impl.hpp"
|
||||||
#include "catch_message.hpp"
|
#include "catch_message.hpp"
|
||||||
#include "catch_context_impl.hpp"
|
#include "catch_context_impl.hpp"
|
||||||
|
@ -5,13 +5,48 @@
|
|||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
#ifndef TWOBLUECUBES_CLARA_H_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CLARA_H_INCLUDED
|
|
||||||
|
|
||||||
#include "catch_text.h" // This will get moved out too
|
// Only use header guard if we are not using an outer namespace
|
||||||
|
#ifndef CLICHE_CLARA_OUTER_NAMESPACE
|
||||||
|
# ifdef TWOBLUECUBES_CLARA_H_INCLUDED
|
||||||
|
# ifndef TWOBLUECUBES_CLARA_H_ALREADY_INCLUDED
|
||||||
|
# define TWOBLUECUBES_CLARA_H_ALREADY_INCLUDED
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# define TWOBLUECUBES_CLARA_H_INCLUDED
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef TWOBLUECUBES_CLARA_H_ALREADY_INCLUDED
|
||||||
|
|
||||||
|
#ifndef CLICHE_CLARA_OUTER_NAMESPACE
|
||||||
|
#define CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE Clara
|
||||||
|
#include "tbc_text_format.h"
|
||||||
|
#undef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
// Use optional outer namespace
|
||||||
|
#ifdef CLICHE_CLARA_OUTER_NAMESPACE
|
||||||
|
namespace CLICHE_CLARA_OUTER_NAMESPACE {
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Clara {
|
namespace Clara {
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
|
|
||||||
|
#ifdef CLARA_CONSOLE_WIDTH
|
||||||
|
const unsigned int consoleWidth = CLARA_CONFIG_CONSOLE_WIDTH;
|
||||||
|
#else
|
||||||
|
const unsigned int consoleWidth = 80;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace Tbc;
|
||||||
|
|
||||||
template<typename T> struct RemoveConstRef{ typedef T type; };
|
template<typename T> struct RemoveConstRef{ typedef T type; };
|
||||||
template<typename T> struct RemoveConstRef<T&>{ typedef T type; };
|
template<typename T> struct RemoveConstRef<T&>{ typedef T type; };
|
||||||
template<typename T> struct RemoveConstRef<T const&>{ typedef T type; };
|
template<typename T> struct RemoveConstRef<T const&>{ typedef T type; };
|
||||||
@ -401,18 +436,18 @@ namespace Clara {
|
|||||||
m_boundProcessName = Detail::makeBoundField( f );
|
m_boundProcessName = Detail::makeBoundField( f );
|
||||||
}
|
}
|
||||||
|
|
||||||
void optUsage( std::ostream& os, std::size_t indent = 0, std::size_t width = CATCH_CONFIG_CONSOLE_WIDTH ) const {
|
void optUsage( std::ostream& os, std::size_t indent = 0, std::size_t width = Detail::consoleWidth ) const {
|
||||||
typename std::vector<Arg>::const_iterator itBegin = m_options.begin(), itEnd = m_options.end(), it;
|
typename std::vector<Arg>::const_iterator itBegin = m_options.begin(), itEnd = m_options.end(), it;
|
||||||
std::size_t maxWidth = 0;
|
std::size_t maxWidth = 0;
|
||||||
for( it = itBegin; it != itEnd; ++it )
|
for( it = itBegin; it != itEnd; ++it )
|
||||||
maxWidth = (std::max)( maxWidth, it->commands().size() );
|
maxWidth = (std::max)( maxWidth, it->commands().size() );
|
||||||
|
|
||||||
for( it = itBegin; it != itEnd; ++it ) {
|
for( it = itBegin; it != itEnd; ++it ) {
|
||||||
Catch::Text usage( it->commands(), Catch::TextAttributes()
|
Detail::Text usage( it->commands(), Detail::TextAttributes()
|
||||||
.setWidth( maxWidth+indent )
|
.setWidth( maxWidth+indent )
|
||||||
.setIndent( indent ) );
|
.setIndent( indent ) );
|
||||||
// !TBD handle longer usage strings
|
// !TBD handle longer usage strings
|
||||||
Catch::Text desc( it->description, Catch::TextAttributes()
|
Detail::Text desc( it->description, Detail::TextAttributes()
|
||||||
.setWidth( width - maxWidth -3 ) );
|
.setWidth( width - maxWidth -3 ) );
|
||||||
|
|
||||||
for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) {
|
for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) {
|
||||||
@ -582,5 +617,9 @@ namespace Clara {
|
|||||||
|
|
||||||
} // end namespace Clara
|
} // end namespace Clara
|
||||||
|
|
||||||
|
#ifdef CLICHE_CLARA_OUTER_NAMESPACE
|
||||||
|
} // end outer namespace
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // TWOBLUECUBES_CLARA_H_ALREADY_INCLUDED
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CLARA_H_INCLUDED
|
|
||||||
|
153
include/internal/tbc_text_format.h
Normal file
153
include/internal/tbc_text_format.h
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 18/4/2013.
|
||||||
|
* Copyright 2013 Two Blue Cubes Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
// Only use header guard if we are not using an outer namespace
|
||||||
|
#ifndef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
|
||||||
|
# ifdef TWOBLUECUBES_TEXT_FORMAT_H_INCLUDED
|
||||||
|
# ifndef TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED
|
||||||
|
# define TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# define TWOBLUECUBES_TEXT_FORMAT_H_INCLUDED
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
// Use optional outer namespace
|
||||||
|
#ifdef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
|
||||||
|
namespace CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace Tbc {
|
||||||
|
|
||||||
|
#ifdef TBC_TEXT_FORMAT_CONSOLE_WIDTH
|
||||||
|
const unsigned int consoleWidth = TBC_TEXT_FORMAT_CONSOLE_WIDTH;
|
||||||
|
#else
|
||||||
|
const unsigned int consoleWidth = 80;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct TextAttributes {
|
||||||
|
TextAttributes()
|
||||||
|
: initialIndent( std::string::npos ),
|
||||||
|
indent( 0 ),
|
||||||
|
width( consoleWidth-1 ),
|
||||||
|
tabChar( '\t' )
|
||||||
|
{}
|
||||||
|
|
||||||
|
TextAttributes& setInitialIndent( std::size_t _value ) { initialIndent = _value; return *this; }
|
||||||
|
TextAttributes& setIndent( std::size_t _value ) { indent = _value; return *this; }
|
||||||
|
TextAttributes& setWidth( std::size_t _value ) { width = _value; return *this; }
|
||||||
|
TextAttributes& setTabChar( char _value ) { tabChar = _value; return *this; }
|
||||||
|
|
||||||
|
std::size_t initialIndent; // indent of first line, or npos
|
||||||
|
std::size_t indent; // indent of subsequent lines, or all if initialIndent is npos
|
||||||
|
std::size_t width; // maximum width of text, including indent. Longer text will wrap
|
||||||
|
char tabChar; // If this char is seen the indent is changed to current pos
|
||||||
|
};
|
||||||
|
|
||||||
|
class Text {
|
||||||
|
public:
|
||||||
|
Text( std::string const& _str, TextAttributes const& _attr = TextAttributes() )
|
||||||
|
: attr( _attr )
|
||||||
|
{
|
||||||
|
std::string wrappableChars = " [({.,/|\\-";
|
||||||
|
std::size_t indent = _attr.initialIndent != std::string::npos
|
||||||
|
? _attr.initialIndent
|
||||||
|
: _attr.indent;
|
||||||
|
std::string remainder = _str;
|
||||||
|
|
||||||
|
while( !remainder.empty() ) {
|
||||||
|
if( lines.size() >= 1000 ) {
|
||||||
|
lines.push_back( "... message truncated due to excessive size" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::size_t tabPos = std::string::npos;
|
||||||
|
std::size_t width = (std::min)( remainder.size(), _attr.width - indent );
|
||||||
|
std::size_t pos = remainder.find_first_of( '\n' );
|
||||||
|
if( pos <= width ) {
|
||||||
|
width = pos;
|
||||||
|
}
|
||||||
|
pos = remainder.find_last_of( _attr.tabChar, width );
|
||||||
|
if( pos != std::string::npos ) {
|
||||||
|
tabPos = pos;
|
||||||
|
if( remainder[width] == '\n' )
|
||||||
|
width--;
|
||||||
|
remainder = remainder.substr( 0, tabPos ) + remainder.substr( tabPos+1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( width == remainder.size() ) {
|
||||||
|
spliceLine( indent, remainder, width );
|
||||||
|
}
|
||||||
|
else if( remainder[width] == '\n' ) {
|
||||||
|
spliceLine( indent, remainder, width );
|
||||||
|
if( width <= 1 || remainder.size() != 1 )
|
||||||
|
remainder = remainder.substr( 1 );
|
||||||
|
indent = _attr.indent;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pos = remainder.find_last_of( wrappableChars, width );
|
||||||
|
if( pos != std::string::npos && pos > 0 ) {
|
||||||
|
spliceLine( indent, remainder, pos );
|
||||||
|
if( remainder[0] == ' ' )
|
||||||
|
remainder = remainder.substr( 1 );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
spliceLine( indent, remainder, width-1 );
|
||||||
|
lines.back() += "-";
|
||||||
|
}
|
||||||
|
if( lines.size() == 1 )
|
||||||
|
indent = _attr.indent;
|
||||||
|
if( tabPos != std::string::npos )
|
||||||
|
indent += tabPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void spliceLine( std::size_t _indent, std::string& _remainder, std::size_t _pos ) {
|
||||||
|
lines.push_back( std::string( _indent, ' ' ) + _remainder.substr( 0, _pos ) );
|
||||||
|
_remainder = _remainder.substr( _pos );
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef std::vector<std::string>::const_iterator const_iterator;
|
||||||
|
|
||||||
|
const_iterator begin() const { return lines.begin(); }
|
||||||
|
const_iterator end() const { return lines.end(); }
|
||||||
|
std::string const& last() const { return lines.back(); }
|
||||||
|
std::size_t size() const { return lines.size(); }
|
||||||
|
std::string const& operator[]( std::size_t _index ) const { return lines[_index]; }
|
||||||
|
std::string toString() const {
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << *this;
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) {
|
||||||
|
for( Text::const_iterator it = _text.begin(), itEnd = _text.end();
|
||||||
|
it != itEnd; ++it ) {
|
||||||
|
if( it != _text.begin() )
|
||||||
|
_stream << "\n";
|
||||||
|
_stream << *it;
|
||||||
|
}
|
||||||
|
return _stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string str;
|
||||||
|
TextAttributes attr;
|
||||||
|
std::vector<std::string> lines;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end namespace Tbc
|
||||||
|
|
||||||
|
#ifdef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
|
||||||
|
} // end outer namespace
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED
|
@ -99,6 +99,8 @@ namespace Catch {
|
|||||||
return node->stats.sectionInfo.lineInfo == m_other.lineInfo;
|
return node->stats.sectionInfo.lineInfo == m_other.lineInfo;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
BySectionInfo& operator=( BySectionInfo const& other ); // = delete;
|
||||||
|
|
||||||
SectionInfo const& m_other;
|
SectionInfo const& m_other;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#pragma clang diagnostic ignored "-Wpadded"
|
#pragma clang diagnostic ignored "-Wpadded"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "internal/clara.h"
|
#include "internal/clara.h" // This will does not declare Clara within the Catch namespace
|
||||||
|
|
||||||
#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
template<size_t size>
|
template<size_t size>
|
||||||
void parseIntoConfig( const char * (&argv)[size], Catch::ConfigData& config ) {
|
void parseIntoConfig( const char * (&argv)[size], Catch::ConfigData& config ) {
|
||||||
Clara::CommandLine<Catch::ConfigData> parser = Catch::makeCommandLineParser();
|
Catch::Clara::CommandLine<Catch::ConfigData> parser = Catch::makeCommandLineParser();
|
||||||
parser.parseInto( size, argv, config );
|
parser.parseInto( size, argv, config );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
SOURCES = ApproxTests.cpp \
|
SOURCES = ApproxTests.cpp \
|
||||||
|
BDDTests.cpp \
|
||||||
ClassTests.cpp \
|
ClassTests.cpp \
|
||||||
|
CmdLineTests.cpp \
|
||||||
ConditionTests.cpp \
|
ConditionTests.cpp \
|
||||||
ExceptionTests.cpp \
|
ExceptionTests.cpp \
|
||||||
GeneratorTests.cpp \
|
GeneratorTests.cpp \
|
||||||
@ -7,7 +9,6 @@ SOURCES = ApproxTests.cpp \
|
|||||||
MiscTests.cpp \
|
MiscTests.cpp \
|
||||||
TestMain.cpp \
|
TestMain.cpp \
|
||||||
TrickyTests.cpp \
|
TrickyTests.cpp \
|
||||||
BDDTests.cpp \
|
|
||||||
VariadicMacrosTests.cpp
|
VariadicMacrosTests.cpp
|
||||||
OBJECTS = $(patsubst %.cpp, %.o, $(SOURCES))
|
OBJECTS = $(patsubst %.cpp, %.o, $(SOURCES))
|
||||||
CXX = g++
|
CXX = g++
|
||||||
|
@ -77,6 +77,8 @@
|
|||||||
26847E5B16BBAB790043B9C1 /* catch_message.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_message.h; sourceTree = "<group>"; };
|
26847E5B16BBAB790043B9C1 /* catch_message.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_message.h; sourceTree = "<group>"; };
|
||||||
26847E5C16BBACB60043B9C1 /* catch_message.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_message.hpp; sourceTree = "<group>"; };
|
26847E5C16BBACB60043B9C1 /* catch_message.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_message.hpp; sourceTree = "<group>"; };
|
||||||
26847E5D16BBADB40043B9C1 /* catch_message.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_message.cpp; path = ../../../SelfTest/SurrogateCpps/catch_message.cpp; sourceTree = "<group>"; };
|
26847E5D16BBADB40043B9C1 /* catch_message.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_message.cpp; path = ../../../SelfTest/SurrogateCpps/catch_message.cpp; sourceTree = "<group>"; };
|
||||||
|
268F47B018A93F7800D8C14F /* catch_clara.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_clara.h; sourceTree = "<group>"; };
|
||||||
|
268F47B118A944DB00D8C14F /* tbc_text_format.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = tbc_text_format.h; path = ../../../../include/internal/tbc_text_format.h; sourceTree = "<group>"; };
|
||||||
26948284179A9AB900ED166E /* SectionTrackerTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SectionTrackerTests.cpp; path = ../../../SelfTest/SectionTrackerTests.cpp; sourceTree = "<group>"; };
|
26948284179A9AB900ED166E /* SectionTrackerTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SectionTrackerTests.cpp; path = ../../../SelfTest/SectionTrackerTests.cpp; sourceTree = "<group>"; };
|
||||||
26948287179EF7F900ED166E /* catch_test_case_tracker.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_test_case_tracker.hpp; sourceTree = "<group>"; };
|
26948287179EF7F900ED166E /* catch_test_case_tracker.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_test_case_tracker.hpp; sourceTree = "<group>"; };
|
||||||
2694A1FB16A0000E004816E3 /* catch_text.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = catch_text.cpp; sourceTree = "<group>"; };
|
2694A1FB16A0000E004816E3 /* catch_text.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = catch_text.cpp; sourceTree = "<group>"; };
|
||||||
@ -201,6 +203,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
26C5F3EC17514B970056FB3C /* clara.h */,
|
26C5F3EC17514B970056FB3C /* clara.h */,
|
||||||
|
268F47B118A944DB00D8C14F /* tbc_text_format.h */,
|
||||||
);
|
);
|
||||||
name = External;
|
name = External;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -438,6 +441,7 @@
|
|||||||
26AEAF1617BEA18E009E32C9 /* catch_platform.h */,
|
26AEAF1617BEA18E009E32C9 /* catch_platform.h */,
|
||||||
262E739A1846759000CAC268 /* catch_common.hpp */,
|
262E739A1846759000CAC268 /* catch_common.hpp */,
|
||||||
261488FC184D1DC10041FBEB /* catch_stream.h */,
|
261488FC184D1DC10041FBEB /* catch_stream.h */,
|
||||||
|
268F47B018A93F7800D8C14F /* catch_clara.h */,
|
||||||
);
|
);
|
||||||
name = Infrastructure;
|
name = Infrastructure;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -128,7 +128,7 @@
|
|||||||
4A90B5CD15D2E3E900EF71BC /* Project object */ = {
|
4A90B5CD15D2E3E900EF71BC /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
LastUpgradeCheck = 0440;
|
LastUpgradeCheck = 0500;
|
||||||
ORGANIZATIONNAME = "Phil Nash";
|
ORGANIZATIONNAME = "Phil Nash";
|
||||||
};
|
};
|
||||||
buildConfigurationList = 4A90B5D015D2E3E900EF71BC /* Build configuration list for PBXProject "CatchSelfTestSingle" */;
|
buildConfigurationList = 4A90B5D015D2E3E900EF71BC /* Build configuration list for PBXProject "CatchSelfTestSingle" */;
|
||||||
@ -172,7 +172,6 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
@ -199,7 +198,6 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
COPY_PHASE_STRIP = YES;
|
COPY_PHASE_STRIP = YES;
|
||||||
|
@ -8,10 +8,10 @@ from scriptCommon import catchPath
|
|||||||
|
|
||||||
versionParser = re.compile( r'(\s*const\sT\sLibraryVersionInfo<T>::value)\s*\(\s*(.*)\s*,\s*(.*)\s*,\s*(.*)\s*,\s*\"(.*)\"\s*\).*' )
|
versionParser = re.compile( r'(\s*const\sT\sLibraryVersionInfo<T>::value)\s*\(\s*(.*)\s*,\s*(.*)\s*,\s*(.*)\s*,\s*\"(.*)\"\s*\).*' )
|
||||||
includesParser = re.compile( r'\s*#include\s*"(.*)"' )
|
includesParser = re.compile( r'\s*#include\s*"(.*)"' )
|
||||||
guardParser = re.compile( r'\s*#.*_INCLUDED')
|
guardParser = re.compile( r'\s*#.*TWOBLUECUBES_CATCH_.*_INCLUDED')
|
||||||
defineParser = re.compile( r'\s*#define')
|
defineParser = re.compile( r'\s*#define')
|
||||||
ifParser = re.compile( r'\s*#if')
|
ifParser = re.compile( r'\s*#ifndef TWOBLUECUBES_CATCH_.*_INCLUDED')
|
||||||
endIfParser = re.compile( r'\s*#endif')
|
endIfParser = re.compile( r'\s*#endif // TWOBLUECUBES_CATCH_.*_INCLUDED')
|
||||||
ifImplParser = re.compile( r'\s*#if.*(CATCH_CONFIG_MAIN|CATCH_CONFIG_RUNNER)')
|
ifImplParser = re.compile( r'\s*#if.*(CATCH_CONFIG_MAIN|CATCH_CONFIG_RUNNER)')
|
||||||
commentParser1 = re.compile( r'^\s*/\*')
|
commentParser1 = re.compile( r'^\s*/\*')
|
||||||
commentParser2 = re.compile( r'^\s*\*')
|
commentParser2 = re.compile( r'^\s*\*')
|
||||||
@ -62,6 +62,7 @@ def parseFile( path, filename ):
|
|||||||
header = m.group(1)
|
header = m.group(1)
|
||||||
headerPath, sep, headerFile = header.rpartition( "/" )
|
headerPath, sep, headerFile = header.rpartition( "/" )
|
||||||
if not headerFile in seenHeaders:
|
if not headerFile in seenHeaders:
|
||||||
|
if headerFile != "tbc_text_format.h" and headerFile != "clara.h":
|
||||||
seenHeaders.add( headerFile )
|
seenHeaders.add( headerFile )
|
||||||
write( "// #included from: {0}\n".format( header ) )
|
write( "// #included from: {0}\n".format( header ) )
|
||||||
if( headerPath == "internal" and path.endswith( "internal/" ) ):
|
if( headerPath == "internal" and path.endswith( "internal/" ) ):
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user