mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-16 18:52:25 +01:00
Merge remote-tracking branch 'upstream/devel' into devel. (see #2094)
This commit is contained in:
commit
e1827f7875
@ -76,6 +76,7 @@ set(INTERNAL_HEADERS
|
||||
${SOURCES_DIR}/internal/catch_exception_translator_registry.hpp
|
||||
${SOURCES_DIR}/internal/catch_fatal_condition_handler.hpp
|
||||
${SOURCES_DIR}/internal/catch_floating_point_helpers.hpp
|
||||
${SOURCES_DIR}/internal/catch_istream.hpp
|
||||
${SOURCES_DIR}/internal/catch_unique_name.hpp
|
||||
${SOURCES_DIR}/internal/catch_sharding.hpp
|
||||
${SOURCES_DIR}/generators/catch_generator_exception.hpp
|
||||
@ -125,11 +126,12 @@ set(INTERNAL_HEADERS
|
||||
${SOURCES_DIR}/internal/catch_result_type.hpp
|
||||
${SOURCES_DIR}/internal/catch_run_context.hpp
|
||||
${SOURCES_DIR}/internal/catch_section.hpp
|
||||
${SOURCES_DIR}/internal/catch_stdstreams.hpp
|
||||
${SOURCES_DIR}/catch_section_info.hpp
|
||||
${SOURCES_DIR}/catch_session.hpp
|
||||
${SOURCES_DIR}/internal/catch_singletons.hpp
|
||||
${SOURCES_DIR}/internal/catch_startup_exception_registry.hpp
|
||||
${SOURCES_DIR}/internal/catch_stream.hpp
|
||||
${SOURCES_DIR}/internal/catch_reusable_string_stream.hpp
|
||||
${SOURCES_DIR}/internal/catch_stream_end_stop.hpp
|
||||
${SOURCES_DIR}/internal/catch_string_manip.hpp
|
||||
${SOURCES_DIR}/internal/catch_stringref.hpp
|
||||
@ -180,6 +182,7 @@ set(IMPL_SOURCES
|
||||
${SOURCES_DIR}/internal/catch_exception_translator_registry.cpp
|
||||
${SOURCES_DIR}/internal/catch_fatal_condition_handler.cpp
|
||||
${SOURCES_DIR}/internal/catch_floating_point_helpers.cpp
|
||||
${SOURCES_DIR}/internal/catch_istream.cpp
|
||||
${SOURCES_DIR}/generators/internal/catch_generators_combined_tu.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_combined_tu.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter.cpp
|
||||
@ -198,9 +201,10 @@ set(IMPL_SOURCES
|
||||
${SOURCES_DIR}/internal/catch_result_type.cpp
|
||||
${SOURCES_DIR}/internal/catch_run_context.cpp
|
||||
${SOURCES_DIR}/internal/catch_section.cpp
|
||||
${SOURCES_DIR}/internal/catch_stdstreams.cpp
|
||||
${SOURCES_DIR}/catch_session.cpp
|
||||
${SOURCES_DIR}/internal/catch_singletons.cpp
|
||||
${SOURCES_DIR}/internal/catch_stream.cpp
|
||||
${SOURCES_DIR}/internal/catch_reusable_string_stream.cpp
|
||||
${SOURCES_DIR}/internal/catch_stringref.cpp
|
||||
${SOURCES_DIR}/internal/catch_string_manip.cpp
|
||||
${SOURCES_DIR}/internal/catch_tag_alias_registry.cpp
|
||||
|
@ -68,6 +68,7 @@
|
||||
#include <catch2/internal/catch_exception_translator_registry.hpp>
|
||||
#include <catch2/internal/catch_fatal_condition_handler.hpp>
|
||||
#include <catch2/internal/catch_floating_point_helpers.hpp>
|
||||
#include <catch2/internal/catch_istream.hpp>
|
||||
#include <catch2/internal/catch_lazy_expr.hpp>
|
||||
#include <catch2/internal/catch_leak_detector.hpp>
|
||||
#include <catch2/internal/catch_list.hpp>
|
||||
@ -86,13 +87,14 @@
|
||||
#include <catch2/internal/catch_reporter_registry.hpp>
|
||||
#include <catch2/internal/catch_reporter_spec_parser.hpp>
|
||||
#include <catch2/internal/catch_result_type.hpp>
|
||||
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||
#include <catch2/internal/catch_run_context.hpp>
|
||||
#include <catch2/internal/catch_section.hpp>
|
||||
#include <catch2/internal/catch_sharding.hpp>
|
||||
#include <catch2/internal/catch_singletons.hpp>
|
||||
#include <catch2/internal/catch_source_line_info.hpp>
|
||||
#include <catch2/internal/catch_startup_exception_registry.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_stdstreams.hpp>
|
||||
#include <catch2/internal/catch_stream_end_stop.hpp>
|
||||
#include <catch2/internal/catch_string_manip.hpp>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
|
@ -7,7 +7,7 @@
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/internal/catch_enforce.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
#include <catch2/catch_assertion_result.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <catch2/catch_user_config.hpp>
|
||||
#include <catch2/internal/catch_compiler_detections.hpp>
|
||||
#include <catch2/internal/catch_enforce.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
#include <catch2/internal/catch_string_manip.hpp>
|
||||
#include <catch2/internal/catch_test_spec_parser.hpp>
|
||||
|
@ -9,7 +9,7 @@
|
||||
#define CATCH_MESSAGE_HPP_INCLUDED
|
||||
|
||||
#include <catch2/internal/catch_result_type.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||
#include <catch2/internal/catch_stream_end_stop.hpp>
|
||||
#include <catch2/internal/catch_message_info.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include <catch2/internal/catch_list.hpp>
|
||||
#include <catch2/internal/catch_context.hpp>
|
||||
#include <catch2/internal/catch_run_context.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/catch_test_spec.hpp>
|
||||
#include <catch2/catch_version.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
||||
@ -23,6 +22,8 @@
|
||||
#include <catch2/interfaces/catch_interfaces_reporter_registry.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
#include <catch2/internal/catch_stdstreams.hpp>
|
||||
#include <catch2/internal/catch_istream.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||
#include <catch2/internal/catch_compiler_detections.hpp>
|
||||
#include <catch2/internal/catch_config_wchar.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||
#include <catch2/internal/catch_void_type.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_enum_values_registry.hpp>
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <catch2/catch_test_case_info.hpp>
|
||||
#include <catch2/reporters/catch_reporter_helpers.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
#include <catch2/internal/catch_istream.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
@ -44,6 +45,8 @@ namespace Catch {
|
||||
return m_customOptions;
|
||||
}
|
||||
|
||||
ReporterConfig::~ReporterConfig() = default;
|
||||
|
||||
AssertionStats::AssertionStats( AssertionResult const& _assertionResult,
|
||||
std::vector<MessageInfo> const& _infoMessages,
|
||||
Totals const& _totals )
|
||||
|
@ -40,6 +40,10 @@ namespace Catch {
|
||||
ColourMode colourMode,
|
||||
std::map<std::string, std::string> customOptions );
|
||||
|
||||
ReporterConfig( ReporterConfig&& ) = default;
|
||||
ReporterConfig& operator=( ReporterConfig&& ) = default;
|
||||
~ReporterConfig(); // = default
|
||||
|
||||
Detail::unique_ptr<IStream> takeStream() &&;
|
||||
IConfig const* fullConfig() const;
|
||||
ColourMode colourMode() const;
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include <catch2/internal/catch_enforce.hpp>
|
||||
#include <catch2/internal/catch_errno_guard.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_config.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_istream.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
#include <catch2/internal/catch_context.hpp>
|
||||
#include <catch2/internal/catch_platform.hpp>
|
||||
|
@ -5,13 +5,16 @@
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
#include <catch2/internal/catch_debug_console.hpp>
|
||||
|
||||
#include <catch2/internal/catch_config_android_logwrite.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_platform.hpp>
|
||||
#include <catch2/internal/catch_windows_h_proxy.hpp>
|
||||
#include <catch2/catch_user_config.hpp>
|
||||
#include <catch2/internal/catch_stdstreams.hpp>
|
||||
|
||||
#include <iosfwd>
|
||||
#include <ostream>
|
||||
|
||||
#if defined(CATCH_CONFIG_ANDROID_LOGWRITE)
|
||||
#include <android/log.h>
|
||||
|
@ -9,8 +9,8 @@
|
||||
|
||||
#include <catch2/internal/catch_compiler_detections.hpp>
|
||||
#include <catch2/internal/catch_errno_guard.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_platform.hpp>
|
||||
#include <catch2/internal/catch_stdstreams.hpp>
|
||||
|
||||
#if defined(CATCH_PLATFORM_MAC) || defined(CATCH_PLATFORM_IPHONE)
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
#include <catch2/internal/catch_enforce.hpp>
|
||||
#include <catch2/internal/catch_stdstreams.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include <catch2/internal/catch_source_line_info.hpp>
|
||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||
|
||||
#include <exception>
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
#include <catch2/internal/catch_enum_values_registry.hpp>
|
||||
#include <catch2/internal/catch_string_manip.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <catch2/internal/catch_enforce.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
||||
#include <catch2/internal/catch_windows_h_proxy.hpp>
|
||||
#include <catch2/internal/catch_stdstreams.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -5,15 +5,14 @@
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
#include <catch2/internal/catch_istream.hpp>
|
||||
#include <catch2/internal/catch_enforce.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_debug_console.hpp>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
#include <catch2/internal/catch_singletons.hpp>
|
||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||
#include <catch2/internal/catch_stdstreams.hpp>
|
||||
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
@ -156,57 +155,4 @@ namespace Detail {
|
||||
return Detail::make_unique<Detail::FileStream>( filename );
|
||||
}
|
||||
|
||||
|
||||
// This class encapsulates the idea of a pool of ostringstreams that can be reused.
|
||||
struct StringStreams {
|
||||
std::vector<Detail::unique_ptr<std::ostringstream>> m_streams;
|
||||
std::vector<std::size_t> m_unused;
|
||||
std::ostringstream m_referenceStream; // Used for copy state/ flags from
|
||||
|
||||
auto add() -> std::size_t {
|
||||
if( m_unused.empty() ) {
|
||||
m_streams.push_back( Detail::make_unique<std::ostringstream>() );
|
||||
return m_streams.size()-1;
|
||||
}
|
||||
else {
|
||||
auto index = m_unused.back();
|
||||
m_unused.pop_back();
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
void release( std::size_t index ) {
|
||||
m_streams[index]->copyfmt( m_referenceStream ); // Restore initial flags and other state
|
||||
m_unused.push_back(index);
|
||||
}
|
||||
};
|
||||
|
||||
ReusableStringStream::ReusableStringStream()
|
||||
: m_index( Singleton<StringStreams>::getMutable().add() ),
|
||||
m_oss( Singleton<StringStreams>::getMutable().m_streams[m_index].get() )
|
||||
{}
|
||||
|
||||
ReusableStringStream::~ReusableStringStream() {
|
||||
static_cast<std::ostringstream*>( m_oss )->str("");
|
||||
m_oss->clear();
|
||||
Singleton<StringStreams>::getMutable().release( m_index );
|
||||
}
|
||||
|
||||
std::string ReusableStringStream::str() const {
|
||||
return static_cast<std::ostringstream*>( m_oss )->str();
|
||||
}
|
||||
|
||||
void ReusableStringStream::str( std::string const& str ) {
|
||||
static_cast<std::ostringstream*>( m_oss )->str( str );
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement these functions
|
||||
std::ostream& cout() { return std::cout; }
|
||||
std::ostream& cerr() { return std::cerr; }
|
||||
std::ostream& clog() { return std::clog; }
|
||||
#endif
|
||||
}
|
@ -5,10 +5,9 @@
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
#ifndef CATCH_STREAM_HPP_INCLUDED
|
||||
#define CATCH_STREAM_HPP_INCLUDED
|
||||
#ifndef CATCH_ISTREAM_HPP_INCLUDED
|
||||
#define CATCH_ISTREAM_HPP_INCLUDED
|
||||
|
||||
#include <catch2/internal/catch_compiler_detections.hpp>
|
||||
#include <catch2/internal/catch_noncopyable.hpp>
|
||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||
|
||||
@ -19,10 +18,6 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
std::ostream& cout();
|
||||
std::ostream& cerr();
|
||||
std::ostream& clog();
|
||||
|
||||
class IStream {
|
||||
public:
|
||||
virtual ~IStream(); // = default
|
||||
@ -54,41 +49,6 @@ namespace Catch {
|
||||
*/
|
||||
auto makeStream( std::string const& filename ) -> Detail::unique_ptr<IStream>;
|
||||
|
||||
class ReusableStringStream : Detail::NonCopyable {
|
||||
std::size_t m_index;
|
||||
std::ostream* m_oss;
|
||||
public:
|
||||
ReusableStringStream();
|
||||
~ReusableStringStream();
|
||||
|
||||
//! Returns the serialized state
|
||||
std::string str() const;
|
||||
//! Sets internal state to `str`
|
||||
void str(std::string const& str);
|
||||
|
||||
#if defined(CATCH_COMPILER_GCC)
|
||||
#pragma GCC diagnostic push
|
||||
// Old versions of GCC do not understand -Wnonnull-compare
|
||||
#pragma GCC diagnostic ignored "-Wpragmas"
|
||||
// Streaming a function pointer triggers Waddress and Wnonnull-compare
|
||||
// on GCC, because it implicitly converts it to bool and then decides
|
||||
// that the check it uses (a? true : false) is tautological and cannot
|
||||
// be null...
|
||||
#pragma GCC diagnostic ignored "-Waddress"
|
||||
#pragma GCC diagnostic ignored "-Wnonnull-compare"
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
auto operator << ( T const& value ) -> ReusableStringStream& {
|
||||
*m_oss << value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined(CATCH_COMPILER_GCC)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
auto get() -> std::ostream& { return *m_oss; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CATCH_STREAM_HPP_INCLUDED
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <catch2/internal/catch_compiler_detections.hpp>
|
||||
#include <catch2/internal/catch_enforce.hpp>
|
||||
#include <catch2/internal/catch_stdstreams.hpp>
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
@ -9,7 +9,7 @@
|
||||
#define CATCH_OUTPUT_REDIRECT_HPP_INCLUDED
|
||||
|
||||
#include <catch2/internal/catch_platform.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||
#include <catch2/internal/catch_compiler_detections.hpp>
|
||||
|
||||
|
62
src/catch2/internal/catch_reusable_string_stream.cpp
Normal file
62
src/catch2/internal/catch_reusable_string_stream.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||
#include <catch2/internal/catch_singletons.hpp>
|
||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
// This class encapsulates the idea of a pool of ostringstreams that can be reused.
|
||||
struct StringStreams {
|
||||
std::vector<Detail::unique_ptr<std::ostringstream>> m_streams;
|
||||
std::vector<std::size_t> m_unused;
|
||||
std::ostringstream m_referenceStream; // Used for copy state/ flags from
|
||||
|
||||
auto add() -> std::size_t {
|
||||
if( m_unused.empty() ) {
|
||||
m_streams.push_back( Detail::make_unique<std::ostringstream>() );
|
||||
return m_streams.size()-1;
|
||||
}
|
||||
else {
|
||||
auto index = m_unused.back();
|
||||
m_unused.pop_back();
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
void release( std::size_t index ) {
|
||||
m_streams[index]->copyfmt( m_referenceStream ); // Restore initial flags and other state
|
||||
m_unused.push_back(index);
|
||||
}
|
||||
};
|
||||
|
||||
ReusableStringStream::ReusableStringStream()
|
||||
: m_index( Singleton<StringStreams>::getMutable().add() ),
|
||||
m_oss( Singleton<StringStreams>::getMutable().m_streams[m_index].get() )
|
||||
{}
|
||||
|
||||
ReusableStringStream::~ReusableStringStream() {
|
||||
static_cast<std::ostringstream*>( m_oss )->str("");
|
||||
m_oss->clear();
|
||||
Singleton<StringStreams>::getMutable().release( m_index );
|
||||
}
|
||||
|
||||
std::string ReusableStringStream::str() const {
|
||||
return static_cast<std::ostringstream*>( m_oss )->str();
|
||||
}
|
||||
|
||||
void ReusableStringStream::str( std::string const& str ) {
|
||||
static_cast<std::ostringstream*>( m_oss )->str( str );
|
||||
}
|
||||
|
||||
|
||||
}
|
58
src/catch2/internal/catch_reusable_string_stream.hpp
Normal file
58
src/catch2/internal/catch_reusable_string_stream.hpp
Normal file
@ -0,0 +1,58 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
#ifndef CATCH_REUSABLE_STRING_STREAM_HPP_INCLUDED
|
||||
#define CATCH_REUSABLE_STRING_STREAM_HPP_INCLUDED
|
||||
|
||||
#include <catch2/internal/catch_compiler_detections.hpp>
|
||||
#include <catch2/internal/catch_noncopyable.hpp>
|
||||
|
||||
#include <iosfwd>
|
||||
#include <cstddef>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
class ReusableStringStream : Detail::NonCopyable {
|
||||
std::size_t m_index;
|
||||
std::ostream* m_oss;
|
||||
public:
|
||||
ReusableStringStream();
|
||||
~ReusableStringStream();
|
||||
|
||||
//! Returns the serialized state
|
||||
std::string str() const;
|
||||
//! Sets internal state to `str`
|
||||
void str(std::string const& str);
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
// Old versions of GCC do not understand -Wnonnull-compare
|
||||
#pragma GCC diagnostic ignored "-Wpragmas"
|
||||
// Streaming a function pointer triggers Waddress and Wnonnull-compare
|
||||
// on GCC, because it implicitly converts it to bool and then decides
|
||||
// that the check it uses (a? true : false) is tautological and cannot
|
||||
// be null...
|
||||
#pragma GCC diagnostic ignored "-Waddress"
|
||||
#pragma GCC diagnostic ignored "-Wnonnull-compare"
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
auto operator << ( T const& value ) -> ReusableStringStream& {
|
||||
*m_oss << value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
auto get() -> std::ostream& { return *m_oss; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CATCH_REUSABLE_STRING_STREAM_HPP_INCLUDED
|
24
src/catch2/internal/catch_stdstreams.cpp
Normal file
24
src/catch2/internal/catch_stdstreams.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
#include <catch2/internal/catch_stdstreams.hpp>
|
||||
|
||||
#include <catch2/catch_user_config.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
// If you #define this you must implement these functions
|
||||
#if !defined( CATCH_CONFIG_NOSTDOUT )
|
||||
std::ostream& cout() { return std::cout; }
|
||||
std::ostream& cerr() { return std::cerr; }
|
||||
std::ostream& clog() { return std::clog; }
|
||||
#endif
|
||||
|
||||
} // namespace Catch
|
22
src/catch2/internal/catch_stdstreams.hpp
Normal file
22
src/catch2/internal/catch_stdstreams.hpp
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
#ifndef CATCH_STDSTREAMS_HPP_INCLUDED
|
||||
#define CATCH_STDSTREAMS_HPP_INCLUDED
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
std::ostream& cout();
|
||||
std::ostream& cerr();
|
||||
std::ostream& clog();
|
||||
|
||||
} // namespace Catch
|
||||
|
||||
#endif
|
@ -11,7 +11,7 @@
|
||||
#include <string>
|
||||
|
||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||
|
||||
namespace Catch {
|
||||
template <typename T>
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef CATCH_XMLWRITER_HPP_INCLUDED
|
||||
#define CATCH_XMLWRITER_HPP_INCLUDED
|
||||
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
|
||||
#include <iosfwd>
|
||||
|
@ -43,7 +43,7 @@ namespace Catch {
|
||||
// vvv formerly catch_matchers_container_properties.cpp vvv //
|
||||
//////////////////////////////////////////////////////////////
|
||||
#include <catch2/matchers/catch_matchers_container_properties.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||
|
||||
namespace Catch {
|
||||
namespace Matchers {
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <catch2/internal/catch_console_width.hpp>
|
||||
#include <catch2/internal/catch_errno_guard.hpp>
|
||||
#include <catch2/internal/catch_textflow.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||
#include <catch2/internal/catch_string_manip.hpp>
|
||||
#include <catch2/internal/catch_console_colour.hpp>
|
||||
#include <catch2/catch_tostring.hpp>
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include <catch2/reporters/catch_reporter_helpers.hpp>
|
||||
#include <catch2/internal/catch_console_colour.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_istream.hpp>
|
||||
|
||||
|
||||
namespace Catch {
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <catch2/internal/catch_string_manip.hpp>
|
||||
#include <catch2/catch_version.hpp>
|
||||
#include <catch2/internal/catch_textflow.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
#include <catch2/catch_test_case_info.hpp>
|
||||
#include <catch2/internal/catch_console_width.hpp>
|
||||
|
@ -9,7 +9,9 @@
|
||||
|
||||
#include <catch2/catch_config.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_stdstreams.hpp>
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace Catch {
|
||||
void MultiReporter::updatePreferences(IEventListener const& reporterish) {
|
||||
|
@ -8,11 +8,13 @@
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace Catch {
|
||||
[[noreturn]]
|
||||
void throw_exception(std::exception const& e) {
|
||||
Catch::cerr() << "====== CUSTOM HANDLER ====== run terminates because an exception was thrown.\n"
|
||||
<< "The message was: " << e.what() << '\n';
|
||||
std::cerr << "====== CUSTOM HANDLER ====== run terminates because an exception was thrown.\n"
|
||||
<< "The message was: " << e.what() << '\n';
|
||||
// Avoid abort and other exceptional exits -- there is no way
|
||||
// to tell CMake that abort is the desired outcome of a test.
|
||||
exit(1);
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/internal/catch_console_colour.hpp>
|
||||
#include <catch2/internal/catch_istream.hpp>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include <catch2/internal/catch_enforce.hpp>
|
||||
#include <catch2/internal/catch_list.hpp>
|
||||
#include <catch2/internal/catch_reporter_registry.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_istream.hpp>
|
||||
#include <catch2/matchers/catch_matchers_string.hpp>
|
||||
#include <catch2/reporters/catch_reporter_helpers.hpp>
|
||||
#include <catch2/reporters/catch_reporter_event_listener.hpp>
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_istream.hpp>
|
||||
|
||||
TEST_CASE( "Cout stream properly declares it writes to stdout", "[streams]" ) {
|
||||
REQUIRE( Catch::makeStream( "-" )->isConsole() );
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/internal/catch_xmlwriter.hpp>
|
||||
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||
#include <catch2/matchers/catch_matchers_string.hpp>
|
||||
|
||||
#include <sstream>
|
||||
|
Loading…
Reference in New Issue
Block a user