Compare commits

..

21 Commits

Author SHA1 Message Date
Martin Hořeňovský
7cbd0b587a v2.1.2 2018-02-09 17:10:27 +01:00
Martin Hořeňovský
2f15ccd4d3 Passthrough error code from coverage helper 2018-02-09 16:54:10 +01:00
Martin Hořeňovský
8f3fc15b73 Update version of Clara
Fixes #1165
2018-02-09 16:50:19 +01:00
Martin Hořeňovský
e13d9cab02 Keep .py files with LF endings so they can be executed from bash 2018-02-09 16:49:35 +01:00
Martin Hořeňovský
414e2fa946 Make embedClara.py executable 2018-02-09 16:49:21 +01:00
Martin Hořeňovský
b5ef68b044 Force MSVC to use utf-8 2018-02-08 15:44:33 +01:00
Martin Hořeňovský
681f5daa13 Update approval tests 2018-02-08 15:00:56 +01:00
Martin Hořeňovský
3b6fda3c1b Add tests for StringRef::numberOfCharacters 2018-02-08 13:10:12 +01:00
Martin Hořeňovský
1b2fa601c6 Remove superfluous comment 2018-02-08 13:09:02 +01:00
Daniel J. Rollins
39bfc6e82b Export Catch as a CMake package and 'linkable' target
Create a namespaced Catch2::Catch target that is 'linkable' through
`target_link_libraries()` and export it so it is findable through
`find_package()`.

`find_package()` will find versions with the same major number and with
minor number >= requested.

This makes catch a lot easier to use in CMake-based projects. Whether it
is found using `find_package` or included in the client project as a
subdirectory, the client can include the catch headers per-target with
`target_include_directories(target PRIVATE Catch2::Catch).

Example usage:

    cmake_minimum_required(VERSION 3.1)

    # include Catch2 as subdirectory or installed package
    # add_subdirectory(Catch2)
    find_package(Catch2 VERSION 2.1.0 REQUIRED)

    add_executable(tests tests/catch_main.cpp)
    target_link_libraries(tests PRIVATE Catch2::Catch)
2018-02-08 12:18:42 +01:00
Martin Hořeňovský
ba6d33fb8c Enable -Wpedantic, fix unconditional use of C++14 extension 2018-02-05 10:04:59 +01:00
Zachary Michaels
4be81d3588 Remove unnecessary semicolons 2018-02-05 10:03:51 +01:00
Josh Lospinoso
5201e92564 Redirect std::uncaught_exception to Catch::uncaught_exception
This means that only one place needs to work with warnings from
the deprecation of `std::uncaught_exception()` in C++17.

Closes #1162.
2018-02-02 15:36:15 +01:00
Martin Hořeňovský
5e484862f2 Add Catch::is_range to documentation 2018-02-01 20:29:49 +01:00
philsquared
5713381d06 Fixes for cygwin 2018-02-01 16:14:20 +00:00
Martin Hořeňovský
1ab6be30a2 Add a BrightYellow colour, also use it for reconstructed exprs
Closes #979
2018-02-01 14:58:33 +00:00
Martin Hořeňovský
126850e76b Prefer operator<< to range-based stringification
Fixes #1172
2018-02-01 14:07:23 +01:00
George Fotopoulos
5e8df1c384 Update opensource-users.md 2018-01-28 21:05:24 +01:00
Martin Hořeňovský
44dbda9f01 Add CATCH_VERSION_* defines for external use
I wonder how much use they will actually see, but their cost is
fairly minor.

Closes #1131
2018-01-26 20:56:14 +01:00
Phil Nash
ca2455e6e6 Fixed NoAssertions warning 2018-01-26 16:52:28 +00:00
Martin Hořeňovský
42213d4c31 Keep LICENCE.txt with LF as line endings for easy hashing 2018-01-26 16:45:32 +01:00
39 changed files with 678 additions and 144 deletions

7
.gitattributes vendored
View File

@@ -10,6 +10,13 @@
# Windows specific files should retain windows line-endings
*.sln text eol=crlf
# Keep executable scripts with LFs so they can be run after being
# checked out on Windows
*.py text eol=lf
# Keep the single include header with LFs to make sure it is uploaded,
# hashed etc with LF
single_include/*.hpp eol=lf
# Also keep the LICENCE file with LFs for the same reason
LICENCE.txt eol=lf

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.1)
# detect if Catch is being bundled,
# disable testsuite in that case
@@ -6,7 +6,7 @@ if(NOT DEFINED PROJECT_NAME)
set(NOT_SUBPROJECT ON)
endif()
project(Catch2 LANGUAGES CXX VERSION 2.1.1)
project(Catch2 LANGUAGES CXX VERSION 2.1.2)
include(GNUInstallDirs)
@@ -187,6 +187,7 @@ set(INTERNAL_HEADERS
${HEADER_DIR}/internal/catch_timer.h
${HEADER_DIR}/internal/catch_tostring.h
${HEADER_DIR}/internal/catch_totals.h
${HEADER_DIR}/internal/catch_uncaught_exceptions.h
${HEADER_DIR}/internal/catch_user_interfaces.h
${HEADER_DIR}/internal/catch_version.h
${HEADER_DIR}/internal/catch_wildcard_pattern.h
@@ -247,6 +248,7 @@ set(IMPL_SOURCES
${HEADER_DIR}/internal/catch_timer.cpp
${HEADER_DIR}/internal/catch_tostring.cpp
${HEADER_DIR}/internal/catch_totals.cpp
${HEADER_DIR}/internal/catch_uncaught_exceptions.cpp
${HEADER_DIR}/internal/catch_version.cpp
${HEADER_DIR}/internal/catch_wildcard_pattern.cpp
${HEADER_DIR}/internal/catch_xmlwriter.cpp
@@ -328,16 +330,15 @@ if (BUILD_TESTING AND NOT_SUBPROJECT)
coverage_evaluate()
endif()
# Add desired warnings
# Add per compiler options
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU" )
target_compile_options( SelfTest PRIVATE -Wall -Wextra -Wunreachable-code )
target_compile_options( SelfTest PRIVATE -Wall -Wextra -Wunreachable-code -Wpedantic)
if (CATCH_ENABLE_WERROR)
target_compile_options( SelfTest PRIVATE -Werror)
endif()
endif()
# Clang specific warning go here
# Clang specific options go here
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
# Actually keep these
target_compile_options( SelfTest PRIVATE -Wweak-vtables -Wexit-time-destructors -Wglobal-constructors -Wmissing-noreturn )
endif()
if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
@@ -346,6 +347,8 @@ if (BUILD_TESTING AND NOT_SUBPROJECT)
if (CATCH_ENABLE_WERROR)
target_compile_options( SelfTest PRIVATE /WX)
endif()
# Force MSVC to consider everything as encoded in utf-8
target_compile_options( SelfTest PRIVATE /utf-8 )
endif()
@@ -403,3 +406,37 @@ if(NOT WIN32 OR NOT CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/catch.pc DESTINATION ${PKGCONFIG_INSTALL_DIR})
endif()
# add catch as a 'linkable' target
add_library(Catch INTERFACE)
# depend on some obvious c++11 features so the dependency is transitively added dependants
target_compile_features(Catch INTERFACE cxx_auto_type cxx_constexpr cxx_noexcept)
target_include_directories(Catch
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/single_include>
$<INSTALL_INTERFACE:include/catch>
$<INSTALL_INTERFACE:include>)
# provide a namespaced alias for clients to 'link' against if catch is included as a sub-project
add_library(Catch2::Catch ALIAS Catch)
set(CATCH_CMAKE_CONFIG_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Catch2")
# create and install an export set for catch target as Catch2::Catch
install(TARGETS Catch EXPORT Catch2Config DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(EXPORT Catch2Config
NAMESPACE Catch2::
DESTINATION ${CATCH_CMAKE_CONFIG_DESTINATION})
# install Catch2ConfigVersion.cmake file to handle versions in find_package
include(CMakePackageConfigHelpers)
write_basic_package_version_file(Catch2ConfigVersion.cmake
COMPATIBILITY SameMajorVersion)
install(FILES
"${CMAKE_BINARY_DIR}/Catch2ConfigVersion.cmake"
DESTINATION ${CATCH_CMAKE_CONFIG_DESTINATION})

View File

@@ -5,9 +5,9 @@
[![Build Status](https://travis-ci.org/catchorg/Catch2.svg?branch=master)](https://travis-ci.org/catchorg/Catch2)
[![Build status](https://ci.appveyor.com/api/projects/status/github/catchorg/Catch2?svg=true)](https://ci.appveyor.com/project/catchorg/catch2)
[![codecov](https://codecov.io/gh/catchorg/Catch2/branch/master/graph/badge.svg)](https://codecov.io/gh/catchorg/Catch2)
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/TpIcJaLaH4WrKlhS)
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/6O2wo5BOvVeUeKQe)
<a href="https://github.com/catchorg/Catch2/releases/download/v2.1.1/catch.hpp">The latest version of the single header can be downloaded directly using this link</a>
<a href="https://github.com/catchorg/Catch2/releases/download/v2.1.2/catch.hpp">The latest version of the single header can be downloaded directly using this link</a>
## Catch2 is released!

View File

@@ -4,7 +4,7 @@ from conans import ConanFile
class CatchConan(ConanFile):
name = "Catch"
version = "2.1.1"
version = "2.1.2"
description = "A modern, C++-native, header-only, framework for unit-tests, TDD and BDD"
author = "philsquared"
generators = "cmake"

View File

@@ -35,6 +35,9 @@ The next-generation core storage and query engine for Couchbase Lite
### [DtCraft](https://github.com/twhuang-uiuc/DtCraft)
A High-performance Cluster Computing Engine
### [forest](https://github.com/xorz57/forest)
Forest is an open-source, template library of tree data structures written in C++11.
### [Fuxedo](https://github.com/fuxedo/fuxedo)
Open source Oracle Tuxedo-like XATMI middleware for C and C++.

View File

@@ -106,6 +106,20 @@ int main( int argc, char* argv[] )
See the [Clara documentation](https://github.com/philsquared/Clara/blob/master/README.md) for more details.
## Version detection
Catch provides a triplet of macros providing the header's version,
* `CATCH_VERSION_MAJOR`
* `CATCH_VERSION_MINOR`
* `CATCH_VERSION_PATCH`
these macros expand into a single number, that corresponds to the appropriate
part of the version. As an example, given single header version v2.3.4,
the macros would expand into `2`, `3`, and `4` respectively.
---
[Home](Readme.md#top)

View File

@@ -1,5 +1,22 @@
<a id="top"></a>
# 2.1.2
## Fixes
* Fixed compilation error with `-fno-rtti` (#1165)
* Fixed NoAssertion warnings
* `operator<<` is used before range-based stringification (#1172)
* Fixed `-Wpedantic` warnings (extra semicolons and binary literals) (#1173)
## Improvements
* Added `CATCH_VERSION_{MAJOR,MINOR,PATCH}` macros (#1131)
* Added `BrightYellow` colour for use in reporters (#979)
* It is also used by ConsoleReporter for reconstructed expressions
## Other changes
* Catch is now exported as a CMake package and linkable target (#1170)
# 2.1.1
## Improvements

View File

@@ -33,6 +33,23 @@ namespace Catch {
}
```
## Catch::is_range<T> specialisation
As a fallback, Catch attempts to detect if the type can be iterated
(`begin(T)` and `end(T)` are valid) and if it can be, it is stringified
as a range. For certain types this can lead to infinite recursion, so
it can be disabled by specializing `Catch::is_range` like so:
```cpp
namespace Catch {
template<>
struct is_range<T> {
static const bool value = false;
};
}
```
## Exceptions
By default all exceptions deriving from `std::exception` will be translated to strings by calling the `what()` method. For exception types that do not derive from `std::exception` - or if `what()` does not return a suitable string - use `CATCH_TRANSLATE_EXCEPTION`. This defines a function that takes your exception type, by reference, and returns a string. It can appear anywhere in the code - it doesn't have to be in the same translation unit. For example:

