diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5c724a46..fdf30a87 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -125,6 +125,7 @@ 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 @@ -198,6 +199,7 @@ 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 diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp index 5367ef3e..ce3f49d3 100644 --- a/src/catch2/catch_all.hpp +++ b/src/catch2/catch_all.hpp @@ -91,6 +91,7 @@ #include #include #include +#include #include #include #include diff --git a/src/catch2/catch_session.cpp b/src/catch2/catch_session.cpp index e6ad93a1..c2047aa2 100644 --- a/src/catch2/catch_session.cpp +++ b/src/catch2/catch_session.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -23,6 +22,7 @@ #include #include #include +#include #include #include diff --git a/src/catch2/internal/catch_debug_console.cpp b/src/catch2/internal/catch_debug_console.cpp index d13cc0bb..ce351de0 100644 --- a/src/catch2/internal/catch_debug_console.cpp +++ b/src/catch2/internal/catch_debug_console.cpp @@ -5,13 +5,15 @@ // https://www.boost.org/LICENSE_1_0.txt) // SPDX-License-Identifier: BSL-1.0 + #include + #include #include #include #include - -#include +#include +#include #if defined(CATCH_CONFIG_ANDROID_LOGWRITE) #include diff --git a/src/catch2/internal/catch_debugger.cpp b/src/catch2/internal/catch_debugger.cpp index 3c80173a..57ade819 100644 --- a/src/catch2/internal/catch_debugger.cpp +++ b/src/catch2/internal/catch_debugger.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #if defined(CATCH_PLATFORM_MAC) || defined(CATCH_PLATFORM_IPHONE) diff --git a/src/catch2/internal/catch_enforce.cpp b/src/catch2/internal/catch_enforce.cpp index 3f4962cb..4bc47ce3 100644 --- a/src/catch2/internal/catch_enforce.cpp +++ b/src/catch2/internal/catch_enforce.cpp @@ -6,6 +6,7 @@ // SPDX-License-Identifier: BSL-1.0 #include +#include #include diff --git a/src/catch2/internal/catch_fatal_condition_handler.cpp b/src/catch2/internal/catch_fatal_condition_handler.cpp index 410b9b8f..3afd46f5 100644 --- a/src/catch2/internal/catch_fatal_condition_handler.cpp +++ b/src/catch2/internal/catch_fatal_condition_handler.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include diff --git a/src/catch2/internal/catch_output_redirect.cpp b/src/catch2/internal/catch_output_redirect.cpp index 49cfaa0d..ae060141 100644 --- a/src/catch2/internal/catch_output_redirect.cpp +++ b/src/catch2/internal/catch_output_redirect.cpp @@ -7,6 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 #include #include +#include #include #include diff --git a/src/catch2/internal/catch_stdstreams.cpp b/src/catch2/internal/catch_stdstreams.cpp new file mode 100644 index 00000000..21a0e4e6 --- /dev/null +++ b/src/catch2/internal/catch_stdstreams.cpp @@ -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 + +#include + +#include + +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 diff --git a/src/catch2/internal/catch_stdstreams.hpp b/src/catch2/internal/catch_stdstreams.hpp new file mode 100644 index 00000000..39d8bd75 --- /dev/null +++ b/src/catch2/internal/catch_stdstreams.hpp @@ -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 + +namespace Catch { + + std::ostream& cout(); + std::ostream& cerr(); + std::ostream& clog(); + +} // namespace Catch + +#endif diff --git a/src/catch2/internal/catch_stream.cpp b/src/catch2/internal/catch_stream.cpp index 089a7583..64cfde0a 100644 --- a/src/catch2/internal/catch_stream.cpp +++ b/src/catch2/internal/catch_stream.cpp @@ -11,9 +11,9 @@ #include #include #include +#include #include -#include #include #include #include @@ -201,12 +201,4 @@ namespace Detail { } - /////////////////////////////////////////////////////////////////////////// - - -#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 } diff --git a/src/catch2/internal/catch_stream.hpp b/src/catch2/internal/catch_stream.hpp index eab7161c..d02dc4b1 100644 --- a/src/catch2/internal/catch_stream.hpp +++ b/src/catch2/internal/catch_stream.hpp @@ -18,10 +18,6 @@ namespace Catch { - std::ostream& cout(); - std::ostream& cerr(); - std::ostream& clog(); - class IStream { public: virtual ~IStream(); // = default diff --git a/src/catch2/reporters/catch_reporter_multi.cpp b/src/catch2/reporters/catch_reporter_multi.cpp index e8cf7bdf..e7ba7e5d 100644 --- a/src/catch2/reporters/catch_reporter_multi.cpp +++ b/src/catch2/reporters/catch_reporter_multi.cpp @@ -9,7 +9,9 @@ #include #include -#include +#include + +#include namespace Catch { void MultiReporter::updatePreferences(IEventListener const& reporterish) { diff --git a/tests/ExtraTests/X04-DisabledExceptions-CustomHandler.cpp b/tests/ExtraTests/X04-DisabledExceptions-CustomHandler.cpp index b506d8b8..725440ec 100644 --- a/tests/ExtraTests/X04-DisabledExceptions-CustomHandler.cpp +++ b/tests/ExtraTests/X04-DisabledExceptions-CustomHandler.cpp @@ -8,11 +8,13 @@ #include +#include + 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);