Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Removed tbc_text_format (superceded by TextFlow)

Commit
3a37f45a97276b3450f8fb86811f590fc1abf1b7
Author
Phil Nash ·
Parents
6ec7709e07f8

Files · Download .tar.gz

Changes

 include/catch_session.hpp                     |   3 +-
 include/external/tbc_text_format.h            | 179 --------------------------
 include/internal/catch_list.cpp               |   4 +-
 include/internal/catch_text.h                 |  11 +-
 include/reporters/catch_reporter_console.cpp  |   4 +-
 include/reporters/catch_reporter_teamcity.hpp |   2 -
 6 files changed, 5 insertions(+), 198 deletions(-)

diff --git a/include/catch_session.hpp b/include/catch_session.hpp
index 05ebff47..e9a4aade 100644
--- a/include/catch_session.hpp
+++ b/include/catch_session.hpp
@@ -16,6 +16,7 @@
 #include "internal/catch_version.h"
 #include "internal/catch_interfaces_reporter.h"
 #include "internal/catch_startup_exception_registry.h"
+#include "internal/catch_text.h"
 
 #include <fstream>
 #include <cstdlib>
@@ -23,8 +24,6 @@
 
 namespace Catch {
 
-    using namespace clara::TextFlow;
-
     IStreamingReporterPtr createReporter( std::string const& reporterName, IConfigPtr const& config ) {
         auto reporter = getRegistryHub().getReporterRegistry().create( reporterName, config );
         CATCH_ENFORCE( reporter, "No reporter registered with name: '" << reporterName << "'" );
diff --git a/include/external/tbc_text_format.h b/include/external/tbc_text_format.h
deleted file mode 100644
index d6c06c2c..00000000
--- a/include/external/tbc_text_format.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- *  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 )
-        {}
-
-        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; }
-
-        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
-    };
-
-    class Text {
-    public:
-        Text( std::string const& _str, TextAttributes const& _attr = TextAttributes() )
-        : attr( _attr )
-        {
-            init( _str );
-        }
-
-        template<typename T>
-        Text( T const& _val, TextAttributes const& _attr = TextAttributes() )
-        : attr( _attr )
-        {
-            std::ostringstream oss;
-            oss << _val;
-            init( oss.str() );
-        }
-
-        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:
-        TextAttributes attr;
-        std::vector<std::string> lines;
-
-        void init( std::string const& _str )
-        {
-            const std::string wrappableBeforeChars = "[({<\t";
-            const std::string wrappableAfterChars = "])}>-,./|\\";
-            const std::string wrappableInsteadOfChars = " \n\r";
-            std::string indent = attr.initialIndent != std::string::npos
-                ? std::string( attr.initialIndent, ' ' )
-                : std::string( attr.indent, ' ' );
-
-            typedef std::string::const_iterator iterator;
-            iterator it = _str.begin();
-            const iterator strEnd = _str.end();
-
-            while( it != strEnd ) {
-
-                if( lines.size() >= 1000 ) {
-                    lines.push_back( "... message truncated due to excessive size" );
-                    return;
-                }
-
-
-                std::string suffix;
-                std::size_t width = (std::min)( static_cast<size_t>( strEnd-it ), attr.width-static_cast<size_t>( indent.size() ) );
-                iterator itEnd = it+width;
-                iterator itNext = _str.end();
-
-                iterator itNewLine = std::find( it, itEnd, '\n' );
-                if( itNewLine != itEnd )
-                    itEnd = itNewLine;
-
-                if( itEnd != strEnd  ) {
-                    bool foundWrapPoint = false;
-                    iterator findIt = itEnd;
-                    do {
-                        if( wrappableAfterChars.find( *findIt ) != std::string::npos && findIt != itEnd ) {
-                            itEnd = findIt+1;
-                            itNext = findIt+1;
-                            foundWrapPoint = true;
-                        }
-                        else if( findIt > it && wrappableBeforeChars.find( *findIt ) != std::string::npos ) {
-                            itEnd = findIt;
-                            itNext = findIt;
-                            foundWrapPoint = true;
-                        }
-                        else if( wrappableInsteadOfChars.find( *findIt ) != std::string::npos ) {
-                            itNext = findIt+1;
-                            itEnd = findIt;
-                            foundWrapPoint = true;
-                        }
-                        if( findIt == it )
-                            break;
-                        else
-                            --findIt;
-                    }
-                    while( !foundWrapPoint );
-
-                    if( !foundWrapPoint ) {
-                        // No good wrap char, so we'll break mid word and add a hyphen
-                        --itEnd;
-                        itNext = itEnd;
-                        suffix = "-";
-                    }
-                    else {
-                        while( itEnd > it && wrappableInsteadOfChars.find( *(itEnd-1) ) != std::string::npos )
-                            --itEnd;
-                    }
-                }
-                lines.push_back( indent + std::string( it, itEnd ) + suffix );
-
-                if( indent.size() != attr.indent )
-                    indent = std::string( attr.indent, ' ' );
-                it = itNext;
-            }
-        }
-    };
-
-} // end namespace Tbc
-
-#ifdef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
-} // end outer namespace
-#endif
-
-#endif // TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED
\ No newline at end of file
diff --git a/include/internal/catch_list.cpp b/include/internal/catch_list.cpp
index c7e90693..84b58ac7 100644
--- a/include/internal/catch_list.cpp
+++ b/include/internal/catch_list.cpp
@@ -12,7 +12,7 @@
 #include "catch_interfaces_reporter.h"
 #include "catch_interfaces_testcase.h"
 