View File

@@ -9,6 +9,9 @@
#ifndef TWOBLUECUBES_CATCH_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_HPP_INCLUDED
#define CATCH_VERSION_MAJOR 2
#define CATCH_VERSION_MINOR 1
#define CATCH_VERSION_PATCH 2
#ifdef __clang__
# pragma clang system_header

View File

@@ -5,7 +5,7 @@
//
// See https://github.com/philsquared/Clara for more details
// Clara v1.1.1
// Clara v1.1.2
#ifndef CATCH_CLARA_HPP_INCLUDED
#define CATCH_CLARA_HPP_INCLUDED
@@ -670,12 +670,14 @@ namespace detail {
struct BoundRef : NonCopyable {
virtual ~BoundRef() = default;
virtual auto isContainer() const -> bool { return false; }
virtual auto isFlag() const -> bool { return false; }
};
struct BoundValueRefBase : BoundRef {
virtual auto setValue( std::string const &arg ) -> ParserResult = 0;
};
struct BoundFlagRefBase : BoundRef {
virtual auto setFlag( bool flag ) -> ParserResult = 0;
virtual auto isFlag() const -> bool { return true; }
};
template<typename T>
@@ -907,7 +909,7 @@ namespace detail {
if( token.type != TokenType::Argument )
return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) );
assert( dynamic_cast<detail::BoundValueRefBase*>( m_ref.get() ) );
assert( !m_ref->isFlag() );
auto valueRef = static_cast<detail::BoundValueRefBase*>( m_ref.get() );
auto result = valueRef->setValue( remainingTokens->token );
@@ -983,14 +985,14 @@ namespace detail {
if( remainingTokens && remainingTokens->type == TokenType::Option ) {
auto const &token = *remainingTokens;
if( isMatch(token.token ) ) {
if( auto flagRef = dynamic_cast<detail::BoundFlagRefBase*>( m_ref.get() ) ) {
if( m_ref->isFlag() ) {
auto flagRef = static_cast<detail::BoundFlagRefBase*>( m_ref.get() );
auto result = flagRef->setFlag( true );
if( !result )
return InternalParseResult( result );
if( result.value() == ParseResultType::ShortCircuitAll )
return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) );
} else {
assert( dynamic_cast<detail::BoundValueRefBase*>( m_ref.get() ) );
auto valueRef = static_cast<detail::BoundValueRefBase*>( m_ref.get() );
++remainingTokens;
if( !remainingTokens )

View File

@@ -31,6 +31,14 @@
# define CATCH_CPP14_OR_GREATER
# endif
# if __cplusplus >= 201703L
# define CATCH_CPP17_OR_GREATER
# endif
#endif
#if defined(CATCH_CPP17_OR_GREATER)
# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
#endif
#ifdef __clang__
@@ -80,6 +88,11 @@
// Visual C++
#ifdef _MSC_VER
# if _MSC_VER >= 1900 // Visual Studio 2015 or newer
# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
# endif
// Universal Windows platform does not support SEH
// Or console colours (or console at all...)
# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
@@ -112,6 +125,11 @@
# define CATCH_CONFIG_POSIX_SIGNALS
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_INTERNAL_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS)
# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
#endif
#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS

View File

@@ -11,8 +11,8 @@
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wexit-time-destructors"
#endif
#include "catch_console_colour.h"
#include "catch_enforce.h"
#include "catch_errno_guard.h"
@@ -84,8 +84,12 @@ namespace {
case Colour::BrightRed: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED );
case Colour::BrightGreen: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN );
case Colour::BrightWhite: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE );
case Colour::BrightYellow: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN );
case Colour::Bright: CATCH_INTERNAL_ERROR( "not a colour" );
default:
CATCH_ERROR( "Unknown colour requested" );
}
}
@@ -143,8 +147,10 @@ namespace {
case Colour::BrightRed: return setColour( "[1;31m" );
case Colour::BrightGreen: return setColour( "[1;32m" );
case Colour::BrightWhite: return setColour( "[1;37m" );
case Colour::BrightYellow: return setColour( "[1;33m" );
case Colour::Bright: CATCH_INTERNAL_ERROR( "not a colour" );
default: CATCH_INTERNAL_ERROR( "Unknown colour requested" );
}
}
static IColourImpl* instance() {
@@ -196,7 +202,7 @@ namespace Catch {
namespace Catch {
Colour::Colour( Code _colourCode ) { use( _colourCode ); }
Colour::Colour( Colour&& rhs ) noexcept {
Colour::Colour( Colour&& rhs ) noexcept {
m_moved = rhs.m_moved;
rhs.m_moved = true;
}
@@ -205,7 +211,7 @@ namespace Catch {
rhs.m_moved = true;
return *this;
}
Colour::~Colour(){ if( !m_moved ) use( None ); }
void Colour::use( Code _colourCode ) {

View File

@@ -30,10 +30,11 @@ namespace Catch {
BrightGreen = Bright | Green,
LightGrey = Bright | Grey,
BrightWhite = Bright | White,
BrightYellow = Bright | Yellow,
// By intention
FileName = LightGrey,
Warning = Yellow,
Warning = BrightYellow,
ResultError = BrightRed,
ResultSuccess = BrightGreen,
ResultExpectedFailure = Warning,
@@ -42,7 +43,7 @@ namespace Catch {
Success = Green,
OriginalExpression = Cyan,
ReconstructedExpression = Yellow,
ReconstructedExpression = BrightYellow,
SecondaryText = LightGrey,
Headers = White

View File

@@ -40,7 +40,10 @@ namespace Catch {
#ifdef CATCH_TRAP
#define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { CATCH_TRAP(); }
#else
#define CATCH_BREAK_INTO_DEBUGGER() (void)0, 0
namespace Catch {
inline void doNothing() {}
}
#define CATCH_BREAK_INTO_DEBUGGER() Catch::doNothing()
#endif
#endif // TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED

View File

@@ -82,7 +82,7 @@ namespace Catch {
// Specialised comparison functions to handle equality comparisons between ints and pointers (NULL deduces as an int)
template<typename LhsT, typename RhsT>
auto compareEqual( LhsT const& lhs, RhsT const& rhs ) -> bool { return static_cast<bool>(lhs == rhs); };
auto compareEqual( LhsT const& lhs, RhsT const& rhs ) -> bool { return static_cast<bool>(lhs == rhs); }
template<typename T>
auto compareEqual( T* const& lhs, int rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); }
template<typename T>
@@ -93,7 +93,7 @@ namespace Catch {
auto compareEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) == rhs; }
template<typename LhsT, typename RhsT>
auto compareNotEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return static_cast<bool>(lhs != rhs); };
auto compareNotEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return static_cast<bool>(lhs != rhs); }
template<typename T>
auto compareNotEqual( T* const& lhs, int rhs ) -> bool { return lhs != reinterpret_cast<void const*>( rhs ); }
template<typename T>

View File

@@ -17,12 +17,14 @@
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
#if (defined(CATCH_PLATFORM_WINDOWS) && defined(CATCH_CONFIG_WINDOWS_SEH)) || defined(CATCH_CONFIG_POSIX_SIGNALS)
namespace {
// Report the error condition
void reportFatal( char const * const message ) {
Catch::getCurrentContext().getResultCapture()->handleFatalErrorCondition( message );
}
}
#endif
#if defined ( CATCH_PLATFORM_WINDOWS ) /////////////////////////////////////////

View File

@@ -8,6 +8,7 @@
#include "catch_message.h"
#include "catch_interfaces_capture.h"
#include "catch_uncaught_exceptions.h"
namespace Catch {
@@ -49,18 +50,9 @@ namespace Catch {
getResultCapture().pushScopedMessage( m_info );
}
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4996) // std::uncaught_exception is deprecated in C++17
#endif
ScopedMessage::~ScopedMessage() {
if ( !std::uncaught_exception() ){
if ( !uncaught_exceptions() ){
getResultCapture().popScopedMessage(m_info);
}
}
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
} // end namespace Catch

View File

@@ -321,12 +321,13 @@ namespace Catch {
handleUnexpectedInflightException( m_lastAssertionInfo, translateActiveException(), dummyReaction );
}
}
Counts assertions = m_totals.assertions - prevAssertions;
bool missingAssertions = testForMissingAssertions(assertions);
m_testCaseTracker->close();
handleUnfinishedSections();
m_messages.clear();
Counts assertions = m_totals.assertions - prevAssertions;
bool missingAssertions = testForMissingAssertions(assertions);
SectionStats testCaseSectionStats(testCaseSection, assertions, duration, missingAssertions);
m_reporter->sectionEnded(testCaseSectionStats);
}

View File

@@ -8,6 +8,7 @@
#include "catch_section.h"
#include "catch_capture.hpp"
#include "catch_uncaught_exceptions.h"
namespace Catch {
@@ -18,22 +19,15 @@ namespace Catch {
m_timer.start();
}
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4996) // std::uncaught_exception is deprecated in C++17
#endif
Section::~Section() {
if( m_sectionIncluded ) {
SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() );
if( std::uncaught_exception() )
if( uncaught_exceptions() )
getResultCapture().sectionEndedEarly( endInfo );
else
getResultCapture().sectionEnded( endInfo );
}
}
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
// This indicates whether the section should be executed or not
Section::operator bool() const {

View File

@@ -15,6 +15,13 @@
#include <ostream>
#include <cstring>
#include <cstdint>
namespace {
const uint32_t byte_2_lead = 0xC0;
const uint32_t byte_3_lead = 0xE0;
const uint32_t byte_4_lead = 0xF0;
}
namespace Catch {
StringRef::StringRef( char const* rawChars ) noexcept
@@ -79,13 +86,12 @@ namespace Catch {
// Make adjustments for uft encodings
for( size_type i=0; i < m_size; ++i ) {
char c = m_start[i];
if( ( c & 0b11000000 ) == 0b11000000 ) {
if( ( c & 0b11100000 ) == 0b11000000 )
if( ( c & byte_2_lead ) == byte_2_lead ) {
noChars--;
if (( c & byte_3_lead ) == byte_3_lead )
noChars--;
if( ( c & byte_4_lead ) == byte_4_lead )
noChars--;
else if( ( c & 0b11110000 ) == 0b11100000 )
noChars-=2;
else if( ( c & 0b11111000 ) == 0b11110000 )
noChars-=3;
}
}
return noChars;

View File

@@ -63,11 +63,11 @@ namespace Catch {
template<typename T>
typename std::enable_if<!std::is_enum<T>::value, std::string>::type convertUnstreamable( T const& ) {
return Detail::unprintableString;
};
}
template<typename T>
typename std::enable_if<std::is_enum<T>::value, std::string>::type convertUnstreamable( T const& value ) {
return convertUnknownEnumToString( value );
};
}
} // namespace Detail
@@ -387,7 +387,7 @@ namespace Catch {
}
template<typename R>
struct StringMaker<R, typename std::enable_if<is_range<R>::value && !std::is_array<R>::value>::type> {
struct StringMaker<R, typename std::enable_if<is_range<R>::value && !::Catch::Detail::IsStreamInsertable<R>::value>::type> {
static std::string convert( R const& range ) {
return rangeToString( range );
}

View File

@@ -0,0 +1,21 @@
/*
* Created by Josh on 1/2/2018.
* Copyright 2018 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)
*/
#include "catch_compiler_capabilities.h"
#include "catch_uncaught_exceptions.h"
#include <exception>
namespace Catch {
bool uncaught_exceptions() {
#if defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS)
return std::uncaught_exceptions() > 0;
#else
return std::uncaught_exception();
#endif
}
} // end namespace Catch

View File

@@ -0,0 +1,15 @@
/*
* Created by Josh on 1/2/2018.
* Copyright 2018 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_UNCAUGHT_EXCEPTIONS_H_INCLUDED
#define TWOBLUECUBES_CATCH_UNCAUGHT_EXCEPTIONS_H_INCLUDED
namespace Catch {
bool uncaught_exceptions();
} // end namespace Catch
#endif // TWOBLUECUBES_CATCH_UNCAUGHT_EXCEPTIONS_H_INCLUDED

View File

@@ -37,7 +37,7 @@ namespace Catch {
}
Version const& libraryVersion() {
static Version version( 2, 1, 1, "", 0 );
static Version version( 2, 1, 2, "", 0 );
return version;
}

View File

@@ -64,7 +64,7 @@ namespace Catch {
m_reporterPrefs.shouldRedirectStdOut = true;
}
JunitReporter::~JunitReporter() {};
JunitReporter::~JunitReporter() {}
std::string JunitReporter::getDescription() {
return "Reports test results in an XML format that looks like Ant's junitreport target";

View File

@@ -96,5 +96,10 @@ int main(int argc, char** argv) {
return lhs + ' ' + rhs;
});
exec_cmd(cmdline, num, windowsify_path(catch_path(args[0])));
try {
return exec_cmd(cmdline, num, windowsify_path(catch_path(args[0])));
} catch (std::exception const& ex) {
std::cerr << "Helper failed with: '" << ex.what() << "'\n";
return 12;
}
}

View File

@@ -652,6 +652,9 @@ String.tests.cpp:<line number>: passed: stdStr == "a stringref" for: "a stringre
String.tests.cpp:<line number>: passed: stdStr.size() == sr.size() for: 11 == 11
String.tests.cpp:<line number>: passed: stdStr == "a stringref" for: "a stringref" == "a stringref"
String.tests.cpp:<line number>: passed: stdStr.size() == sr.size() for: 11 == 11
String.tests.cpp:<line number>: passed: ascii.numberOfCharacters() == ascii.size() for: 39 == 39
String.tests.cpp:<line number>: passed: simpleu8.numberOfCharacters() == 30 for: 30 == 30
String.tests.cpp:<line number>: passed: emojis.numberOfCharacters() == 9 for: 9 == 9
ToStringChrono.tests.cpp:<line number>: passed: minute == seconds for: 1 m == 60 s
ToStringChrono.tests.cpp:<line number>: passed: hour != seconds for: 1 h != 60 s
ToStringChrono.tests.cpp:<line number>: passed: micro != milli for: 1 us != 1 ms
@@ -987,6 +990,14 @@ Misc.tests.cpp:<line number>: passed: result == "/"wide load/"" for: ""wide load
Misc.tests.cpp:<line number>: passed: result == "/"wide load/"" for: ""wide load"" == ""wide load""
Misc.tests.cpp:<line number>: passed: result == "/"wide load/"" for: ""wide load"" == ""wide load""
Misc.tests.cpp:<line number>: passed: result == "/"wide load/"" for: ""wide load"" == ""wide load""
ToStringWhich.tests.cpp:<line number>: passed: ::Catch::Detail::stringify(streamable_range{}) == "op<<(streamable_range)" for: "op<<(streamable_range)"
==
"op<<(streamable_range)"
ToStringWhich.tests.cpp:<line number>: passed: ::Catch::Detail::stringify(stringmaker_range{}) == "stringmaker(streamable_range)" for: "stringmaker(streamable_range)"
==
"stringmaker(streamable_range)"
ToStringWhich.tests.cpp:<line number>: passed: ::Catch::Detail::stringify(just_range{}) == "{ 1, 2, 3, 4 }" for: "{ 1, 2, 3, 4 }" == "{ 1, 2, 3, 4 }"
ToStringWhich.tests.cpp:<line number>: passed: ::Catch::Detail::stringify(disabled_range{}) == "{?}" for: "{?}" == "{?}"
ToStringWhich.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( v ) == "{ StringMaker<has_maker> }" for: "{ StringMaker<has_maker> }"
==
"{ StringMaker<has_maker> }"
@@ -1058,5 +1069,5 @@ Misc.tests.cpp:<line number>: passed: v.size() == 5 for: 5 == 5
Misc.tests.cpp:<line number>: passed: v.capacity() >= 5 for: 5 >= 5
Misc.tests.cpp:<line number>: passed:
Misc.tests.cpp:<line number>: passed:
Failed 49 test cases, failed 108 assertions.
Failed 61 test cases, failed 120 assertions.

View File

@@ -1064,6 +1064,6 @@ with expansion:
"first" == "second"
===============================================================================
test cases: 197 | 146 passed | 47 failed | 4 failed as expected
assertions: 992 | 866 passed | 105 failed | 21 failed as expected
test cases: 198 | 147 passed | 47 failed | 4 failed as expected
assertions: 999 | 873 passed | 105 failed | 21 failed as expected

View File

@@ -574,6 +574,15 @@ PASSED:
with expansion:
100.3 == Approx( 100.0 )
-------------------------------------------------------------------------------
An empty test with no assertions
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
No assertions in test case 'An empty test with no assertions'
-------------------------------------------------------------------------------
An expression with side-effects should only be evaluated once
-------------------------------------------------------------------------------
@@ -2118,6 +2127,9 @@ warning:
this is a message
this is a warning
No assertions in test case 'INFO and WARN do not abort tests'
-------------------------------------------------------------------------------
INFO gets logged on failure
-------------------------------------------------------------------------------
@@ -2530,6 +2542,9 @@ Misc.tests.cpp:<line number>:
warning:
This one ran
No assertions in test case 'Nice descriptive name'
-------------------------------------------------------------------------------
Non-std exceptions can be translated
-------------------------------------------------------------------------------
@@ -4662,6 +4677,15 @@ with expansion:
A string sent directly to stdout
A string sent directly to stderr
A string sent to stderr via clog
-------------------------------------------------------------------------------
Sends stuff to stdout and stderr
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
No assertions in test case 'Sends stuff to stdout and stderr'
-------------------------------------------------------------------------------
Some simple comparisons between doubles
-------------------------------------------------------------------------------
@@ -5215,6 +5239,31 @@ PASSED:
with expansion:
11 == 11
-------------------------------------------------------------------------------
StringRef
Counting utf-8 codepoints
-------------------------------------------------------------------------------
String.tests.cpp:<line number>
...............................................................................
String.tests.cpp:<line number>:
PASSED:
REQUIRE( ascii.numberOfCharacters() == ascii.size() )
with expansion:
39 == 39
String.tests.cpp:<line number>:
PASSED:
REQUIRE( simpleu8.numberOfCharacters() == 30 )
with expansion:
30 == 30
String.tests.cpp:<line number>:
PASSED:
REQUIRE( emojis.numberOfCharacters() == 9 )
with expansion:
9 == 9
-------------------------------------------------------------------------------
Stringifying std::chrono::duration helpers
-------------------------------------------------------------------------------
@@ -5390,6 +5439,9 @@ Message.tests.cpp:<line number>:
FAILED - but was ok:
CHECK_NOFAIL( 1 == 2 )
No assertions in test case 'The NO_FAIL macro reports a failure but does not fail the test'
-------------------------------------------------------------------------------
This test 'should' fail but doesn't
-------------------------------------------------------------------------------
@@ -6755,6 +6807,15 @@ Exception.tests.cpp:<line number>: FAILED:
due to unexpected exception with message:
unexpected exception
-------------------------------------------------------------------------------
When unchecked exceptions are thrown, but caught, they do not affect the test
-------------------------------------------------------------------------------
Exception.tests.cpp:<line number>
...............................................................................
No assertions in test case 'When unchecked exceptions are thrown, but caught, they do not affect the test'
-------------------------------------------------------------------------------
Where the LHS is not a simple value
-------------------------------------------------------------------------------
@@ -6766,6 +6827,9 @@ warning:
Uncomment the code in this test to check that it gives a sensible compiler
error
No assertions in test case 'Where the LHS is not a simple value'
-------------------------------------------------------------------------------
Where there is more to the expression after the RHS
-------------------------------------------------------------------------------
@@ -6777,6 +6841,9 @@ warning:
Uncomment the code in this test to check that it gives a sensible compiler
error
No assertions in test case 'Where there is more to the expression after the RHS'
-------------------------------------------------------------------------------
X/level/0/a
-------------------------------------------------------------------------------
@@ -7143,7 +7210,25 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>:
PASSED:
-------------------------------------------------------------------------------
first tag
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
No assertions in test case 'first tag'
loose text artifact
-------------------------------------------------------------------------------
has printf
-------------------------------------------------------------------------------
Tricky.tests.cpp:<line number>
...............................................................................
No assertions in test case 'has printf'
-------------------------------------------------------------------------------
just failure
-------------------------------------------------------------------------------
@@ -7154,6 +7239,15 @@ Message.tests.cpp:<line number>: FAILED:
explicitly with message:
Previous info should not be seen
-------------------------------------------------------------------------------
just info
-------------------------------------------------------------------------------
Message.tests.cpp:<line number>
...............................................................................
No assertions in test case 'just info'
-------------------------------------------------------------------------------
long long
-------------------------------------------------------------------------------
@@ -7572,6 +7666,15 @@ PASSED:
with expansion:
"didn|'t" == "didn|'t"
-------------------------------------------------------------------------------
second tag
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
No assertions in test case 'second tag'
-------------------------------------------------------------------------------
send a single char to INFO
-------------------------------------------------------------------------------
@@ -7816,6 +7919,40 @@ PASSED:
with expansion:
""wide load"" == ""wide load""
-------------------------------------------------------------------------------
toString streamable range
-------------------------------------------------------------------------------
ToStringWhich.tests.cpp:<line number>
...............................................................................
ToStringWhich.tests.cpp:<line number>:
PASSED:
REQUIRE( ::Catch::Detail::stringify(streamable_range{}) == "op<<(streamable_range)" )
with expansion:
"op<<(streamable_range)"
==
"op<<(streamable_range)"
ToStringWhich.tests.cpp:<line number>:
PASSED:
REQUIRE( ::Catch::Detail::stringify(stringmaker_range{}) == "stringmaker(streamable_range)" )
with expansion:
"stringmaker(streamable_range)"
==
"stringmaker(streamable_range)"
ToStringWhich.tests.cpp:<line number>:
PASSED:
REQUIRE( ::Catch::Detail::stringify(just_range{}) == "{ 1, 2, 3, 4 }" )
with expansion:
"{ 1, 2, 3, 4 }" == "{ 1, 2, 3, 4 }"
ToStringWhich.tests.cpp:<line number>:
PASSED:
REQUIRE( ::Catch::Detail::stringify(disabled_range{}) == "{?}" )
with expansion:
"{?}" == "{?}"
-------------------------------------------------------------------------------
toString( vectors<has_maker> )
-------------------------------------------------------------------------------
@@ -8329,6 +8466,6 @@ Misc.tests.cpp:<line number>:
PASSED:
===============================================================================
test cases: 197 | 144 passed | 49 failed | 4 failed as expected
assertions: 991 | 862 passed | 108 failed | 21 failed as expected
test cases: 198 | 133 passed | 61 failed | 4 failed as expected
assertions: 1010 | 869 passed | 120 failed | 21 failed as expected

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact
>
<testsuite name="<exe-name>" errors="15" failures="94" tests="992" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testsuite name="<exe-name>" errors="15" failures="106" tests="1011" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#1027" time="{duration}"/>
@@ -562,6 +562,7 @@ String.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="StringRef/to std::string/implicitly constructed" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/to std::string/explicitly constructed" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/to std::string/assigned" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/Counting utf-8 codepoints" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Stringifying std::chrono::duration helpers" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Stringifying std::chrono::duration with weird ratios" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Stringifying std::chrono::time_point&lt;system_clock>" time="{duration}"/>
@@ -825,6 +826,7 @@ Tricky.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="toString on const wchar_t pointer returns the string contents" time="{duration}"/>
<testcase classname="<exe-name>.global" name="toString on wchar_t const pointer returns the string contents" time="{duration}"/>
<testcase classname="<exe-name>.global" name="toString on wchar_t returns the string contents" time="{duration}"/>
<testcase classname="<exe-name>.global" name="toString streamable range" time="{duration}"/>
<testcase classname="<exe-name>.global" name="toString( vectors&lt;has_maker> )" time="{duration}"/>
<testcase classname="<exe-name>.global" name="toString( vectors&lt;has_maker_and_operator> )" time="{duration}"/>
<testcase classname="<exe-name>.global" name="toString( vectors&lt;has_operator> )" time="{duration}"/>

View File

@@ -600,7 +600,7 @@
<OverallResult success="true"/>
</TestCase>
<TestCase name="An empty test with no assertions" tags="[empty]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<OverallResult success="true"/>
<OverallResult success="false"/>
</TestCase>
<TestCase name="An expression with side-effects should only be evaluated once" tags="[Tricky]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
@@ -2447,7 +2447,7 @@
<Warning>
this is a warning
</Warning>
<OverallResult success="true"/>
<OverallResult success="false"/>
</TestCase>
<TestCase name="INFO gets logged on failure" tags="[.][failing][messages]" filename="projects/<exe-name>/UsageTests/Message.tests.cpp" >
<Info>
@@ -2957,7 +2957,7 @@
<Warning>
This one ran
</Warning>
<OverallResult success="true"/>
<OverallResult success="false"/>
</TestCase>
<TestCase name="Non-std exceptions can be translated" tags="[!throws][.][failing]" filename="projects/<exe-name>/UsageTests/Exception.tests.cpp" >
<Exception filename="projects/<exe-name>/UsageTests/Exception.tests.cpp" >
@@ -5375,7 +5375,7 @@
<OverallResult success="true"/>
</TestCase>
<TestCase name="Sends stuff to stdout and stderr" tags="[.]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<OverallResult success="true">
<OverallResult success="false">
<StdOut>
A string sent directly to stdout
</StdOut>
@@ -5582,7 +5582,7 @@ Message from section two
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="StringRef" tags="[Strings]" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
<TestCase name="StringRef" tags="[StringRef][Strings]" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
<Section name="Empty string" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
<Original>
@@ -5992,6 +5992,33 @@ Message from section two
</Section>
<OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section>
<Section name="Counting utf-8 codepoints" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
<Original>
ascii.numberOfCharacters() == ascii.size()
</Original>
<Expanded>
39 == 39
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
<Original>
simpleu8.numberOfCharacters() == 30
</Original>
<Expanded>
30 == 30
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
<Original>
emojis.numberOfCharacters() == 9
</Original>
<Expanded>
9 == 9
</Expanded>
</Expression>
<OverallResults successes="3" failures="0" expectedFailures="0"/>
</Section>
<OverallResult success="false"/>
</TestCase>
<TestCase name="Stringifying std::chrono::duration helpers" tags="[chrono][toString]" filename="projects/<exe-name>/UsageTests/ToStringChrono.tests.cpp" >
@@ -6183,7 +6210,7 @@ Message from section two
1 == 2
</Expanded>
</Expression>
<OverallResult success="true"/>
<OverallResult success="false"/>
</TestCase>
<TestCase name="This test 'should' fail but doesn't" tags="[!shouldfail][.][failing]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<OverallResult success="false"/>
@@ -7699,19 +7726,19 @@ Message from section two
<OverallResult success="false"/>
</TestCase>
<TestCase name="When unchecked exceptions are thrown, but caught, they do not affect the test" tags="[!throws]" filename="projects/<exe-name>/UsageTests/Exception.tests.cpp" >
<OverallResult success="true"/>
<OverallResult success="false"/>
</TestCase>
<TestCase name="Where the LHS is not a simple value" tags="[.][Tricky][failing]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
<Warning>
Uncomment the code in this test to check that it gives a sensible compiler error
</Warning>
<OverallResult success="true"/>
<OverallResult success="false"/>
</TestCase>
<TestCase name="Where there is more to the expression after the RHS" tags="[.][Tricky][failing]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
<Warning>
Uncomment the code in this test to check that it gives a sensible compiler error
</Warning>
<OverallResult success="true"/>
<OverallResult success="false"/>
</TestCase>
<TestCase name="X/level/0/a" tags="[Tricky]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
<OverallResult success="true"/>
@@ -8052,11 +8079,11 @@ Message from section two
<OverallResult success="true"/>
</TestCase>
<TestCase name="first tag" tags="[tag1]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<OverallResult success="true"/>
<OverallResult success="false"/>
</TestCase>
<TestCase name="has printf" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
loose text artifact
<OverallResult success="true"/>
<OverallResult success="false"/>
</TestCase>
<TestCase name="just failure" tags="[.][fail][isolated info][messages]" filename="projects/<exe-name>/UsageTests/Message.tests.cpp" >
<Failure filename="projects/<exe-name>/UsageTests/Message.tests.cpp" >
@@ -8065,7 +8092,7 @@ loose text artifact
<OverallResult success="false"/>
</TestCase>
<TestCase name="just info" tags="[info][isolated info][messages]" filename="projects/<exe-name>/UsageTests/Message.tests.cpp" >
<OverallResult success="true"/>
<OverallResult success="false"/>
</TestCase>
<TestCase name="long long" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
@@ -8375,7 +8402,7 @@ loose text artifact
</Section>
<OverallResult success="true"/>
</TestCase>
<TestCase name="replaceInPlace" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
<TestCase name="replaceInPlace" tags="[StringManip][Strings]" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
<Section name="replace single char" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
<Original>
@@ -8512,7 +8539,7 @@ loose text artifact
<OverallResult success="true"/>
</TestCase>
<TestCase name="second tag" tags="[tag2]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<OverallResult success="true"/>
<OverallResult success="false"/>
</TestCase>
<TestCase name="send a single char to INFO" tags="[.][failing]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<Info>
@@ -8750,6 +8777,45 @@ loose text artifact
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="toString streamable range" tags="[toString]" filename="projects/<exe-name>/UsageTests/ToStringWhich.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/ToStringWhich.tests.cpp" >
<Original>
::Catch::Detail::stringify(streamable_range{}) == "op&lt;&lt;(streamable_range)"
</Original>
<Expanded>
"op&lt;&lt;(streamable_range)"
==
"op&lt;&lt;(streamable_range)"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/ToStringWhich.tests.cpp" >
<Original>
::Catch::Detail::stringify(stringmaker_range{}) == "stringmaker(streamable_range)"
</Original>
<Expanded>
"stringmaker(streamable_range)"
==
"stringmaker(streamable_range)"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/ToStringWhich.tests.cpp" >
<Original>
::Catch::Detail::stringify(just_range{}) == "{ 1, 2, 3, 4 }"
</Original>
<Expanded>
"{ 1, 2, 3, 4 }" == "{ 1, 2, 3, 4 }"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/ToStringWhich.tests.cpp" >
<Original>
::Catch::Detail::stringify(disabled_range{}) == "{?}"
</Original>
<Expanded>
"{?}" == "{?}"
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="toString( vectors&lt;has_maker> )" tags="[toString]" filename="projects/<exe-name>/UsageTests/ToStringWhich.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/ToStringWhich.tests.cpp" >
<Original>
@@ -9257,7 +9323,7 @@ loose text artifact
</Section>
<OverallResult success="true"/>
</TestCase>
<OverallResults successes="862" failures="109" expectedFailures="21"/>
<OverallResults successes="869" failures="121" expectedFailures="21"/>
</Group>
<OverallResults successes="862" failures="108" expectedFailures="21"/>
<OverallResults successes="869" failures="120" expectedFailures="21"/>
</Catch>

View File

@@ -36,8 +36,8 @@ namespace Catch {
}
} // namespace Catch
TEST_CASE( "StringRef", "[Strings]" ) {
TEST_CASE( "StringRef", "[Strings][StringRef]" ) {
using Catch::StringRef;
SECTION( "Empty string" ) {
@@ -46,21 +46,21 @@ TEST_CASE( "StringRef", "[Strings]" ) {
REQUIRE( empty.size() == 0 );
REQUIRE( std::strcmp( empty.c_str(), "" ) == 0 );
}
SECTION( "From string literal" ) {
StringRef s = "hello";
REQUIRE( s.empty() == false );
REQUIRE( s.size() == 5 );
REQUIRE( isSubstring( s ) == false );
auto rawChars = data( s );
REQUIRE( std::strcmp( rawChars, "hello" ) == 0 );
SECTION( "c_str() does not cause copy" ) {
REQUIRE( isOwned( s ) == false );
REQUIRE( s.c_str() == rawChars );
REQUIRE( isOwned( s ) == false );
}
}
@@ -69,19 +69,19 @@ TEST_CASE( "StringRef", "[Strings]" ) {
REQUIRE( original == "original" );
REQUIRE( isSubstring( original ) );
REQUIRE( isOwned( original ) == false );
original.c_str(); // Forces it to take ownership
REQUIRE( isSubstring( original ) == false );
REQUIRE( isOwned( original ) );
}
SECTION( "Substrings" ) {
StringRef s = "hello world!";
StringRef ss = s.substr(0, 5);
SECTION( "zero-based substring" ) {
REQUIRE( ss.empty() == false );
REQUIRE( ss.size() == 5 );
@@ -91,33 +91,33 @@ TEST_CASE( "StringRef", "[Strings]" ) {
SECTION( "c_str() causes copy" ) {
REQUIRE( isSubstring( ss ) );
REQUIRE( isOwned( ss ) == false );
auto rawChars = data( ss );
REQUIRE( rawChars == data( s ) ); // same pointer value
REQUIRE( ss.c_str() != rawChars );
REQUIRE( isSubstring( ss ) == false );
REQUIRE( isOwned( ss ) );
REQUIRE( data( ss ) != data( s ) ); // different pointer value
}
SECTION( "non-zero-based substring") {
ss = s.substr( 6, 6 );
REQUIRE( ss.size() == 6 );
REQUIRE( std::strcmp( ss.c_str(), "world!" ) == 0 );
}
SECTION( "Pointer values of full refs should match" ) {
StringRef s2 = s;
REQUIRE( s.c_str() == s2.c_str() );
}
SECTION( "Pointer values of substring refs should not match" ) {
REQUIRE( s.c_str() != ss.c_str() );
}
}
SECTION( "Comparisons" ) {
REQUIRE( StringRef("hello") == StringRef("hello") );
REQUIRE( StringRef("hello") != StringRef("cello") );
@@ -164,9 +164,21 @@ TEST_CASE( "StringRef", "[Strings]" ) {
REQUIRE( stdStr.size() == sr.size() );
}
}
SECTION( "Counting utf-8 codepoints" ) {
StringRef ascii = "just a plain old boring ascii string...";
REQUIRE(ascii.numberOfCharacters() == ascii.size());
StringRef simpleu8 = u8"Trocha češtiny nikoho nezabila";
REQUIRE(simpleu8.numberOfCharacters() == 30);
StringRef emojis = u8"Here be 👾";
REQUIRE(emojis.numberOfCharacters() == 9);
}
}
TEST_CASE( "replaceInPlace" ) {
TEST_CASE( "replaceInPlace", "[Strings][StringManip]" ) {
std::string letters = "abcdefcg";
SECTION( "replace single char" ) {
CHECK( Catch::replaceInPlace( letters, "b", "z" ) );

View File

@@ -29,5 +29,5 @@ CATCH_REGISTER_TAG_ALIAS( "[@tricky]", "[tricky]~[.]" )
struct TestListener : Catch::TestEventListenerBase {
using TestEventListenerBase::TestEventListenerBase; // inherit constructor
};
CATCH_REGISTER_LISTENER( TestListener );
CATCH_REGISTER_LISTENER( TestListener )

View File

@@ -71,3 +71,76 @@ TEST_CASE( "toString( vectors<has_maker_and_operator> )", "[toString]" ) {
std::vector<has_maker_and_operator> v(1);
REQUIRE( ::Catch::Detail::stringify( v ) == "{ StringMaker<has_maker_and_operator> }" );
}
// Conversion should go
// StringMaker specialization, operator<<, range/enum detection, unprintable
struct int_iterator {
using iterator_category = std::input_iterator_tag;
using difference_type = std::ptrdiff_t;
using value_type = int;
using reference = int&;
using pointer = int*;
int_iterator() = default;
int_iterator(int i) :val(i) {}
value_type operator*() const { return val; }
bool operator==(int_iterator rhs) const { return val == rhs.val; }
bool operator!=(int_iterator rhs) const { return val != rhs.val; }
int_iterator operator++() { ++val; return *this; }
int_iterator operator++(int) {
auto temp(*this);
++val;
return temp;
}
private:
int val = 5;
};
struct streamable_range {
int_iterator begin() const { return int_iterator{ 1 }; }
int_iterator end() const { return {}; }
};
std::ostream& operator<<(std::ostream& os, const streamable_range&) {
os << "op<<(streamable_range)";
return os;
}
struct stringmaker_range {
int_iterator begin() const { return int_iterator{ 1 }; }
int_iterator end() const { return {}; }
};
namespace Catch {
template <>
struct StringMaker<stringmaker_range> {
static std::string convert(stringmaker_range const&) {
return "stringmaker(streamable_range)";
}
};
}
struct just_range {
int_iterator begin() const { return int_iterator{ 1 }; }
int_iterator end() const { return {}; }
};
struct disabled_range {
int_iterator begin() const { return int_iterator{ 1 }; }
int_iterator end() const { return {}; }
};
namespace Catch {
template <>
struct is_range<disabled_range> {
static const bool value = false;
};
}
TEST_CASE("toString streamable range", "[toString]") {
REQUIRE(::Catch::Detail::stringify(streamable_range{}) == "op<<(streamable_range)");
REQUIRE(::Catch::Detail::stringify(stringmaker_range{}) == "stringmaker(streamable_range)");
REQUIRE(::Catch::Detail::stringify(just_range{}) == "{ 1, 2, 3, 4 }");
REQUIRE(::Catch::Detail::stringify(disabled_range{}) == "{?}");
}

2
scripts/embedClara.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
# Execute this script any time you import a new copy of Clara into the third_party area
import os
import sys

View File

@@ -10,6 +10,7 @@ from scriptCommon import catchPath
versionParser = re.compile( r'(\s*static\sVersion\sversion)\s*\(\s*(.*)\s*,\s*(.*)\s*,\s*(.*)\s*,\s*\"(.*)\"\s*,\s*(.*)\s*\).*' )
rootPath = os.path.join( catchPath, 'include/' )
versionPath = os.path.join( rootPath, "internal/catch_version.cpp" )
definePath = os.path.join(rootPath, 'catch.hpp')
readmePath = os.path.join( catchPath, "README.md" )
conanPath = os.path.join(catchPath, 'conanfile.py')
conanTestPath = os.path.join(catchPath, 'test_package', 'conanfile.py')
@@ -137,10 +138,27 @@ def updateCmakeFile(version):
else:
file.write(line)
def updateVersionDefine(version):
with open(definePath, 'r') as file:
lines = file.readlines()
with open(definePath, 'w') as file:
for line in lines:
if '#define CATCH_VERSION_MAJOR' in line:
file.write('#define CATCH_VERSION_MAJOR {}\n'.format(version.majorVersion))
elif '#define CATCH_VERSION_MINOR' in line:
file.write('#define CATCH_VERSION_MINOR {}\n'.format(version.minorVersion))
elif '#define CATCH_VERSION_PATCH' in line:
file.write('#define CATCH_VERSION_PATCH {}\n'.format(version.patchNumber))
else:
file.write(line)
def performUpdates(version):
# First update version file, so we can regenerate single header and
# have it ready for upload to wandbox, when updating readme
version.updateVersionFile()
updateVersionDefine(version)
import generateSingleHeader
generateSingleHeader.generate(version)

View File

@@ -1,6 +1,6 @@
/*
* Catch v2.1.1
* Generated: 2018-01-26 16:04:07.190063
* Catch v2.1.2
* Generated: 2018-02-09 17:05:21.506253
* ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2018 Two Blue Cubes Ltd. All rights reserved.
@@ -13,6 +13,10 @@
// start catch.hpp
#define CATCH_VERSION_MAJOR 2
#define CATCH_VERSION_MINOR 1
#define CATCH_VERSION_PATCH 2
#ifdef __clang__
# pragma clang system_header
#elif defined __GNUC__
@@ -116,6 +120,14 @@ namespace Catch {
# define CATCH_CPP14_OR_GREATER
# endif
# if __cplusplus >= 201703L
# define CATCH_CPP17_OR_GREATER
# endif
#endif
#if defined(CATCH_CPP17_OR_GREATER)
# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
#endif
#ifdef __clang__
@@ -164,6 +176,10 @@ namespace Catch {
// Visual C++
#ifdef _MSC_VER
# if _MSC_VER >= 1900 // Visual Studio 2015 or newer
# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
# endif
// Universal Windows platform does not support SEH
// Or console colours (or console at all...)
# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
@@ -196,6 +212,10 @@ namespace Catch {
# define CATCH_CONFIG_POSIX_SIGNALS
#endif
#if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_INTERNAL_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS)
# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
#endif
#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS
@@ -735,11 +755,11 @@ namespace Catch {
template<typename T>
typename std::enable_if<!std::is_enum<T>::value, std::string>::type convertUnstreamable( T const& ) {
return Detail::unprintableString;
};
}
template<typename T>
typename std::enable_if<std::is_enum<T>::value, std::string>::type convertUnstreamable( T const& value ) {
return convertUnknownEnumToString( value );
};
}
} // namespace Detail
@@ -1057,7 +1077,7 @@ namespace Catch {
}
template<typename R>
struct StringMaker<R, typename std::enable_if<is_range<R>::value && !std::is_array<R>::value>::type> {
struct StringMaker<R, typename std::enable_if<is_range<R>::value && !::Catch::Detail::IsStreamInsertable<R>::value>::type> {
static std::string convert( R const& range ) {
return rangeToString( range );
}
@@ -1264,7 +1284,7 @@ namespace Catch {
// Specialised comparison functions to handle equality comparisons between ints and pointers (NULL deduces as an int)
template<typename LhsT, typename RhsT>
auto compareEqual( LhsT const& lhs, RhsT const& rhs ) -> bool { return static_cast<bool>(lhs == rhs); };
auto compareEqual( LhsT const& lhs, RhsT const& rhs ) -> bool { return static_cast<bool>(lhs == rhs); }
template<typename T>
auto compareEqual( T* const& lhs, int rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); }
template<typename T>
@@ -1275,7 +1295,7 @@ namespace Catch {
auto compareEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) == rhs; }
template<typename LhsT, typename RhsT>
auto compareNotEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return static_cast<bool>(lhs != rhs); };
auto compareNotEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return static_cast<bool>(lhs != rhs); }
template<typename T>
auto compareNotEqual( T* const& lhs, int rhs ) -> bool { return lhs != reinterpret_cast<void const*>( rhs ); }
template<typename T>
@@ -3881,10 +3901,11 @@ namespace Catch {
BrightGreen = Bright | Green,
LightGrey = Bright | Grey,
BrightWhite = Bright | White,
BrightYellow = Bright | Yellow,
// By intention
FileName = LightGrey,
Warning = Yellow,
Warning = BrightYellow,
ResultError = BrightRed,
ResultSuccess = BrightGreen,
ResultExpectedFailure = Warning,
@@ -3893,7 +3914,7 @@ namespace Catch {
Success = Green,
OriginalExpression = Cyan,
ReconstructedExpression = Yellow,
ReconstructedExpression = BrightYellow,
SecondaryText = LightGrey,
Headers = White
@@ -4606,7 +4627,10 @@ namespace Catch {
#ifdef CATCH_TRAP
#define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { CATCH_TRAP(); }
#else
#define CATCH_BREAK_INTO_DEBUGGER() (void)0, 0
namespace Catch {
inline void doNothing() {}
}
#define CATCH_BREAK_INTO_DEBUGGER() Catch::doNothing()
#endif
// end catch_debugger.h
@@ -5095,7 +5119,7 @@ namespace Catch {
//
// See https://github.com/philsquared/Clara for more details
// Clara v1.1.1
// Clara v1.1.2
#ifndef CATCH_CLARA_CONFIG_CONSOLE_WIDTH
@@ -5751,12 +5775,14 @@ namespace detail {
struct BoundRef : NonCopyable {
virtual ~BoundRef() = default;
virtual auto isContainer() const -> bool { return false; }
virtual auto isFlag() const -> bool { return false; }
};
struct BoundValueRefBase : BoundRef {
virtual auto setValue( std::string const &arg ) -> ParserResult = 0;
};
struct BoundFlagRefBase : BoundRef {
virtual auto setFlag( bool flag ) -> ParserResult = 0;
virtual auto isFlag() const -> bool { return true; }
};
template<typename T>
@@ -5987,7 +6013,7 @@ namespace detail {
if( token.type != TokenType::Argument )
return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) );
assert( dynamic_cast<detail::BoundValueRefBase*>( m_ref.get() ) );
assert( !m_ref->isFlag() );
auto valueRef = static_cast<detail::BoundValueRefBase*>( m_ref.get() );
auto result = valueRef->setValue( remainingTokens->token );
@@ -6063,14 +6089,14 @@ namespace detail {
if( remainingTokens && remainingTokens->type == TokenType::Option ) {
auto const &token = *remainingTokens;
if( isMatch(token.token ) ) {
if( auto flagRef = dynamic_cast<detail::BoundFlagRefBase*>( m_ref.get() ) ) {
if( m_ref->isFlag() ) {
auto flagRef = static_cast<detail::BoundFlagRefBase*>( m_ref.get() );
auto result = flagRef->setFlag( true );
if( !result )
return InternalParseResult( result );
if( result.value() == ParseResultType::ShortCircuitAll )
return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) );
} else {
assert( dynamic_cast<detail::BoundValueRefBase*>( m_ref.get() ) );
auto valueRef = static_cast<detail::BoundValueRefBase*>( m_ref.get() );
++remainingTokens;
if( !remainingTokens )
@@ -6691,8 +6717,12 @@ namespace {
case Colour::BrightRed: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED );
case Colour::BrightGreen: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN );
case Colour::BrightWhite: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE );
case Colour::BrightYellow: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN );
case Colour::Bright: CATCH_INTERNAL_ERROR( "not a colour" );
default:
CATCH_ERROR( "Unknown colour requested" );
}
}
@@ -6750,8 +6780,10 @@ namespace {
case Colour::BrightRed: return setColour( "[1;31m" );
case Colour::BrightGreen: return setColour( "[1;32m" );
case Colour::BrightWhite: return setColour( "[1;37m" );
case Colour::BrightYellow: return setColour( "[1;33m" );
case Colour::Bright: CATCH_INTERNAL_ERROR( "not a colour" );
default: CATCH_INTERNAL_ERROR( "Unknown colour requested" );
}
}
static IColourImpl* instance() {
@@ -7133,12 +7165,14 @@ namespace Catch {
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
#if (defined(CATCH_PLATFORM_WINDOWS) && defined(CATCH_CONFIG_WINDOWS_SEH)) || defined(CATCH_CONFIG_POSIX_SIGNALS)
namespace {
// Report the error condition
void reportFatal( char const * const message ) {
Catch::getCurrentContext().getResultCapture()->handleFatalErrorCondition( message );
}
}
#endif
#if defined ( CATCH_PLATFORM_WINDOWS ) /////////////////////////////////////////
@@ -7962,6 +7996,13 @@ namespace Matchers {
// end catch_matchers_string.cpp
// start catch_message.cpp
// start catch_uncaught_exceptions.h
namespace Catch {
bool uncaught_exceptions();
} // end namespace Catch
// end catch_uncaught_exceptions.h
namespace Catch {
MessageInfo::MessageInfo( std::string const& _macroName,
@@ -8000,19 +8041,11 @@ namespace Catch {
getResultCapture().pushScopedMessage( m_info );
}
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4996) // std::uncaught_exception is deprecated in C++17
#endif
ScopedMessage::~ScopedMessage() {
if ( !std::uncaught_exception() ){
if ( !uncaught_exceptions() ){
getResultCapture().popScopedMessage(m_info);
}
}
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
} // end namespace Catch
// end catch_message.cpp
// start catch_random_number_generator.cpp
@@ -8652,12 +8685,13 @@ namespace Catch {
handleUnexpectedInflightException( m_lastAssertionInfo, translateActiveException(), dummyReaction );
}
}
Counts assertions = m_totals.assertions - prevAssertions;
bool missingAssertions = testForMissingAssertions(assertions);
m_testCaseTracker->close();
handleUnfinishedSections();
m_messages.clear();
Counts assertions = m_totals.assertions - prevAssertions;
bool missingAssertions = testForMissingAssertions(assertions);
SectionStats testCaseSectionStats(testCaseSection, assertions, duration, missingAssertions);
m_reporter->sectionEnded(testCaseSectionStats);
}
@@ -8804,22 +8838,15 @@ namespace Catch {
m_timer.start();
}
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4996) // std::uncaught_exception is deprecated in C++17
#endif
Section::~Section() {
if( m_sectionIncluded ) {
SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() );
if( std::uncaught_exception() )
if( uncaught_exceptions() )
getResultCapture().sectionEndedEarly( endInfo );
else
getResultCapture().sectionEnded( endInfo );
}
}
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
// This indicates whether the section should be executed or not
Section::operator bool() const {
@@ -9470,6 +9497,13 @@ namespace Catch {
#include <ostream>
#include <cstring>
#include <cstdint>
namespace {
const uint32_t byte_2_lead = 0xC0;
const uint32_t byte_3_lead = 0xE0;
const uint32_t byte_4_lead = 0xF0;
}
namespace Catch {
StringRef::StringRef( char const* rawChars ) noexcept
@@ -9534,13 +9568,12 @@ namespace Catch {
// Make adjustments for uft encodings
for( size_type i=0; i < m_size; ++i ) {
char c = m_start[i];
if( ( c & 0b11000000 ) == 0b11000000 ) {
if( ( c & 0b11100000 ) == 0b11000000 )
if( ( c & byte_2_lead ) == byte_2_lead ) {
noChars--;
if (( c & byte_3_lead ) == byte_3_lead )
noChars--;
if( ( c & byte_4_lead ) == byte_4_lead )
noChars--;
else if( ( c & 0b11110000 ) == 0b11100000 )
noChars-=2;
else if( ( c & 0b11111000 ) == 0b11110000 )
noChars-=3;
}
}
return noChars;
@@ -10672,6 +10705,20 @@ namespace Catch {
}
// end catch_totals.cpp
// start catch_uncaught_exceptions.cpp
#include <exception>
namespace Catch {
bool uncaught_exceptions() {
#if defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS)
return std::uncaught_exceptions() > 0;
#else
return std::uncaught_exception();
#endif
}
} // end namespace Catch
// end catch_uncaught_exceptions.cpp
// start catch_version.cpp
#include <ostream>
@@ -10704,7 +10751,7 @@ namespace Catch {
}
Version const& libraryVersion() {
static Version version( 2, 1, 1, "", 0 );
static Version version( 2, 1, 2, "", 0 );
return version;
}
@@ -11933,7 +11980,7 @@ namespace Catch {
m_reporterPrefs.shouldRedirectStdOut = true;
}
JunitReporter::~JunitReporter() {};
JunitReporter::~JunitReporter() {}
std::string JunitReporter::getDescription() {
return "Reports test results in an XML format that looks like Ant's junitreport target";

View File

@@ -10,7 +10,7 @@ class CatchConanTest(ConanFile):
settings = "os", "compiler", "arch", "build_type"
username = getenv("CONAN_USERNAME", "philsquared")
channel = getenv("CONAN_CHANNEL", "testing")
requires = "Catch/2.1.1@%s/%s" % (username, channel)
requires = "Catch/2.1.2@%s/%s" % (username, channel)
def build(self):
cmake = CMake(self)

10
third_party/clara.hpp vendored
View File

@@ -5,7 +5,7 @@
//
// See https://github.com/philsquared/Clara for more details
// Clara v1.1.1
// Clara v1.1.2
#ifndef CLARA_HPP_INCLUDED
#define CLARA_HPP_INCLUDED
@@ -670,12 +670,14 @@ namespace detail {
struct BoundRef : NonCopyable {
virtual ~BoundRef() = default;
virtual auto isContainer() const -> bool { return false; }
virtual auto isFlag() const -> bool { return false; }
};
struct BoundValueRefBase : BoundRef {
virtual auto setValue( std::string const &arg ) -> ParserResult = 0;
};
struct BoundFlagRefBase : BoundRef {
virtual auto setFlag( bool flag ) -> ParserResult = 0;
virtual auto isFlag() const -> bool { return true; }
};
template<typename T>
@@ -907,7 +909,7 @@ namespace detail {
if( token.type != TokenType::Argument )
return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) );
assert( dynamic_cast<detail::BoundValueRefBase*>( m_ref.get() ) );
assert( !m_ref->isFlag() );
auto valueRef = static_cast<detail::BoundValueRefBase*>( m_ref.get() );
auto result = valueRef->setValue( remainingTokens->token );
@@ -983,14 +985,14 @@ namespace detail {
if( remainingTokens && remainingTokens->type == TokenType::Option ) {
auto const &token = *remainingTokens;
if( isMatch(token.token ) ) {
if( auto flagRef = dynamic_cast<detail::BoundFlagRefBase*>( m_ref.get() ) ) {
if( m_ref->isFlag() ) {
auto flagRef = static_cast<detail::BoundFlagRefBase*>( m_ref.get() );
auto result = flagRef->setFlag( true );
if( !result )
return InternalParseResult( result );
if( result.value() == ParseResultType::ShortCircuitAll )
return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) );
} else {
assert( dynamic_cast<detail::BoundValueRefBase*>( m_ref.get() ) );
auto valueRef = static_cast<detail::BoundValueRefBase*>( m_ref.get() );
++remainingTokens;
if( !remainingTokens )