Update Clara to v1.1.5 to fix TextFlow bugs

This commit is contained in:
Martin Hořeňovský 2018-10-26 18:48:28 +02:00
parent 544c7d7cbf
commit 779e83bc20
3 changed files with 290 additions and 272 deletions

View File

@ -5,7 +5,7 @@
// //
// See https://github.com/philsquared/Clara for more details // See https://github.com/philsquared/Clara for more details
// Clara v1.1.4 // Clara v1.1.5
#ifndef CATCH_CLARA_HPP_INCLUDED #ifndef CATCH_CLARA_HPP_INCLUDED
#define CATCH_CLARA_HPP_INCLUDED #define CATCH_CLARA_HPP_INCLUDED
@ -34,8 +34,8 @@
// //
// A single-header library for wrapping and laying out basic text, by Phil Nash // A single-header library for wrapping and laying out basic text, by Phil Nash
// //
// This work is licensed under the BSD 2-Clause license. // Distributed under the Boost Software License, Version 1.0. (See accompanying
// See the accompanying LICENSE file, or the one at https://opensource.org/licenses/BSD-2-Clause // file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// //
// This project is hosted at https://github.com/philsquared/textflowcpp // This project is hosted at https://github.com/philsquared/textflowcpp
@ -52,7 +52,9 @@
#endif #endif
namespace Catch { namespace clara { namespace TextFlow { namespace Catch {
namespace clara {
namespace TextFlow {
inline auto isWhitespace(char c) -> bool { inline auto isWhitespace(char c) -> bool {
static std::string chars = " \t\n\r"; static std::string chars = " \t\n\r";
@ -89,8 +91,7 @@ namespace Catch { namespace clara { namespace TextFlow {
iterator(Column const& column, size_t stringIndex) iterator(Column const& column, size_t stringIndex)
: m_column(column), : m_column(column),
m_stringIndex( stringIndex ) m_stringIndex(stringIndex) {}
{}
auto line() const -> std::string const& { return m_column.m_strings[m_stringIndex]; } auto line() const -> std::string const& { return m_column.m_strings[m_stringIndex]; }
@ -115,8 +116,7 @@ namespace Catch { namespace clara { namespace TextFlow {
if (m_end < m_pos + width) { if (m_end < m_pos + width) {
m_len = m_end - m_pos; m_len = m_end - m_pos;
} } else {
else {
size_t len = width; size_t len = width;
while (len > 0 && !isBoundary(m_pos + len)) while (len > 0 && !isBoundary(m_pos + len))
--len; --len;
@ -142,6 +142,12 @@ namespace Catch { namespace clara { namespace TextFlow {
} }
public: public:
using difference_type = std::ptrdiff_t;
using value_type = std::string;
using pointer = value_type * ;
using reference = value_type & ;
using iterator_category = std::forward_iterator_tag;
explicit iterator(Column const& column) : m_column(column) { explicit iterator(Column const& column) : m_column(column) {
assert(m_column.m_width > m_column.m_indent); assert(m_column.m_width > m_column.m_indent);
assert(m_column.m_initialIndent == std::string::npos || m_column.m_width > m_column.m_initialIndent); assert(m_column.m_initialIndent == std::string::npos || m_column.m_width > m_column.m_initialIndent);
@ -153,10 +159,7 @@ namespace Catch { namespace clara { namespace TextFlow {
auto operator *() const -> std::string { auto operator *() const -> std::string {
assert(m_stringIndex < m_column.m_strings.size()); assert(m_stringIndex < m_column.m_strings.size());
assert(m_pos <= m_end); assert(m_pos <= m_end);
if( m_pos + m_column.m_width < m_end )
return addIndentAndSuffix(line().substr(m_pos, m_len)); return addIndentAndSuffix(line().substr(m_pos, m_len));
else
return addIndentAndSuffix(line().substr(m_pos, m_end - m_pos));
} }
auto operator ++() -> iterator& { auto operator ++() -> iterator& {
@ -257,8 +260,7 @@ namespace Catch { namespace clara { namespace TextFlow {
iterator(Columns const& columns, EndTag) iterator(Columns const& columns, EndTag)
: m_columns(columns.m_columns), : m_columns(columns.m_columns),
m_activeIterators( 0 ) m_activeIterators(0) {
{
m_iterators.reserve(m_columns.size()); m_iterators.reserve(m_columns.size());
for (auto const& col : m_columns) for (auto const& col : m_columns)
@ -266,10 +268,15 @@ namespace Catch { namespace clara { namespace TextFlow {
} }
public: public:
using difference_type = std::ptrdiff_t;
using value_type = std::string;
using pointer = value_type * ;
using reference = value_type & ;
using iterator_category = std::forward_iterator_tag;
explicit iterator(Columns const& columns) explicit iterator(Columns const& columns)
: m_columns(columns.m_columns), : m_columns(columns.m_columns),
m_activeIterators( m_columns.size() ) m_activeIterators(m_columns.size()) {
{
m_iterators.reserve(m_columns.size()); m_iterators.reserve(m_columns.size());
for (auto const& col : m_columns) for (auto const& col : m_columns)
@ -294,8 +301,7 @@ namespace Catch { namespace clara { namespace TextFlow {
padding = std::string(width - col.size(), ' '); padding = std::string(width - col.size(), ' ');
else else
padding = ""; padding = "";
} } else {
else {
padding += std::string(width, ' '); padding += std::string(width, ' ');
} }
} }
@ -355,14 +361,17 @@ namespace Catch { namespace clara { namespace TextFlow {
cols += other; cols += other;
return cols; return cols;
} }
}}} // namespace Catch::clara::TextFlow }
}
}
#endif // CATCH_CLARA_TEXTFLOW_HPP_INCLUDED #endif // CATCH_CLARA_TEXTFLOW_HPP_INCLUDED
// ----------- end of #include from clara_textflow.hpp ----------- // ----------- end of #include from clara_textflow.hpp -----------
// ........... back in clara.hpp // ........... back in clara.hpp
#include <string>
#include <memory> #include <memory>
#include <set> #include <set>
#include <algorithm> #include <algorithm>

View File

@ -6732,7 +6732,7 @@ Matchers.tests.cpp:<line number>:
PASSED: PASSED:
CHECK_THAT( testStringForMatching(), Contains("aBC", Catch::CaseSensitive::No) ) CHECK_THAT( testStringForMatching(), Contains("aBC", Catch::CaseSensitive::No) )
with expansion: with expansion:
"this string contains 'abc' as a substring" contains: "abc" (case insensitive) "this string contains 'abc' as a substring" contains: "abc" (case
insensitive) insensitive)
Matchers.tests.cpp:<line number>: Matchers.tests.cpp:<line number>:
@ -10865,7 +10865,7 @@ with expansion:
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
xmlentitycheck xmlentitycheck
embedded xml: <test>it should be possible to embed xml characters, such as <, embedded xml: <test>it should be possible to embed xml characters, such as <,
" or &, or even whole <xml>documents</xml> within an attribute</test> " or &, or even whole <xml>documents</xml> within an attribute
</test> </test>
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Misc.tests.cpp:<line number> Misc.tests.cpp:<line number>

23
third_party/clara.hpp vendored
View File

@ -5,7 +5,7 @@
// //
// See https://github.com/philsquared/Clara for more details // See https://github.com/philsquared/Clara for more details
// Clara v1.1.4 // Clara v1.1.5
#ifndef CLARA_HPP_INCLUDED #ifndef CLARA_HPP_INCLUDED
#define CLARA_HPP_INCLUDED #define CLARA_HPP_INCLUDED
@ -34,8 +34,8 @@
// //
// A single-header library for wrapping and laying out basic text, by Phil Nash // A single-header library for wrapping and laying out basic text, by Phil Nash
// //
// This work is licensed under the BSD 2-Clause license. // Distributed under the Boost Software License, Version 1.0. (See accompanying
// See the accompanying LICENSE file, or the one at https://opensource.org/licenses/BSD-2-Clause // file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// //
// This project is hosted at https://github.com/philsquared/textflowcpp // This project is hosted at https://github.com/philsquared/textflowcpp
@ -142,6 +142,12 @@ namespace clara { namespace TextFlow {
} }
public: public:
using difference_type = std::ptrdiff_t;
using value_type = std::string;
using pointer = value_type*;
using reference = value_type&;
using iterator_category = std::forward_iterator_tag;
explicit iterator( Column const& column ) : m_column( column ) { explicit iterator( Column const& column ) : m_column( column ) {
assert( m_column.m_width > m_column.m_indent ); assert( m_column.m_width > m_column.m_indent );
assert( m_column.m_initialIndent == std::string::npos || m_column.m_width > m_column.m_initialIndent ); assert( m_column.m_initialIndent == std::string::npos || m_column.m_width > m_column.m_initialIndent );
@ -153,10 +159,7 @@ namespace clara { namespace TextFlow {
auto operator *() const -> std::string { auto operator *() const -> std::string {
assert( m_stringIndex < m_column.m_strings.size() ); assert( m_stringIndex < m_column.m_strings.size() );
assert( m_pos <= m_end ); assert( m_pos <= m_end );
if( m_pos + m_column.m_width < m_end )
return addIndentAndSuffix(line().substr(m_pos, m_len)); return addIndentAndSuffix(line().substr(m_pos, m_len));
else
return addIndentAndSuffix(line().substr(m_pos, m_end - m_pos));
} }
auto operator ++() -> iterator& { auto operator ++() -> iterator& {
@ -266,6 +269,12 @@ namespace clara { namespace TextFlow {
} }
public: public:
using difference_type = std::ptrdiff_t;
using value_type = std::string;
using pointer = value_type*;
using reference = value_type&;
using iterator_category = std::forward_iterator_tag;
explicit iterator( Columns const& columns ) explicit iterator( Columns const& columns )
: m_columns( columns.m_columns ), : m_columns( columns.m_columns ),
m_activeIterators( m_columns.size() ) m_activeIterators( m_columns.size() )
@ -355,7 +364,7 @@ namespace clara { namespace TextFlow {
cols += other; cols += other;
return cols; return cols;
} }
}} // namespace clara::TextFlow }}
#endif // CLARA_TEXTFLOW_HPP_INCLUDED #endif // CLARA_TEXTFLOW_HPP_INCLUDED