提交 70d91e92 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Update Catch2 to v2.12.2

上级 1a02410d
# Changelog # Changelog
### 3.5.16 (WIP)
* Update `Catch2` to v2.12.2.
### 3.5.15 ### 3.5.15
* Simulcast and SVC: Better computation of desired bitrate based on `maxBitrate` field in the `producer.rtpParameters.encodings`. * Simulcast and SVC: Better computation of desired bitrate based on `maxBitrate` field in the `producer.rtpParameters.encodings`.
......
...@@ -31,7 +31,7 @@ class BuilderSettings(object): ...@@ -31,7 +31,7 @@ class BuilderSettings(object):
not match the stable pattern. Otherwise it will upload to stable not match the stable pattern. Otherwise it will upload to stable
channel. channel.
""" """
return os.getenv("CONAN_UPLOAD", "https://api.bintray.com/conan/catchorg/Catch2") return os.getenv("CONAN_UPLOAD", "https://api.bintray.com/conan/catchorg/catch2")
@property @property
def upload_only_when_stable(self): def upload_only_when_stable(self):
......
...@@ -28,3 +28,4 @@ Build ...@@ -28,3 +28,4 @@ Build
cmake-build-* cmake-build-*
benchmark-dir benchmark-dir
.conan/test_package/build .conan/test_package/build
bazel-*
# Load the cc_library rule.
load("@rules_cc//cc:defs.bzl", "cc_library")
# Header-only rule to export catch2/catch.hpp.
cc_library(
name = "catch2",
hdrs = ["single_include/catch2/catch.hpp"],
visibility = ["//visibility:public"],
includes = ["single_include/"],
)
...@@ -14,7 +14,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) ...@@ -14,7 +14,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif() endif()
project(Catch2 LANGUAGES CXX VERSION 2.12.1) project(Catch2 LANGUAGES CXX VERSION 2.12.2)
# Provide path for scripts # Provide path for scripts
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")
......
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
[![Build Status](https://travis-ci.org/catchorg/Catch2.svg?branch=master)](https://travis-ci.org/catchorg/Catch2) [![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) [![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) [![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/DQL97fLLJLZXwB8d) [![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/QdDfqVqDGRuwcduN)
[![Join the chat in Discord: https://discord.gg/4CWS9zD](https://img.shields.io/badge/Discord-Chat!-brightgreen.svg)](https://discord.gg/4CWS9zD) [![Join the chat in Discord: https://discord.gg/4CWS9zD](https://img.shields.io/badge/Discord-Chat!-brightgreen.svg)](https://discord.gg/4CWS9zD)
<a href="https://github.com/catchorg/Catch2/releases/download/v2.12.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.12.2/catch.hpp">The latest version of the single header can be downloaded directly using this link</a>
## Catch2 is released! ## Catch2 is released!
......
...@@ -25,3 +25,6 @@ class CatchConan(ConanFile): ...@@ -25,3 +25,6 @@ class CatchConan(ConanFile):
def package_id(self): def package_id(self):
self.info.header_only() self.info.header_only()
def package_info(self):
self.cpp_info.builddirs.append("lib/cmake/Catch2")
...@@ -11,9 +11,9 @@ The easiest way to use Catch is to let it supply ```main()``` for you and handle ...@@ -11,9 +11,9 @@ The easiest way to use Catch is to let it supply ```main()``` for you and handle
This is achieved by writing ```#define CATCH_CONFIG_MAIN``` before the ```#include "catch.hpp"``` in *exactly one* source file. This is achieved by writing ```#define CATCH_CONFIG_MAIN``` before the ```#include "catch.hpp"``` in *exactly one* source file.
Sometimes, though, you need to write your own version of main(). You can do this by writing ```#define CATCH_CONFIG_RUNNER``` instead. Now you are free to write ```main()``` as normal and call into Catch yourself manually. Sometimes, though, you need to write your own version of main(). You can do this by writing ```#define CATCH_CONFIG_RUNNER``` instead. Now you are free to write ```main()``` as normal and call into Catch yourself manually. You now have a lot of flexibility - but here are three recipes to get your started:
You now have a lot of flexibility - but here are three recipes to get your started: **Important note: you can only provide `main` in the same file you defined `CATCH_CONFIG_RUNNER`.**
## Let Catch take full control of args and config ## Let Catch take full control of args and config
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# Release notes # Release notes
**Contents**<br> **Contents**<br>
[2.12.2](#2122)<br>
[2.12.1](#2121)<br> [2.12.1](#2121)<br>
[2.12.0](#2120)<br> [2.12.0](#2120)<br>
[2.11.3](#2113)<br> [2.11.3](#2113)<br>
...@@ -36,6 +37,20 @@ ...@@ -36,6 +37,20 @@
[Older versions](#older-versions)<br> [Older versions](#older-versions)<br>
[Even Older versions](#even-older-versions)<br> [Even Older versions](#even-older-versions)<br>
## 2.12.2
### Fixes
* Fixed compilation failure if `is_range` ADL found deleted function (#1929)
* Fixed potential UB in `CAPTURE` if the expression contained non-ASCII characters (#1925)
### Improvements
* `std::result_of` is not used if `std::invoke_result` is available (#1934)
* JUnit reporter writes out `status` attribute for tests (#1899)
* Suppresed clang-tidy's `hicpp-vararg` warning (#1921)
* Catch2 was already suppressing the `cppcoreguidelines-pro-type-vararg` alias of the warning
## 2.12.1 ## 2.12.1
### Fixes ### Fixes
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#define CATCH_VERSION_MAJOR 2 #define CATCH_VERSION_MAJOR 2
#define CATCH_VERSION_MINOR 12 #define CATCH_VERSION_MINOR 12
#define CATCH_VERSION_PATCH 1 #define CATCH_VERSION_PATCH 2
#ifdef __clang__ #ifdef __clang__
# pragma clang system_header # pragma clang system_header
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#define TWOBLUECUBES_CATCH_DETAIL_COMPLETE_INVOKE_HPP_INCLUDED #define TWOBLUECUBES_CATCH_DETAIL_COMPLETE_INVOKE_HPP_INCLUDED
#include "../../catch_enforce.h" #include "../../catch_enforce.h"
#include "../../catch_meta.hpp"
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
...@@ -42,20 +43,18 @@ namespace Catch { ...@@ -42,20 +43,18 @@ namespace Catch {
return {}; return {};
} }
}; };
template <typename Sig>
using ResultOf_t = typename std::result_of<Sig>::type;
// invoke and not return void :( // invoke and not return void :(
template <typename Fun, typename... Args> template <typename Fun, typename... Args>
CompleteType_t<ResultOf_t<Fun(Args...)>> complete_invoke(Fun&& fun, Args&&... args) { CompleteType_t<FunctionReturnType<Fun, Args...>> complete_invoke(Fun&& fun, Args&&... args) {
return CompleteInvoker<ResultOf_t<Fun(Args...)>>::invoke(std::forward<Fun>(fun), std::forward<Args>(args)...); return CompleteInvoker<FunctionReturnType<Fun, Args...>>::invoke(std::forward<Fun>(fun), std::forward<Args>(args)...);
} }
const std::string benchmarkErrorMsg = "a benchmark failed to run successfully"; const std::string benchmarkErrorMsg = "a benchmark failed to run successfully";
} // namespace Detail } // namespace Detail
template <typename Fun> template <typename Fun>
Detail::CompleteType_t<Detail::ResultOf_t<Fun()>> user_code(Fun&& fun) { Detail::CompleteType_t<FunctionReturnType<Fun>> user_code(Fun&& fun) {
CATCH_TRY{ CATCH_TRY{
return Detail::complete_invoke(std::forward<Fun>(fun)); return Detail::complete_invoke(std::forward<Fun>(fun));
} CATCH_CATCH_ALL{ } CATCH_CATCH_ALL{
......
...@@ -21,7 +21,7 @@ namespace Catch { ...@@ -21,7 +21,7 @@ namespace Catch {
namespace Benchmark { namespace Benchmark {
namespace Detail { namespace Detail {
template <typename Clock, typename Fun, typename... Args> template <typename Clock, typename Fun, typename... Args>
TimingOf<Clock, Fun(Args...)> measure(Fun&& fun, Args&&... args) { TimingOf<Clock, Fun, Args...> measure(Fun&& fun, Args&&... args) {
auto start = Clock::now(); auto start = Clock::now();
auto&& r = Detail::complete_invoke(fun, std::forward<Args>(args)...); auto&& r = Detail::complete_invoke(fun, std::forward<Args>(args)...);
auto end = Clock::now(); auto end = Clock::now();
......
...@@ -25,11 +25,11 @@ namespace Catch { ...@@ -25,11 +25,11 @@ namespace Catch {
namespace Benchmark { namespace Benchmark {
namespace Detail { namespace Detail {
template <typename Clock, typename Fun> template <typename Clock, typename Fun>
TimingOf<Clock, Fun(int)> measure_one(Fun&& fun, int iters, std::false_type) { TimingOf<Clock, Fun, int> measure_one(Fun&& fun, int iters, std::false_type) {
return Detail::measure<Clock>(fun, iters); return Detail::measure<Clock>(fun, iters);
} }
template <typename Clock, typename Fun> template <typename Clock, typename Fun>
TimingOf<Clock, Fun(Chronometer)> measure_one(Fun&& fun, int iters, std::true_type) { TimingOf<Clock, Fun, Chronometer> measure_one(Fun&& fun, int iters, std::true_type) {
Detail::ChronometerModel<Clock> meter; Detail::ChronometerModel<Clock> meter;
auto&& result = Detail::complete_invoke(fun, Chronometer(meter, iters)); auto&& result = Detail::complete_invoke(fun, Chronometer(meter, iters));
...@@ -46,7 +46,7 @@ namespace Catch { ...@@ -46,7 +46,7 @@ namespace Catch {
}; };
template <typename Clock, typename Fun> template <typename Clock, typename Fun>
TimingOf<Clock, Fun(run_for_at_least_argument_t<Clock, Fun>)> run_for_at_least(ClockDuration<Clock> how_long, int seed, Fun&& fun) { TimingOf<Clock, Fun, run_for_at_least_argument_t<Clock, Fun>> run_for_at_least(ClockDuration<Clock> how_long, int seed, Fun&& fun) {
auto iters = seed; auto iters = seed;
while (iters < (1 << 30)) { while (iters < (1 << 30)) {
auto&& Timing = measure_one<Clock>(fun, iters, is_callable<Fun(Chronometer)>()); auto&& Timing = measure_one<Clock>(fun, iters, is_callable<Fun(Chronometer)>());
......
...@@ -25,8 +25,8 @@ namespace Catch { ...@@ -25,8 +25,8 @@ namespace Catch {
Result result; Result result;
int iterations; int iterations;
}; };
template <typename Clock, typename Sig> template <typename Clock, typename Func, typename... Args>
using TimingOf = Timing<ClockDuration<Clock>, Detail::CompleteType_t<Detail::ResultOf_t<Sig>>>; using TimingOf = Timing<ClockDuration<Clock>, Detail::CompleteType_t<FunctionReturnType<Func, Args...>>>;
} // namespace Benchmark } // namespace Benchmark
} // namespace Catch } // namespace Catch
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
// //
// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. // Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented.
# if !defined(__ibmxl__) # if !defined(__ibmxl__)
# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg) */ # define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) */
# endif # endif
......
...@@ -131,8 +131,6 @@ namespace Matchers { ...@@ -131,8 +131,6 @@ namespace Matchers {
struct UnorderedEqualsMatcher : MatcherBase<std::vector<T, AllocMatch>> { struct UnorderedEqualsMatcher : MatcherBase<std::vector<T, AllocMatch>> {
UnorderedEqualsMatcher(std::vector<T, AllocComp> const& target) : m_target(target) {} UnorderedEqualsMatcher(std::vector<T, AllocComp> const& target) : m_target(target) {}
bool match(std::vector<T, AllocMatch> const& vec) const override { bool match(std::vector<T, AllocMatch> const& vec) const override {
// Note: This is a reimplementation of std::is_permutation,
// because I don't want to include <algorithm> inside the common path
if (m_target.size() != vec.size()) { if (m_target.size() != vec.size()) {
return false; return false;
} }
......
...@@ -69,10 +69,10 @@ namespace Catch { ...@@ -69,10 +69,10 @@ namespace Catch {
Capturer::Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ) { Capturer::Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ) {
auto trimmed = [&] (size_t start, size_t end) { auto trimmed = [&] (size_t start, size_t end) {
while (names[start] == ',' || isspace(names[start])) { while (names[start] == ',' || isspace(static_cast<unsigned char>(names[start]))) {
++start; ++start;
} }
while (names[end] == ',' || isspace(names[end])) { while (names[end] == ',' || isspace(static_cast<unsigned char>(names[end]))) {
--end; --end;
} }
return names.substr(start, end - start + 1); return names.substr(start, end - start + 1);
......
...@@ -32,13 +32,13 @@ namespace Catch { ...@@ -32,13 +32,13 @@ namespace Catch {
#if defined(__cpp_lib_is_invocable) && __cpp_lib_is_invocable >= 201703 #if defined(__cpp_lib_is_invocable) && __cpp_lib_is_invocable >= 201703
// std::result_of is deprecated in C++17 and removed in C++20. Hence, it is // std::result_of is deprecated in C++17 and removed in C++20. Hence, it is
// replaced with std::invoke_result here. Also *_t format is preferred over // replaced with std::invoke_result here.
// typename *::type format. template <typename Func, typename... U>
template <typename Func, typename U> using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::invoke_result_t<Func, U...>>>;
using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::invoke_result_t<Func, U>>>;
#else #else
template <typename Func, typename U> // Keep ::type here because we still support C++11
using FunctionReturnType = typename std::remove_reference<typename std::remove_cv<typename std::result_of<Func(U)>::type>::type>::type; template <typename Func, typename... U>
using FunctionReturnType = typename std::remove_reference<typename std::remove_cv<typename std::result_of<Func(U...)>::type>::type>::type;
#endif #endif
} // namespace Catch } // namespace Catch
......
...@@ -469,20 +469,27 @@ namespace Catch { ...@@ -469,20 +469,27 @@ namespace Catch {
#endif // CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER #endif // CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
namespace Catch { namespace Catch {
struct not_this_one {}; // Tag type for detecting which begin/ end are being selected // Import begin/ end from std here
// Import begin/ end from std here so they are considered alongside the fallback (...) overloads in this namespace
using std::begin; using std::begin;
using std::end; using std::end;
not_this_one begin( ... ); namespace detail {
not_this_one end( ... ); template <typename...>
struct void_type {
using type = void;
};
template <typename T, typename = void>
struct is_range_impl : std::false_type {
};
template <typename T>
struct is_range_impl<T, typename void_type<decltype(begin(std::declval<T>()))>::type> : std::true_type {
};
} // namespace detail
template <typename T> template <typename T>
struct is_range { struct is_range : detail::is_range_impl<T> {
static const bool value =
!std::is_same<decltype(begin(std::declval<T>())), not_this_one>::value &&
!std::is_same<decltype(end(std::declval<T>())), not_this_one>::value;
}; };
#if defined(_MANAGED) // Managed types are never ranges #if defined(_MANAGED) // Managed types are never ranges
......
...@@ -37,7 +37,7 @@ namespace Catch { ...@@ -37,7 +37,7 @@ namespace Catch {
} }
Version const& libraryVersion() { Version const& libraryVersion() {
static Version version( 2, 12, 1, "", 0 ); static Version version( 2, 12, 2, "", 0 );
return version; return version;
} }
......
...@@ -193,6 +193,11 @@ namespace Catch { ...@@ -193,6 +193,11 @@ namespace Catch {
xml.writeAttribute( "name", name ); xml.writeAttribute( "name", name );
} }
xml.writeAttribute( "time", ::Catch::Detail::stringify( sectionNode.stats.durationInSeconds ) ); xml.writeAttribute( "time", ::Catch::Detail::stringify( sectionNode.stats.durationInSeconds ) );
// This is not ideal, but it should be enough to mimic gtest's
// junit output.
// Ideally the JUnit reporter would also handle `skipTest`
// events and write those out appropriately.
xml.writeAttribute( "status", "run" );
writeAssertions( sectionNode ); writeAssertions( sectionNode );
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/* /*
* Catch v2.12.1 * Catch v2.12.2
* Generated: 2020-04-21 19:29:20.964532 * Generated: 2020-05-25 15:09:23.791719
* ---------------------------------------------------------- * ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly * This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved. * Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved.
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#define CATCH_VERSION_MAJOR 2 #define CATCH_VERSION_MAJOR 2
#define CATCH_VERSION_MINOR 12 #define CATCH_VERSION_MINOR 12
#define CATCH_VERSION_PATCH 1 #define CATCH_VERSION_PATCH 2
#ifdef __clang__ #ifdef __clang__
# pragma clang system_header # pragma clang system_header
...@@ -163,7 +163,7 @@ namespace Catch { ...@@ -163,7 +163,7 @@ namespace Catch {
// //
// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. // Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented.
# if !defined(__ibmxl__) # if !defined(__ibmxl__)
# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg) */ # define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) */
# endif # endif
# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ # define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
...@@ -944,13 +944,13 @@ namespace Catch { ...@@ -944,13 +944,13 @@ namespace Catch {
#if defined(__cpp_lib_is_invocable) && __cpp_lib_is_invocable >= 201703 #if defined(__cpp_lib_is_invocable) && __cpp_lib_is_invocable >= 201703
// std::result_of is deprecated in C++17 and removed in C++20. Hence, it is // std::result_of is deprecated in C++17 and removed in C++20. Hence, it is
// replaced with std::invoke_result here. Also *_t format is preferred over // replaced with std::invoke_result here.
// typename *::type format. template <typename Func, typename... U>
template <typename Func, typename U> using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::invoke_result_t<Func, U...>>>;
using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::invoke_result_t<Func, U>>>;
#else #else
template <typename Func, typename U> // Keep ::type here because we still support C++11
using FunctionReturnType = typename std::remove_reference<typename std::remove_cv<typename std::result_of<Func(U)>::type>::type>::type; template <typename Func, typename... U>
using FunctionReturnType = typename std::remove_reference<typename std::remove_cv<typename std::result_of<Func(U...)>::type>::type>::type;
#endif #endif
} // namespace Catch } // namespace Catch
...@@ -1988,20 +1988,27 @@ namespace Catch { ...@@ -1988,20 +1988,27 @@ namespace Catch {
#endif // CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER #endif // CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
namespace Catch { namespace Catch {
struct not_this_one {}; // Tag type for detecting which begin/ end are being selected // Import begin/ end from std here
// Import begin/ end from std here so they are considered alongside the fallback (...) overloads in this namespace
using std::begin; using std::begin;
using std::end; using std::end;
not_this_one begin( ... ); namespace detail {
not_this_one end( ... ); template <typename...>
struct void_type {
using type = void;
};
template <typename T, typename = void>
struct is_range_impl : std::false_type {
};
template <typename T>
struct is_range_impl<T, typename void_type<decltype(begin(std::declval<T>()))>::type> : std::true_type {
};
} // namespace detail
template <typename T> template <typename T>
struct is_range { struct is_range : detail::is_range_impl<T> {
static const bool value =
!std::is_same<decltype(begin(std::declval<T>())), not_this_one>::value &&
!std::is_same<decltype(end(std::declval<T>())), not_this_one>::value;
}; };
#if defined(_MANAGED) // Managed types are never ranges #if defined(_MANAGED) // Managed types are never ranges
...@@ -3714,8 +3721,6 @@ namespace Matchers { ...@@ -3714,8 +3721,6 @@ namespace Matchers {
struct UnorderedEqualsMatcher : MatcherBase<std::vector<T, AllocMatch>> { struct UnorderedEqualsMatcher : MatcherBase<std::vector<T, AllocMatch>> {
UnorderedEqualsMatcher(std::vector<T, AllocComp> const& target) : m_target(target) {} UnorderedEqualsMatcher(std::vector<T, AllocComp> const& target) : m_target(target) {}
bool match(std::vector<T, AllocMatch> const& vec) const override { bool match(std::vector<T, AllocMatch> const& vec) const override {
// Note: This is a reimplementation of std::is_permutation,
// because I don't want to include <algorithm> inside the common path
if (m_target.size() != vec.size()) { if (m_target.size() != vec.size()) {
return false; return false;
} }
...@@ -6552,20 +6557,18 @@ namespace Catch { ...@@ -6552,20 +6557,18 @@ namespace Catch {
return {}; return {};
} }
}; };
template <typename Sig>
using ResultOf_t = typename std::result_of<Sig>::type;
// invoke and not return void :( // invoke and not return void :(
template <typename Fun, typename... Args> template <typename Fun, typename... Args>
CompleteType_t<ResultOf_t<Fun(Args...)>> complete_invoke(Fun&& fun, Args&&... args) { CompleteType_t<FunctionReturnType<Fun, Args...>> complete_invoke(Fun&& fun, Args&&... args) {
return CompleteInvoker<ResultOf_t<Fun(Args...)>>::invoke(std::forward<Fun>(fun), std::forward<Args>(args)...); return CompleteInvoker<FunctionReturnType<Fun, Args...>>::invoke(std::forward<Fun>(fun), std::forward<Args>(args)...);
} }
const std::string benchmarkErrorMsg = "a benchmark failed to run successfully"; const std::string benchmarkErrorMsg = "a benchmark failed to run successfully";
} // namespace Detail } // namespace Detail
template <typename Fun> template <typename Fun>
Detail::CompleteType_t<Detail::ResultOf_t<Fun()>> user_code(Fun&& fun) { Detail::CompleteType_t<FunctionReturnType<Fun>> user_code(Fun&& fun) {
CATCH_TRY{ CATCH_TRY{
return Detail::complete_invoke(std::forward<Fun>(fun)); return Detail::complete_invoke(std::forward<Fun>(fun));
} CATCH_CATCH_ALL{ } CATCH_CATCH_ALL{
...@@ -6810,8 +6813,8 @@ namespace Catch { ...@@ -6810,8 +6813,8 @@ namespace Catch {
Result result; Result result;
int iterations; int iterations;
}; };
template <typename Clock, typename Sig> template <typename Clock, typename Func, typename... Args>
using TimingOf = Timing<ClockDuration<Clock>, Detail::CompleteType_t<Detail::ResultOf_t<Sig>>>; using TimingOf = Timing<ClockDuration<Clock>, Detail::CompleteType_t<FunctionReturnType<Func, Args...>>>;
} // namespace Benchmark } // namespace Benchmark
} // namespace Catch } // namespace Catch
...@@ -6822,7 +6825,7 @@ namespace Catch { ...@@ -6822,7 +6825,7 @@ namespace Catch {
namespace Benchmark { namespace Benchmark {
namespace Detail { namespace Detail {
template <typename Clock, typename Fun, typename... Args> template <typename Clock, typename Fun, typename... Args>
TimingOf<Clock, Fun(Args...)> measure(Fun&& fun, Args&&... args) { TimingOf<Clock, Fun, Args...> measure(Fun&& fun, Args&&... args) {
auto start = Clock::now(); auto start = Clock::now();
auto&& r = Detail::complete_invoke(fun, std::forward<Args>(args)...); auto&& r = Detail::complete_invoke(fun, std::forward<Args>(args)...);
auto end = Clock::now(); auto end = Clock::now();
...@@ -6841,11 +6844,11 @@ namespace Catch { ...@@ -6841,11 +6844,11 @@ namespace Catch {
namespace Benchmark { namespace Benchmark {
namespace Detail { namespace Detail {
template <typename Clock, typename Fun> template <typename Clock, typename Fun>
TimingOf<Clock, Fun(int)> measure_one(Fun&& fun, int iters, std::false_type) { TimingOf<Clock, Fun, int> measure_one(Fun&& fun, int iters, std::false_type) {
return Detail::measure<Clock>(fun, iters); return Detail::measure<Clock>(fun, iters);
} }
template <typename Clock, typename Fun> template <typename Clock, typename Fun>
TimingOf<Clock, Fun(Chronometer)> measure_one(Fun&& fun, int iters, std::true_type) { TimingOf<Clock, Fun, Chronometer> measure_one(Fun&& fun, int iters, std::true_type) {
Detail::ChronometerModel<Clock> meter; Detail::ChronometerModel<Clock> meter;
auto&& result = Detail::complete_invoke(fun, Chronometer(meter, iters)); auto&& result = Detail::complete_invoke(fun, Chronometer(meter, iters));
...@@ -6862,7 +6865,7 @@ namespace Catch { ...@@ -6862,7 +6865,7 @@ namespace Catch {
}; };
template <typename Clock, typename Fun> template <typename Clock, typename Fun>
TimingOf<Clock, Fun(run_for_at_least_argument_t<Clock, Fun>)> run_for_at_least(ClockDuration<Clock> how_long, int seed, Fun&& fun) { TimingOf<Clock, Fun, run_for_at_least_argument_t<Clock, Fun>> run_for_at_least(ClockDuration<Clock> how_long, int seed, Fun&& fun) {
auto iters = seed; auto iters = seed;
while (iters < (1 << 30)) { while (iters < (1 << 30)) {
auto&& Timing = measure_one<Clock>(fun, iters, is_callable<Fun(Chronometer)>()); auto&& Timing = measure_one<Clock>(fun, iters, is_callable<Fun(Chronometer)>());
...@@ -11768,10 +11771,10 @@ namespace Catch { ...@@ -11768,10 +11771,10 @@ namespace Catch {
Capturer::Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ) { Capturer::Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ) {
auto trimmed = [&] (size_t start, size_t end) { auto trimmed = [&] (size_t start, size_t end) {
while (names[start] == ',' || isspace(names[start])) { while (names[start] == ',' || isspace(static_cast<unsigned char>(names[start]))) {
++start; ++start;
} }
while (names[end] == ',' || isspace(names[end])) { while (names[end] == ',' || isspace(static_cast<unsigned char>(names[end]))) {
--end; --end;
} }
return names.substr(start, end - start + 1); return names.substr(start, end - start + 1);
...@@ -15159,7 +15162,7 @@ namespace Catch { ...@@ -15159,7 +15162,7 @@ namespace Catch {
} }
Version const& libraryVersion() { Version const& libraryVersion() {
static Version version( 2, 12, 1, "", 0 ); static Version version( 2, 12, 2, "", 0 );
return version; return version;
} }
...@@ -16738,6 +16741,11 @@ namespace Catch { ...@@ -16738,6 +16741,11 @@ namespace Catch {
xml.writeAttribute( "name", name ); xml.writeAttribute( "name", name );
} }
xml.writeAttribute( "time", ::Catch::Detail::stringify( sectionNode.stats.durationInSeconds ) ); xml.writeAttribute( "time", ::Catch::Detail::stringify( sectionNode.stats.durationInSeconds ) );
// This is not ideal, but it should be enough to mimic gtest's
// junit output.
// Ideally the JUnit reporter would also handle `skipTest`
// events and write those out appropriately.
xml.writeAttribute( "status", "run" );
writeAssertions( sectionNode ); writeAssertions( sectionNode );
......
...@@ -126,7 +126,7 @@ function get_abseil_cpp() ...@@ -126,7 +126,7 @@ function get_abseil_cpp()
function get_catch() function get_catch()
{ {
GIT_REPO="https://github.com/catchorg/Catch2.git" GIT_REPO="https://github.com/catchorg/Catch2.git"
GIT_TAG="v2.12.1" GIT_TAG="v2.12.2"
DEST="deps/catch" DEST="deps/catch"
get_dep "${GIT_REPO}" "${GIT_TAG}" "${DEST}" get_dep "${GIT_REPO}" "${GIT_TAG}" "${DEST}"
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论