mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 23:36:11 +01:00
4746caacaf
- use this to wrap Given/ When/ Then with indent after the :
59 lines
1.8 KiB
C++
59 lines
1.8 KiB
C++
/*
|
|
* Created by Phil on 11/1/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_LINE_WRAP_H_INCLUDED
|
|
#define TWOBLUECUBES_CATCH_LINE_WRAP_H_INCLUDED
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace Catch {
|
|
|
|
class LineWrapper {
|
|
public:
|
|
LineWrapper();
|
|
|
|
LineWrapper& setIndent( std::size_t _indent );
|
|
LineWrapper& setInitialIndent( std::size_t _initalIndent );
|
|
LineWrapper& setRight( std::size_t _right );
|
|
LineWrapper& setTabChar( char _tabChar );
|
|
|
|
LineWrapper& wrap( std::string const& _str );
|
|
|
|
std::string toString() const;
|
|
|
|
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]; }
|
|
|
|
friend std::ostream& operator << ( std::ostream& _stream, LineWrapper const& _lineWrapper );
|
|
|
|
private:
|
|
void wrapInternal( std::string const& _str );
|
|
void addLine( const std::string& _line );
|
|
bool isWrapPoint( char c );
|
|
std::size_t getCurrentIndent() const;
|
|
|
|
std::size_t right;
|
|
std::size_t nextTab;
|
|
std::size_t tab;
|
|
std::size_t indent;
|
|
std::size_t initialIndent;
|
|
std::string wrappableChars;
|
|
char tabChar;
|
|
int recursionCount;
|
|
std::vector<std::string> lines;
|
|
};
|
|
|
|
} // end namespace Catch
|
|
|
|
#endif // TWOBLUECUBES_CATCH_LINE_WRAP_H_INCLUDED
|