-#include "catch_clara.h" // For TextFlow
+#include "internal/catch_text.h"
 
 #include "catch_console_colour.hpp"
 #include "catch_test_spec_parser.hpp"
@@ -24,8 +24,6 @@
 
 namespace Catch {
 
-    using namespace clara::TextFlow;
-
     std::size_t listTests( Config const& config ) {
         TestSpec testSpec = config.testSpec();
         if( config.testSpec().hasFilters() )
diff --git a/include/internal/catch_text.h b/include/internal/catch_text.h
index b66751f3..eeafe8e2 100644
--- a/include/internal/catch_text.h
+++ b/include/internal/catch_text.h
@@ -8,17 +8,10 @@
 #ifndef TWOBLUECUBES_CATCH_TEXT_H_INCLUDED
 #define TWOBLUECUBES_CATCH_TEXT_H_INCLUDED
 
-#include "catch_config.hpp"
-
-#define TBC_TEXT_FORMAT_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH
-
-#define CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE Catch
-#include "../external/tbc_text_format.h"
-#undef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
+#include "catch_clara.h"
 
 namespace Catch {
-    using Tbc::Text;
-    using Tbc::TextAttributes;
+    using namespace clara::TextFlow;
 }
 
 #endif // TWOBLUECUBES_CATCH_TEXT_H_INCLUDED
diff --git a/include/reporters/catch_reporter_console.cpp b/include/reporters/catch_reporter_console.cpp
index b70df425..e6f7adc8 100644
--- a/include/reporters/catch_reporter_console.cpp
+++ b/include/reporters/catch_reporter_console.cpp
@@ -11,15 +11,13 @@
 #include "../internal/catch_reporter_registrars.hpp"
 #include "../internal/catch_console_colour.hpp"
 #include "../internal/catch_version.h"
-#include "../internal/catch_clara.h" // For TextFlow
+#include "../internal/catch_text.h"
 
 #include <cfloat>
 #include <cstdio>
 
 namespace Catch {
 
-    using namespace clara::TextFlow;
-
     struct ConsoleReporter : StreamingReporterBase<ConsoleReporter> {
         using StreamingReporterBase::StreamingReporterBase;
 
diff --git a/include/reporters/catch_reporter_teamcity.hpp b/include/reporters/catch_reporter_teamcity.hpp
index c9280a69..cb043022 100644
--- a/include/reporters/catch_reporter_teamcity.hpp
+++ b/include/reporters/catch_reporter_teamcity.hpp
@@ -23,8 +23,6 @@
 
 namespace Catch {
 
-    using namespace clara::TextFlow;
-
     struct TeamCityReporter : StreamingReporterBase<TeamCityReporter> {
         TeamCityReporter( ReporterConfig const& _config )
         :   StreamingReporterBase( _config )