From fc32165d48f0a46a60ac02e0e52f8c89adafd8be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Thu, 6 Jul 2017 22:28:42 +0200 Subject: [PATCH] Started work on splitting out .cpp files from header files --- CMakeLists.txt | 67 +++--- ...onresult.hpp => catch_assertionresult.cpp} | 10 - include/internal/catch_assertionresult.h | 1 + .../{catch_common.hpp => catch_common.cpp} | 7 +- ...lour_impl.hpp => catch_console_colour.cpp} | 10 +- ...tch_context_impl.hpp => catch_context.cpp} | 4 +- ...{catch_debugger.hpp => catch_debugger.cpp} | 7 +- include/internal/catch_errno_guard.cpp | 15 ++ ...ch_errno_guard.hpp => catch_errno_guard.h} | 13 +- .../catch_exception_translator_registry.hpp | 1 + include/internal/catch_fatal_condition.cpp | 181 ++++++++++++++++ include/internal/catch_fatal_condition.h | 92 ++++++++ include/internal/catch_fatal_condition.hpp | 200 ------------------ include/internal/catch_impl.hpp | 37 ++-- include/internal/catch_matchers.hpp | 2 + ...s_string.hpp => catch_matchers_string.cpp} | 2 +- .../{catch_message.hpp => catch_message.cpp} | 21 +- include/internal/catch_message.h | 12 +- ...hpp => catch_notimplemented_exception.cpp} | 4 - ...egistry_hub.hpp => catch_registry_hub.cpp} | 4 - ...t_builder.hpp => catch_result_builder.cpp} | 7 +- include/internal/catch_run_context.hpp | 2 +- .../{catch_section.hpp => catch_section.cpp} | 4 - ...ection_info.hpp => catch_section_info.cpp} | 8 +- ...p => catch_startup_exception_registry.cpp} | 4 - include/internal/catch_stream.h | 1 - include/internal/catch_stream.hpp | 1 + include/internal/catch_stringdata.cpp | 1 - ...istry.hpp => catch_tag_alias_registry.cpp} | 4 - ...case_info.hpp => catch_test_case_info.cpp} | 4 - .../catch_test_case_registry_impl.hpp | 7 + .../{catch_timer.hpp => catch_timer.cpp} | 0 ...{catch_tostring.hpp => catch_tostring.cpp} | 5 +- .../{catch_version.hpp => catch_version.cpp} | 7 +- include/internal/catch_version.h | 4 +- include/reporters/catch_reporter_bases.hpp | 2 +- .../SelfTest/SurrogateCpps/catch_common.cpp | 3 - .../SelfTest/SurrogateCpps/catch_message.cpp | 3 - 38 files changed, 403 insertions(+), 354 deletions(-) rename include/internal/{catch_assertionresult.hpp => catch_assertionresult.cpp} (86%) rename include/internal/{catch_common.hpp => catch_common.cpp} (96%) rename include/internal/{catch_console_colour_impl.hpp => catch_console_colour.cpp} (96%) rename include/internal/{catch_context_impl.hpp => catch_context.cpp} (96%) rename include/internal/{catch_debugger.hpp => catch_debugger.cpp} (95%) create mode 100644 include/internal/catch_errno_guard.cpp rename include/internal/{catch_errno_guard.hpp => catch_errno_guard.h} (53%) create mode 100644 include/internal/catch_fatal_condition.cpp create mode 100644 include/internal/catch_fatal_condition.h delete mode 100644 include/internal/catch_fatal_condition.hpp rename include/internal/{catch_matchers_string.hpp => catch_matchers_string.cpp} (99%) rename include/internal/{catch_message.hpp => catch_message.cpp} (67%) rename include/internal/{catch_notimplemented_exception.hpp => catch_notimplemented_exception.cpp} (78%) rename include/internal/{catch_registry_hub.hpp => catch_registry_hub.cpp} (95%) rename include/internal/{catch_result_builder.hpp => catch_result_builder.cpp} (97%) rename include/internal/{catch_section.hpp => catch_section.cpp} (91%) rename include/internal/{catch_section_info.hpp => catch_section_info.cpp} (92%) rename include/internal/{catch_startup_exception_registry.hpp => catch_startup_exception_registry.cpp} (75%) rename include/internal/{catch_tag_alias_registry.hpp => catch_tag_alias_registry.cpp} (93%) rename include/internal/{catch_test_case_info.hpp => catch_test_case_info.cpp} (96%) rename include/internal/{catch_timer.hpp => catch_timer.cpp} (100%) rename include/internal/{catch_tostring.hpp => catch_tostring.cpp} (97%) rename include/internal/{catch_version.hpp => catch_version.cpp} (87%) delete mode 100644 projects/SelfTest/SurrogateCpps/catch_common.cpp delete mode 100644 projects/SelfTest/SurrogateCpps/catch_message.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ed863deb..4f290cd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,8 +83,7 @@ CheckFileList(TEST_SOURCES ${SELF_TEST_DIR}) # A set of impl files that just #include a single header # Please keep these ordered alphabetically -set(IMPL_SOURCES - ${SELF_TEST_DIR}/SurrogateCpps/catch_common.cpp +set(SURROGATE_SOURCES ${SELF_TEST_DIR}/SurrogateCpps/catch_console_colour.cpp ${SELF_TEST_DIR}/SurrogateCpps/catch_debugger.cpp ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_capture.cpp @@ -94,7 +93,6 @@ set(IMPL_SOURCES ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_reporter.cpp ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_runner.cpp ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_testcase.cpp - ${SELF_TEST_DIR}/SurrogateCpps/catch_message.cpp ${SELF_TEST_DIR}/SurrogateCpps/catch_option.cpp ${SELF_TEST_DIR}/SurrogateCpps/catch_stream.cpp ${SELF_TEST_DIR}/SurrogateCpps/catch_streambuf.cpp @@ -102,7 +100,7 @@ set(IMPL_SOURCES ${SELF_TEST_DIR}/SurrogateCpps/catch_xmlwriter.cpp ${SELF_TEST_DIR}/SurrogateCpps/catch_test_case_tracker.cpp ) -CheckFileList(IMPL_SOURCES ${SELF_TEST_DIR}/SurrogateCpps) +CheckFileList(SURROGATE_SOURCES ${SELF_TEST_DIR}/SurrogateCpps) # Please keep these ordered alphabetically @@ -125,26 +123,21 @@ CheckFileList(EXTERNAL_HEADERS ${HEADER_DIR}/external) set(INTERNAL_HEADERS ${HEADER_DIR}/internal/catch_approx.hpp ${HEADER_DIR}/internal/catch_assertionresult.h - ${HEADER_DIR}/internal/catch_assertionresult.hpp ${HEADER_DIR}/internal/catch_capture.hpp ${HEADER_DIR}/internal/catch_clara.h ${HEADER_DIR}/internal/catch_commandline.hpp ${HEADER_DIR}/internal/catch_common.h - ${HEADER_DIR}/internal/catch_common.hpp ${HEADER_DIR}/internal/catch_compiler_capabilities.h ${HEADER_DIR}/internal/catch_config.hpp ${HEADER_DIR}/internal/catch_console_colour.hpp - ${HEADER_DIR}/internal/catch_console_colour_impl.hpp ${HEADER_DIR}/internal/catch_context.h - ${HEADER_DIR}/internal/catch_context_impl.hpp ${HEADER_DIR}/internal/catch_debugger.h - ${HEADER_DIR}/internal/catch_debugger.hpp ${HEADER_DIR}/internal/catch_default_main.hpp - ${HEADER_DIR}/internal/catch_errno_guard.hpp + ${HEADER_DIR}/internal/catch_errno_guard.h ${HEADER_DIR}/internal/catch_evaluate.hpp ${HEADER_DIR}/internal/catch_exception_translator_registry.hpp ${HEADER_DIR}/internal/catch_expression_lhs.hpp - ${HEADER_DIR}/internal/catch_fatal_condition.hpp + ${HEADER_DIR}/internal/catch_fatal_condition.h ${HEADER_DIR}/internal/catch_impl.hpp ${HEADER_DIR}/internal/catch_interfaces_capture.h ${HEADER_DIR}/internal/catch_interfaces_config.h @@ -157,47 +150,33 @@ set(INTERNAL_HEADERS ${HEADER_DIR}/internal/catch_list.hpp ${HEADER_DIR}/internal/catch_matchers.hpp ${HEADER_DIR}/internal/catch_matchers_string.h - ${HEADER_DIR}/internal/catch_matchers_string.hpp ${HEADER_DIR}/internal/catch_matchers_vector.h ${HEADER_DIR}/internal/catch_message.h - ${HEADER_DIR}/internal/catch_message.hpp ${HEADER_DIR}/internal/catch_notimplemented_exception.h - ${HEADER_DIR}/internal/catch_notimplemented_exception.hpp ${HEADER_DIR}/internal/catch_objc.hpp ${HEADER_DIR}/internal/catch_objc_arc.hpp ${HEADER_DIR}/internal/catch_option.hpp ${HEADER_DIR}/internal/catch_platform.h ${HEADER_DIR}/internal/catch_reenable_warnings.h - ${HEADER_DIR}/internal/catch_registry_hub.hpp ${HEADER_DIR}/internal/catch_reporter_registrars.hpp ${HEADER_DIR}/internal/catch_reporter_registry.hpp ${HEADER_DIR}/internal/catch_result_builder.h - ${HEADER_DIR}/internal/catch_result_builder.hpp ${HEADER_DIR}/internal/catch_result_type.h ${HEADER_DIR}/internal/catch_run_context.hpp ${HEADER_DIR}/internal/catch_section.h - ${HEADER_DIR}/internal/catch_section.hpp ${HEADER_DIR}/internal/catch_section_info.h - ${HEADER_DIR}/internal/catch_section_info.hpp ${HEADER_DIR}/internal/catch_startup_exception_registry.h - ${HEADER_DIR}/internal/catch_startup_exception_registry.hpp ${HEADER_DIR}/internal/catch_stream.h ${HEADER_DIR}/internal/catch_stream.hpp ${HEADER_DIR}/internal/catch_streambuf.h - ${HEADER_DIR}/internal/catch_string.cpp ${HEADER_DIR}/internal/catch_string.h - ${HEADER_DIR}/internal/catch_stringbuilder.cpp ${HEADER_DIR}/internal/catch_stringbuilder.h - ${HEADER_DIR}/internal/catch_stringdata.cpp ${HEADER_DIR}/internal/catch_stringdata.h - ${HEADER_DIR}/internal/catch_stringref.cpp ${HEADER_DIR}/internal/catch_stringref.h ${HEADER_DIR}/internal/catch_suppress_warnings.h ${HEADER_DIR}/internal/catch_tag_alias.h ${HEADER_DIR}/internal/catch_tag_alias_registry.h - ${HEADER_DIR}/internal/catch_tag_alias_registry.hpp ${HEADER_DIR}/internal/catch_test_case_info.h - ${HEADER_DIR}/internal/catch_test_case_info.hpp ${HEADER_DIR}/internal/catch_test_case_registry_impl.hpp ${HEADER_DIR}/internal/catch_test_case_tracker.hpp ${HEADER_DIR}/internal/catch_test_registry.hpp @@ -205,17 +184,41 @@ set(INTERNAL_HEADERS ${HEADER_DIR}/internal/catch_test_spec_parser.hpp ${HEADER_DIR}/internal/catch_text.h ${HEADER_DIR}/internal/catch_timer.h - ${HEADER_DIR}/internal/catch_timer.hpp ${HEADER_DIR}/internal/catch_tostring.h - ${HEADER_DIR}/internal/catch_tostring.hpp ${HEADER_DIR}/internal/catch_totals.hpp ${HEADER_DIR}/internal/catch_version.h - ${HEADER_DIR}/internal/catch_version.hpp ${HEADER_DIR}/internal/catch_wildcard_pattern.hpp ${HEADER_DIR}/internal/catch_windows_h_proxy.h ${HEADER_DIR}/internal/catch_xmlwriter.hpp ) -CheckFileList(INTERNAL_HEADERS ${HEADER_DIR}/internal) +set(IMPL_SOURCES + ${HEADER_DIR}/internal/catch_assertionresult.cpp + ${HEADER_DIR}/internal/catch_common.cpp + ${HEADER_DIR}/internal/catch_console_colour.cpp + ${HEADER_DIR}/internal/catch_context.cpp + ${HEADER_DIR}/internal/catch_debugger.cpp + ${HEADER_DIR}/internal/catch_errno_guard.cpp + ${HEADER_DIR}/internal/catch_fatal_condition.cpp + ${HEADER_DIR}/internal/catch_matchers_string.cpp + ${HEADER_DIR}/internal/catch_message.cpp + ${HEADER_DIR}/internal/catch_notimplemented_exception.cpp + ${HEADER_DIR}/internal/catch_registry_hub.cpp + ${HEADER_DIR}/internal/catch_result_builder.cpp + ${HEADER_DIR}/internal/catch_section.cpp + ${HEADER_DIR}/internal/catch_section_info.cpp + ${HEADER_DIR}/internal/catch_startup_exception_registry.cpp + ${HEADER_DIR}/internal/catch_string.cpp + ${HEADER_DIR}/internal/catch_stringbuilder.cpp + ${HEADER_DIR}/internal/catch_stringdata.cpp + ${HEADER_DIR}/internal/catch_stringref.cpp + ${HEADER_DIR}/internal/catch_tag_alias_registry.cpp + ${HEADER_DIR}/internal/catch_test_case_info.cpp + ${HEADER_DIR}/internal/catch_timer.cpp + ${HEADER_DIR}/internal/catch_tostring.cpp + ${HEADER_DIR}/internal/catch_version.cpp + ) +set(INTERNAL_FILES ${IMPL_SOURCES} ${INTERNAL_HEADERS}) +CheckFileList(INTERNAL_FILES ${HEADER_DIR}/internal) # Please keep these ordered alphabetically set(REPORTER_HEADERS @@ -248,7 +251,7 @@ CheckFileList(BENCH_SOURCES ${BENCHMARK_DIR}) # Provide some groupings for IDEs SOURCE_GROUP("Tests" FILES ${TEST_SOURCES}) -SOURCE_GROUP("Surrogates" FILES ${IMPL_SOURCES}) +SOURCE_GROUP("Surrogates" FILES ${SURROGATE_SOURCES}) SOURCE_GROUP("Benchmarks" FILES ${BENCH_SOURCES}) # configure the executable @@ -259,8 +262,8 @@ add_definitions( -DCATCH_CONFIG_FULL_PROJECT ) # Projects consuming Catch via ExternalProject_Add might want to use install step # without building all of our selftests. if (NOT NO_SELFTEST) - add_executable(SelfTest ${TEST_SOURCES} ${IMPL_SOURCES} ${HEADERS}) - add_executable(Benchmark ${BENCH_SOURCES} ${HEADERS}) + add_executable(SelfTest ${TEST_SOURCES} ${IMPL_SOURCES} ${SURROGATE_SOURCES} ${HEADERS}) + add_executable(Benchmark ${BENCH_SOURCES} ${IMPL_SOURCES} ${HEADERS}) # Add desired warnings if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU" ) diff --git a/include/internal/catch_assertionresult.hpp b/include/internal/catch_assertionresult.cpp similarity index 86% rename from include/internal/catch_assertionresult.hpp rename to include/internal/catch_assertionresult.cpp index a103d961..77c69281 100644 --- a/include/internal/catch_assertionresult.hpp +++ b/include/internal/catch_assertionresult.cpp @@ -5,8 +5,6 @@ * 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_ASSERTIONRESULT_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_HPP_INCLUDED #include "catch_assertionresult.h" @@ -54,12 +52,6 @@ namespace Catch { return !m_resultData.message.empty(); } - std::string capturedExpressionWithSecondArgument( char const * capturedExpression, char const * secondArg ) { - return (secondArg[0] == 0 || secondArg[0] == '"' && secondArg[1] == '"') - ? capturedExpression - : std::string(capturedExpression) + ", " + secondArg; - } - std::string AssertionResult::getExpression() const { if (isFalseTest(m_info.resultDisposition)) return '!' + std::string(m_info.capturedExpression); @@ -102,5 +94,3 @@ namespace Catch { } } // end namespace Catch - -#endif // TWOBLUECUBES_CATCH_ASSERTIONRESULT_HPP_INCLUDED diff --git a/include/internal/catch_assertionresult.h b/include/internal/catch_assertionresult.h index 0b20a876..26546d38 100644 --- a/include/internal/catch_assertionresult.h +++ b/include/internal/catch_assertionresult.h @@ -10,6 +10,7 @@ #include #include "catch_result_type.h" +#include "catch_common.h" namespace Catch { diff --git a/include/internal/catch_common.hpp b/include/internal/catch_common.cpp similarity index 96% rename from include/internal/catch_common.hpp rename to include/internal/catch_common.cpp index fc82351e..12968515 100644 --- a/include/internal/catch_common.hpp +++ b/include/internal/catch_common.cpp @@ -5,10 +5,10 @@ * 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_COMMON_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_COMMON_HPP_INCLUDED #include "catch_common.h" +#include "catch_context.h" +#include "catch_interfaces_config.h" #include #include @@ -107,6 +107,3 @@ namespace Catch { return os; } } - -#endif // TWOBLUECUBES_CATCH_COMMON_HPP_INCLUDED - diff --git a/include/internal/catch_console_colour_impl.hpp b/include/internal/catch_console_colour.cpp similarity index 96% rename from include/internal/catch_console_colour_impl.hpp rename to include/internal/catch_console_colour.cpp index fc3aaf50..5670b8bf 100644 --- a/include/internal/catch_console_colour_impl.hpp +++ b/include/internal/catch_console_colour.cpp @@ -5,11 +5,13 @@ * 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_CONSOLE_COLOUR_IMPL_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_IMPL_HPP_INCLUDED #include "catch_console_colour.hpp" -#include "catch_errno_guard.hpp" +#include "catch_errno_guard.h" +#include "catch_interfaces_config.h" +#include "catch_stream.h" +#include "catch_context.h" +#include "catch_platform.h" namespace Catch { namespace { @@ -186,5 +188,3 @@ namespace Catch { } } // end namespace Catch - -#endif // TWOBLUECUBES_CATCH_CONSOLE_COLOUR_IMPL_HPP_INCLUDED diff --git a/include/internal/catch_context_impl.hpp b/include/internal/catch_context.cpp similarity index 96% rename from include/internal/catch_context_impl.hpp rename to include/internal/catch_context.cpp index 10fd30ea..44d8a99e 100644 --- a/include/internal/catch_context_impl.hpp +++ b/include/internal/catch_context.cpp @@ -8,10 +8,8 @@ #ifndef TWOBLUECUBES_CATCH_CONTEXT_IMPL_HPP_INCLUDED #define TWOBLUECUBES_CATCH_CONTEXT_IMPL_HPP_INCLUDED -#include "catch_run_context.hpp" - +#include "catch_stream.h" #include "catch_context.h" -#include "catch_stream.hpp" #include "catch_common.h" namespace Catch { diff --git a/include/internal/catch_debugger.hpp b/include/internal/catch_debugger.cpp similarity index 95% rename from include/internal/catch_debugger.hpp rename to include/internal/catch_debugger.cpp index 2048904a..e857717d 100644 --- a/include/internal/catch_debugger.hpp +++ b/include/internal/catch_debugger.cpp @@ -6,11 +6,10 @@ * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * */ -#ifndef TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED #include "catch_debugger.h" -#include "catch_errno_guard.hpp" +#include "catch_errno_guard.h" +#include "catch_stream.h" #ifdef CATCH_PLATFORM_MAC @@ -127,5 +126,3 @@ } } #endif // Platform - -#endif // TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED diff --git a/include/internal/catch_errno_guard.cpp b/include/internal/catch_errno_guard.cpp new file mode 100644 index 00000000..070583bc --- /dev/null +++ b/include/internal/catch_errno_guard.cpp @@ -0,0 +1,15 @@ +/* + * Created by Martin on 06/03/2017. + * + * 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_errno_guard.h" + +#include + +namespace Catch { + ErrnoGuard::ErrnoGuard():m_oldErrno(errno){} + ErrnoGuard::~ErrnoGuard() { errno = m_oldErrno; } +} diff --git a/include/internal/catch_errno_guard.hpp b/include/internal/catch_errno_guard.h similarity index 53% rename from include/internal/catch_errno_guard.hpp rename to include/internal/catch_errno_guard.h index 48794b08..b1d1fc1c 100644 --- a/include/internal/catch_errno_guard.hpp +++ b/include/internal/catch_errno_guard.h @@ -4,22 +4,19 @@ * 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_ERRNO_GUARD_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_ERRNO_GUARD_HPP_INCLUDED - -#include - +#ifndef TWOBLUECUBES_CATCH_ERRNO_GUARD_H_INCLUDED +#define TWOBLUECUBES_CATCH_ERRNO_GUARD_H_INCLUDED namespace Catch { class ErrnoGuard { public: - ErrnoGuard():m_oldErrno(errno){} - ~ErrnoGuard() { errno = m_oldErrno; } + ErrnoGuard(); + ~ErrnoGuard(); private: int m_oldErrno; }; } -#endif // TWOBLUECUBES_CATCH_ERRNO_GUARD_HPP_INCLUDED +#endif // TWOBLUECUBES_CATCH_ERRNO_GUARD_H_INCLUDED diff --git a/include/internal/catch_exception_translator_registry.hpp b/include/internal/catch_exception_translator_registry.hpp index c4bdb400..07d83f21 100644 --- a/include/internal/catch_exception_translator_registry.hpp +++ b/include/internal/catch_exception_translator_registry.hpp @@ -10,6 +10,7 @@ #include "catch_interfaces_exception.h" #include "catch_tostring.h" +#include "catch_result_builder.h" #ifdef __OBJC__ #import "Foundation/Foundation.h" diff --git a/include/internal/catch_fatal_condition.cpp b/include/internal/catch_fatal_condition.cpp new file mode 100644 index 00000000..51773f42 --- /dev/null +++ b/include/internal/catch_fatal_condition.cpp @@ -0,0 +1,181 @@ +/* + * Created by Phil on 21/08/2014 + * Copyright 2014 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_fatal_condition.h" + +#include "catch_context.h" +#include "catch_interfaces_capture.h" + +namespace Catch { + + // Report the error condition + void reportFatal( std::string const& message ) { + IContext& context = Catch::getCurrentContext(); + IResultCapture* resultCapture = context.getResultCapture(); + resultCapture->handleFatalErrorCondition( message ); + } + +} // namespace Catch + +#if defined ( CATCH_PLATFORM_WINDOWS ) ///////////////////////////////////////// + +# if !defined ( CATCH_CONFIG_WINDOWS_SEH ) + +namespace Catch { + void FatalConditionHandler::reset() {} +} + +# else // CATCH_CONFIG_WINDOWS_SEH is defined + +namespace Catch { + struct SignalDefs { DWORD id; const char* name; }; + + // There is no 1-1 mapping between signals and windows exceptions. + // Windows can easily distinguish between SO and SigSegV, + // but SigInt, SigTerm, etc are handled differently. + SignalDefs signalDefs[] = { + { EXCEPTION_ILLEGAL_INSTRUCTION, "SIGILL - Illegal instruction signal" }, + { EXCEPTION_STACK_OVERFLOW, "SIGSEGV - Stack overflow" }, + { EXCEPTION_ACCESS_VIOLATION, "SIGSEGV - Segmentation violation signal" }, + { EXCEPTION_INT_DIVIDE_BY_ZERO, "Divide by zero error" }, + }; + + LONG CALLBACK FatalConditionHandler::handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { + for (int i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { + if (ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) { + reportFatal(signalDefs[i].name); + } + } + // If its not an exception we care about, pass it along. + // This stops us from eating debugger breaks etc. + return EXCEPTION_CONTINUE_SEARCH; + } + + FatalConditionHandler::FatalConditionHandler() { + isSet = true; + // 32k seems enough for Catch to handle stack overflow, + // but the value was found experimentally, so there is no strong guarantee + guaranteeSize = 32 * 1024; + exceptionHandlerHandle = nullptr; + // Register as first handler in current chain + exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException); + // Pass in guarantee size to be filled + SetThreadStackGuarantee(&guaranteeSize); + } + + void FatalConditionHandler::reset() { + if (isSet) { + // Unregister handler and restore the old guarantee + RemoveVectoredExceptionHandler(exceptionHandlerHandle); + SetThreadStackGuarantee(&guaranteeSize); + exceptionHandlerHandle = nullptr; + isSet = false; + } + } + + FatalConditionHandler::~FatalConditionHandler() { + reset(); + } + +bool FatalConditionHandler::isSet = false; +ULONG FatalConditionHandler::guaranteeSize = 0; +PVOID FatalConditionHandler::exceptionHandlerHandle = nullptr; + + +} // namespace Catch + +# endif // CATCH_CONFIG_WINDOWS_SEH + +#else // Not Windows - assumed to be POSIX compatible ////////////////////////// + +# if !defined(CATCH_CONFIG_POSIX_SIGNALS) + +namespace Catch { + void FatalConditionHandler::reset() {} +} + + +# else // CATCH_CONFIG_POSIX_SIGNALS is defined + +#include + +namespace Catch { + + struct SignalDefs { + int id; + const char* name; + }; + SignalDefs signalDefs[] = { + { SIGINT, "SIGINT - Terminal interrupt signal" }, + { SIGILL, "SIGILL - Illegal instruction signal" }, + { SIGFPE, "SIGFPE - Floating point error signal" }, + { SIGSEGV, "SIGSEGV - Segmentation violation signal" }, + { SIGTERM, "SIGTERM - Termination request signal" }, + { SIGABRT, "SIGABRT - Abort (abnormal termination) signal" } + }; + + + void FatalConditionHandler::handleSignal( int sig ) { + std::string name = ""; + for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { + SignalDefs &def = signalDefs[i]; + if (sig == def.id) { + name = def.name; + break; + } + } + reset(); + reportFatal(name); + raise( sig ); + } + + FatalConditionHandler::FatalConditionHandler() { + isSet = true; + stack_t sigStack; + sigStack.ss_sp = altStackMem; + sigStack.ss_size = SIGSTKSZ; + sigStack.ss_flags = 0; + sigaltstack(&sigStack, &oldSigStack); + struct sigaction sa = { }; + + sa.sa_handler = handleSignal; + sa.sa_flags = SA_ONSTACK; + for (std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i) { + sigaction(signalDefs[i].id, &sa, &oldSigActions[i]); + } + } + + + FatalConditionHandler::~FatalConditionHandler() { + reset(); + } + + void FatalConditionHandler::reset() { + if( isSet ) { + // Set signals back to previous values -- hopefully nobody overwrote them in the meantime + for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) { + sigaction(signalDefs[i].id, &oldSigActions[i], nullptr); + } + // Return the old stack + sigaltstack(&oldSigStack, nullptr); + isSet = false; + } + } + + bool FatalConditionHandler::isSet = false; + struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = {}; + stack_t FatalConditionHandler::oldSigStack = {}; + char FatalConditionHandler::altStackMem[SIGSTKSZ] = {}; + + +} // namespace Catch + +# endif // CATCH_CONFIG_POSIX_SIGNALS + +#endif // not Windows diff --git a/include/internal/catch_fatal_condition.h b/include/internal/catch_fatal_condition.h new file mode 100644 index 00000000..97f371ae --- /dev/null +++ b/include/internal/catch_fatal_condition.h @@ -0,0 +1,92 @@ +/* + * Created by Phil on 21/08/2014 + * Copyright 2014 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_FATAL_CONDITION_H_INCLUDED +#define TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED + +#include +#include "catch_platform.h" +#include "catch_compiler_capabilities.h" + +namespace Catch { + + // Report the error condition + void reportFatal( std::string const& message ); + +} // namespace Catch + +#if defined ( CATCH_PLATFORM_WINDOWS ) ///////////////////////////////////////// +#include "catch_windows_h_proxy.h" + +# if !defined ( CATCH_CONFIG_WINDOWS_SEH ) + +namespace Catch { + struct FatalConditionHandler { + void reset(); + }; +} + +# else // CATCH_CONFIG_WINDOWS_SEH is defined + +namespace Catch { + + struct FatalConditionHandler { + + static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo); + FatalConditionHandler(); + static void reset(); + ~FatalConditionHandler(); + + private: + static bool isSet; + static ULONG guaranteeSize; + static PVOID exceptionHandlerHandle; + }; + +} // namespace Catch + +# endif // CATCH_CONFIG_WINDOWS_SEH + +#else // Not Windows - assumed to be POSIX compatible ////////////////////////// + +# if !defined(CATCH_CONFIG_POSIX_SIGNALS) + +namespace Catch { + struct FatalConditionHandler { + void reset(); + }; +} + + +# else // CATCH_CONFIG_POSIX_SIGNALS is defined + +#include + +namespace Catch { + + struct FatalConditionHandler { + + static bool isSet; + static struct sigaction oldSigActions[];// [sizeof(signalDefs) / sizeof(SignalDefs)]; + static stack_t oldSigStack; + static char altStackMem[]; + + static void handleSignal( int sig ); + + FatalConditionHandler(); + ~FatalConditionHandler(); + static void reset(); + }; + +} // namespace Catch + +# endif // CATCH_CONFIG_POSIX_SIGNALS + +#endif // not Windows + +#endif // TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED diff --git a/include/internal/catch_fatal_condition.hpp b/include/internal/catch_fatal_condition.hpp deleted file mode 100644 index 26903fe7..00000000 --- a/include/internal/catch_fatal_condition.hpp +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Created by Phil on 21/08/2014 - * Copyright 2014 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_FATAL_CONDITION_H_INCLUDED -#define TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED - - -namespace Catch { - - // Report the error condition - inline void reportFatal( std::string const& message ) { - IContext& context = Catch::getCurrentContext(); - IResultCapture* resultCapture = context.getResultCapture(); - resultCapture->handleFatalErrorCondition( message ); - } - -} // namespace Catch - -#if defined ( CATCH_PLATFORM_WINDOWS ) ///////////////////////////////////////// -#include "catch_windows_h_proxy.h" - -# if !defined ( CATCH_CONFIG_WINDOWS_SEH ) - -namespace Catch { - struct FatalConditionHandler { - void reset() {} - }; -} - -# else // CATCH_CONFIG_WINDOWS_SEH is defined - -namespace Catch { - - struct SignalDefs { DWORD id; const char* name; }; - extern SignalDefs signalDefs[]; - // There is no 1-1 mapping between signals and windows exceptions. - // Windows can easily distinguish between SO and SigSegV, - // but SigInt, SigTerm, etc are handled differently. - SignalDefs signalDefs[] = { - { EXCEPTION_ILLEGAL_INSTRUCTION, "SIGILL - Illegal instruction signal" }, - { EXCEPTION_STACK_OVERFLOW, "SIGSEGV - Stack overflow" }, - { EXCEPTION_ACCESS_VIOLATION, "SIGSEGV - Segmentation violation signal" }, - { EXCEPTION_INT_DIVIDE_BY_ZERO, "Divide by zero error" }, - }; - - struct FatalConditionHandler { - - static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { - for (int i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { - if (ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) { - reportFatal(signalDefs[i].name); - } - } - // If its not an exception we care about, pass it along. - // This stops us from eating debugger breaks etc. - return EXCEPTION_CONTINUE_SEARCH; - } - - FatalConditionHandler() { - isSet = true; - // 32k seems enough for Catch to handle stack overflow, - // but the value was found experimentally, so there is no strong guarantee - guaranteeSize = 32 * 1024; - exceptionHandlerHandle = nullptr; - // Register as first handler in current chain - exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException); - // Pass in guarantee size to be filled - SetThreadStackGuarantee(&guaranteeSize); - } - - static void reset() { - if (isSet) { - // Unregister handler and restore the old guarantee - RemoveVectoredExceptionHandler(exceptionHandlerHandle); - SetThreadStackGuarantee(&guaranteeSize); - exceptionHandlerHandle = nullptr; - isSet = false; - } - } - - ~FatalConditionHandler() { - reset(); - } - private: - static bool isSet; - static ULONG guaranteeSize; - static PVOID exceptionHandlerHandle; - }; - - bool FatalConditionHandler::isSet = false; - ULONG FatalConditionHandler::guaranteeSize = 0; - PVOID FatalConditionHandler::exceptionHandlerHandle = nullptr; - -} // namespace Catch - -# endif // CATCH_CONFIG_WINDOWS_SEH - -#else // Not Windows - assumed to be POSIX compatible ////////////////////////// - -# if !defined(CATCH_CONFIG_POSIX_SIGNALS) - -namespace Catch { - struct FatalConditionHandler { - void reset() {} - }; -} - - -# else // CATCH_CONFIG_POSIX_SIGNALS is defined - -#include - -namespace Catch { - - struct SignalDefs { - int id; - const char* name; - }; - extern SignalDefs signalDefs[]; - SignalDefs signalDefs[] = { - { SIGINT, "SIGINT - Terminal interrupt signal" }, - { SIGILL, "SIGILL - Illegal instruction signal" }, - { SIGFPE, "SIGFPE - Floating point error signal" }, - { SIGSEGV, "SIGSEGV - Segmentation violation signal" }, - { SIGTERM, "SIGTERM - Termination request signal" }, - { SIGABRT, "SIGABRT - Abort (abnormal termination) signal" } - }; - - struct FatalConditionHandler { - - static bool isSet; - static struct sigaction oldSigActions [sizeof(signalDefs)/sizeof(SignalDefs)]; - static stack_t oldSigStack; - static char altStackMem[SIGSTKSZ]; - - static void handleSignal( int sig ) { - std::string name = ""; - for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { - SignalDefs &def = signalDefs[i]; - if (sig == def.id) { - name = def.name; - break; - } - } - reset(); - reportFatal(name); - raise( sig ); - } - - FatalConditionHandler() { - isSet = true; - stack_t sigStack; - sigStack.ss_sp = altStackMem; - sigStack.ss_size = SIGSTKSZ; - sigStack.ss_flags = 0; - sigaltstack(&sigStack, &oldSigStack); - struct sigaction sa = { 0 }; - - sa.sa_handler = handleSignal; - sa.sa_flags = SA_ONSTACK; - for (std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i) { - sigaction(signalDefs[i].id, &sa, &oldSigActions[i]); - } - } - - - ~FatalConditionHandler() { - reset(); - } - static void reset() { - if( isSet ) { - // Set signals back to previous values -- hopefully nobody overwrote them in the meantime - for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) { - sigaction(signalDefs[i].id, &oldSigActions[i], nullptr); - } - // Return the old stack - sigaltstack(&oldSigStack, nullptr); - isSet = false; - } - } - }; - - bool FatalConditionHandler::isSet = false; - struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = {}; - stack_t FatalConditionHandler::oldSigStack = {}; - char FatalConditionHandler::altStackMem[SIGSTKSZ] = {}; - - -} // namespace Catch - -# endif // CATCH_CONFIG_POSIX_SIGNALS - -#endif // not Windows - -#endif // TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED diff --git a/include/internal/catch_impl.hpp b/include/internal/catch_impl.hpp index 2306af7f..934cd4d1 100644 --- a/include/internal/catch_impl.hpp +++ b/include/internal/catch_impl.hpp @@ -17,33 +17,34 @@ #endif #include "../catch_session.hpp" -#include "catch_registry_hub.hpp" -#include "catch_notimplemented_exception.hpp" -#include "catch_context_impl.hpp" -#include "catch_console_colour_impl.hpp" -#include "catch_assertionresult.hpp" -#include "catch_test_case_info.hpp" +#include "catch_stream.hpp" #include "catch_test_spec.hpp" -#include "catch_version.hpp" -#include "catch_message.hpp" -#include "catch_timer.hpp" -#include "catch_common.hpp" -#include "catch_section.hpp" -#include "catch_debugger.hpp" -#include "catch_tostring.hpp" -#include "catch_result_builder.hpp" -#include "catch_tag_alias_registry.hpp" #include "catch_test_case_tracker.hpp" -#include "catch_matchers_string.hpp" -#include "catch_startup_exception_registry.hpp" // These files are not included in the full (not single include) project // as they are compiled as proper cpp files #ifndef CATCH_CONFIG_FULL_PROJECT +# include "catch_assertionresult.cpp" +# include "catch_common.cpp" +# include "catch_console_colour.cpp" +# include "catch_context.cpp" +# include "catch_debugger.cpp" +# include "catch_matchers_string.cpp" +# include "catch_message.cpp" +# include "catch_notimplemented_exception.cpp" +# include "catch_registry_hub.cpp" +# include "catch_result_builder.hpp" +# include "catch_section.cpp" +# include "catch_startup_exception_registry.cpp" # include "catch_stringref.cpp" # include "catch_string.cpp" # include "catch_stringbuilder.cpp" # include "catch_stringdata.cpp" +# include "catch_tag_alias_registry.cpp" +# include "catch_test_case_info.cpp" +# include "catch_timer.cpp" +# include "catch_tostring.cpp" +# include "catch_version.cpp" #endif #include "../reporters/catch_reporter_multi.hpp" @@ -88,8 +89,6 @@ namespace Catch { IConfig::~IConfig() {} XmlReporter::~XmlReporter() {} JunitReporter::~JunitReporter() {} - TestRegistry::~TestRegistry() {} - FreeFunctionTestCase::~FreeFunctionTestCase() {} WildcardPattern::~WildcardPattern() {} TestSpec::Pattern::~Pattern() {} TestSpec::NamePattern::~NamePattern() {} diff --git a/include/internal/catch_matchers.hpp b/include/internal/catch_matchers.hpp index 21445347..ef039aa9 100644 --- a/include/internal/catch_matchers.hpp +++ b/include/internal/catch_matchers.hpp @@ -10,6 +10,8 @@ #include "catch_common.h" +#include + namespace Catch { namespace Matchers { namespace Impl { diff --git a/include/internal/catch_matchers_string.hpp b/include/internal/catch_matchers_string.cpp similarity index 99% rename from include/internal/catch_matchers_string.hpp rename to include/internal/catch_matchers_string.cpp index ca117eda..207193fb 100644 --- a/include/internal/catch_matchers_string.hpp +++ b/include/internal/catch_matchers_string.cpp @@ -6,7 +6,7 @@ * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ -#include "catch_matchers.hpp" +#include "catch_matchers_string.h" namespace Catch { namespace Matchers { diff --git a/include/internal/catch_message.hpp b/include/internal/catch_message.cpp similarity index 67% rename from include/internal/catch_message.hpp rename to include/internal/catch_message.cpp index 11d07466..2f474a90 100644 --- a/include/internal/catch_message.hpp +++ b/include/internal/catch_message.cpp @@ -5,10 +5,9 @@ * 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_MESSAGE_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_MESSAGE_HPP_INCLUDED #include "catch_message.h" +#include "catch_interfaces_capture.h" namespace Catch { @@ -21,12 +20,28 @@ namespace Catch { sequence( ++globalCount ) {} + bool MessageInfo::operator==( MessageInfo const& other ) const { + return sequence == other.sequence; + } + + bool MessageInfo::operator<( MessageInfo const& other ) const { + return sequence < other.sequence; + } + // This may need protecting if threading support is added unsigned int MessageInfo::globalCount = 0; //////////////////////////////////////////////////////////////////////////// + Catch::MessageBuilder::MessageBuilder( std::string const& macroName, + SourceLineInfo const& lineInfo, + ResultWas::OfType type ) + :m_info(macroName, lineInfo, type) {} + + //////////////////////////////////////////////////////////////////////////// + + ScopedMessage::ScopedMessage( MessageBuilder const& builder ) : m_info( builder.m_info ) { @@ -45,5 +60,3 @@ namespace Catch { } // end namespace Catch - -#endif // TWOBLUECUBES_CATCH_MESSAGE_HPP_INCLUDED diff --git a/include/internal/catch_message.h b/include/internal/catch_message.h index 84ff95ea..25d7c259 100644 --- a/include/internal/catch_message.h +++ b/include/internal/catch_message.h @@ -25,12 +25,8 @@ namespace Catch { std::string message; unsigned int sequence; - bool operator == ( MessageInfo const& other ) const { - return sequence == other.sequence; - } - bool operator < ( MessageInfo const& other ) const { - return sequence < other.sequence; - } + bool operator == ( MessageInfo const& other ) const; + bool operator < ( MessageInfo const& other ) const; private: static unsigned int globalCount; }; @@ -38,9 +34,7 @@ namespace Catch { struct MessageBuilder { MessageBuilder( std::string const& macroName, SourceLineInfo const& lineInfo, - ResultWas::OfType type ) - : m_info( macroName, lineInfo, type ) - {} + ResultWas::OfType type ); template MessageBuilder& operator << ( T const& value ) { diff --git a/include/internal/catch_notimplemented_exception.hpp b/include/internal/catch_notimplemented_exception.cpp similarity index 78% rename from include/internal/catch_notimplemented_exception.hpp rename to include/internal/catch_notimplemented_exception.cpp index f5b1ea66..62188ef3 100644 --- a/include/internal/catch_notimplemented_exception.hpp +++ b/include/internal/catch_notimplemented_exception.cpp @@ -5,8 +5,6 @@ * 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_NOTIMPLEMENTED_EXCEPTION_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_HPP_INCLUDED #include "catch_notimplemented_exception.h" #include @@ -26,5 +24,3 @@ namespace Catch { } } // end namespace Catch - -#endif // TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_HPP_INCLUDED diff --git a/include/internal/catch_registry_hub.hpp b/include/internal/catch_registry_hub.cpp similarity index 95% rename from include/internal/catch_registry_hub.hpp rename to include/internal/catch_registry_hub.cpp index 23c9628c..9f901085 100644 --- a/include/internal/catch_registry_hub.hpp +++ b/include/internal/catch_registry_hub.cpp @@ -5,8 +5,6 @@ * 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_REGISTRY_HUB_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_REGISTRY_HUB_HPP_INCLUDED #include "catch_interfaces_registry_hub.h" @@ -96,5 +94,3 @@ namespace Catch { } // end namespace Catch - -#endif // TWOBLUECUBES_CATCH_REGISTRY_HUB_HPP_INCLUDED diff --git a/include/internal/catch_result_builder.hpp b/include/internal/catch_result_builder.cpp similarity index 97% rename from include/internal/catch_result_builder.hpp rename to include/internal/catch_result_builder.cpp index 540e3a5a..727b42e7 100644 --- a/include/internal/catch_result_builder.hpp +++ b/include/internal/catch_result_builder.cpp @@ -5,8 +5,6 @@ * 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_RESULT_BUILDER_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_RESULT_BUILDER_HPP_INCLUDED #include "catch_result_builder.h" #include "catch_context.h" @@ -14,8 +12,11 @@ #include "catch_interfaces_runner.h" #include "catch_interfaces_capture.h" #include "catch_interfaces_registry_hub.h" +#include "catch_matchers_string.h" #include "catch_wildcard_pattern.hpp" +#include + namespace Catch { ResultBuilder::ResultBuilder( char const* macroName, @@ -158,5 +159,3 @@ namespace Catch { } } // end namespace Catch - -#endif // TWOBLUECUBES_CATCH_RESULT_BUILDER_HPP_INCLUDED diff --git a/include/internal/catch_run_context.hpp b/include/internal/catch_run_context.hpp index e4ae981b..574969c8 100644 --- a/include/internal/catch_run_context.hpp +++ b/include/internal/catch_run_context.hpp @@ -20,7 +20,7 @@ #include "catch_test_case_tracker.hpp" #include "catch_timer.h" #include "catch_result_builder.h" -#include "catch_fatal_condition.hpp" +#include "catch_fatal_condition.h" #include #include diff --git a/include/internal/catch_section.hpp b/include/internal/catch_section.cpp similarity index 91% rename from include/internal/catch_section.hpp rename to include/internal/catch_section.cpp index aab721f6..8c300415 100644 --- a/include/internal/catch_section.hpp +++ b/include/internal/catch_section.cpp @@ -5,8 +5,6 @@ * 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_SECTION_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED #include "catch_section.h" #include "catch_capture.hpp" @@ -54,5 +52,3 @@ namespace Catch { } // end namespace Catch - -#endif // TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED diff --git a/include/internal/catch_section_info.hpp b/include/internal/catch_section_info.cpp similarity index 92% rename from include/internal/catch_section_info.hpp rename to include/internal/catch_section_info.cpp index b1ce0ba8..83eb4fef 100644 --- a/include/internal/catch_section_info.hpp +++ b/include/internal/catch_section_info.cpp @@ -5,11 +5,11 @@ * 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_SECTION_INFO_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_SECTION_INFO_HPP_INCLUDED #include "catch_section_info.h" +#include + namespace Catch { class RunningSection { @@ -75,7 +75,7 @@ namespace Catch { RunningSection* findOrAddSubSection( std::string const& name, bool& changed ) { for( auto subSection : m_subSections ) if( subSection->getName() == name ) - return *it; + return subSection; RunningSection* subSection = new RunningSection( this, name ); m_subSections.push_back( subSection ); m_state = Branch; @@ -102,5 +102,3 @@ namespace Catch { SubSections m_subSections; }; } - -#endif // TWOBLUECUBES_CATCH_SECTION_INFO_HPP_INCLUDED diff --git a/include/internal/catch_startup_exception_registry.hpp b/include/internal/catch_startup_exception_registry.cpp similarity index 75% rename from include/internal/catch_startup_exception_registry.hpp rename to include/internal/catch_startup_exception_registry.cpp index caf5d894..088b6446 100644 --- a/include/internal/catch_startup_exception_registry.hpp +++ b/include/internal/catch_startup_exception_registry.cpp @@ -5,8 +5,6 @@ * 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_STARTUP_EXCEPTION_REGISTRY_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_STARTUP_EXCEPTION_REGISTRY_HPP_INCLUDED #include "catch_startup_exception_registry.h" @@ -20,5 +18,3 @@ namespace Catch { } } // end namespace Catch - -#endif // TWOBLUECUBES_CATCH_STARTUP_EXCEPTION_REGISTRY_HPP_INCLUDED diff --git a/include/internal/catch_stream.h b/include/internal/catch_stream.h index 73aa9ace..baa10c44 100644 --- a/include/internal/catch_stream.h +++ b/include/internal/catch_stream.h @@ -9,7 +9,6 @@ #ifndef TWOBLUECUBES_CATCH_STREAM_H_INCLUDED #define TWOBLUECUBES_CATCH_STREAM_H_INCLUDED -#include "catch_compiler_capabilities.h" #include "catch_streambuf.h" #include diff --git a/include/internal/catch_stream.hpp b/include/internal/catch_stream.hpp index b287548b..b0998e3f 100644 --- a/include/internal/catch_stream.hpp +++ b/include/internal/catch_stream.hpp @@ -9,6 +9,7 @@ #ifndef TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED #define TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED +#include "catch_common.h" #include "catch_stream.h" #include "catch_debugger.h" diff --git a/include/internal/catch_stringdata.cpp b/include/internal/catch_stringdata.cpp index 9f1625a8..434368de 100644 --- a/include/internal/catch_stringdata.cpp +++ b/include/internal/catch_stringdata.cpp @@ -5,7 +5,6 @@ * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ - #include "catch_stringdata.h" #include "catch_stringref.h" diff --git a/include/internal/catch_tag_alias_registry.hpp b/include/internal/catch_tag_alias_registry.cpp similarity index 93% rename from include/internal/catch_tag_alias_registry.hpp rename to include/internal/catch_tag_alias_registry.cpp index 7439c36d..f8c25a10 100644 --- a/include/internal/catch_tag_alias_registry.hpp +++ b/include/internal/catch_tag_alias_registry.cpp @@ -5,8 +5,6 @@ * 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_TAG_ALIAS_REGISTRY_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED #include "catch_tag_alias_registry.h" #include "catch_console_colour.hpp" @@ -64,5 +62,3 @@ namespace Catch { } } // end namespace Catch - -#endif // TWOBLUECUBES_CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED diff --git a/include/internal/catch_test_case_info.hpp b/include/internal/catch_test_case_info.cpp similarity index 96% rename from include/internal/catch_test_case_info.hpp rename to include/internal/catch_test_case_info.cpp index 8adf40c7..5ef88593 100644 --- a/include/internal/catch_test_case_info.hpp +++ b/include/internal/catch_test_case_info.cpp @@ -5,8 +5,6 @@ * 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_TEST_CASE_INFO_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_HPP_INCLUDED #include "catch_test_spec.hpp" #include "catch_test_case_info.h" @@ -161,5 +159,3 @@ namespace Catch { } } // end namespace Catch - -#endif // TWOBLUECUBES_CATCH_TEST_CASE_INFO_HPP_INCLUDED diff --git a/include/internal/catch_test_case_registry_impl.hpp b/include/internal/catch_test_case_registry_impl.hpp index eebde92c..d50b3b28 100644 --- a/include/internal/catch_test_case_registry_impl.hpp +++ b/include/internal/catch_test_case_registry_impl.hpp @@ -12,6 +12,7 @@ #include "catch_test_case_info.h" #include "catch_test_spec.hpp" #include "catch_context.h" +#include "catch_interfaces_config.h" #include #include @@ -119,6 +120,9 @@ namespace Catch { std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised }; + TestRegistry::~TestRegistry() {} + + /////////////////////////////////////////////////////////////////////////// class FreeFunctionTestCase : public ITestCase { @@ -136,6 +140,9 @@ namespace Catch { TestFunction m_fun; }; + FreeFunctionTestCase::~FreeFunctionTestCase() {} + + inline std::string extractClassName( std::string const& classOrQualifiedMethodName ) { std::string className = classOrQualifiedMethodName; if( startsWith( className, '&' ) ) diff --git a/include/internal/catch_timer.hpp b/include/internal/catch_timer.cpp similarity index 100% rename from include/internal/catch_timer.hpp rename to include/internal/catch_timer.cpp diff --git a/include/internal/catch_tostring.hpp b/include/internal/catch_tostring.cpp similarity index 97% rename from include/internal/catch_tostring.hpp rename to include/internal/catch_tostring.cpp index d383ba0a..7599c053 100644 --- a/include/internal/catch_tostring.hpp +++ b/include/internal/catch_tostring.cpp @@ -5,11 +5,10 @@ * 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_TOSTRING_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_TOSTRING_HPP_INCLUDED #include "catch_tostring.h" #include "catch_interfaces_config.h" +#include "catch_context.h" namespace Catch { @@ -226,5 +225,3 @@ std::string StringMaker::convert(NSObject* nsObject) { #endif } // end namespace Catch - -#endif // TWOBLUECUBES_CATCH_TOSTRING_HPP_INCLUDED diff --git a/include/internal/catch_version.hpp b/include/internal/catch_version.cpp similarity index 87% rename from include/internal/catch_version.hpp rename to include/internal/catch_version.cpp index 8f515109..d2f234ea 100644 --- a/include/internal/catch_version.hpp +++ b/include/internal/catch_version.cpp @@ -5,10 +5,9 @@ * 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_VERSION_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED #include "catch_version.h" +#include namespace Catch { @@ -37,11 +36,9 @@ namespace Catch { return os; } - inline Version libraryVersion() { + Version libraryVersion() { static Version version( 2, 0, 0, "develop", 1 ); return version; } } - -#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED diff --git a/include/internal/catch_version.h b/include/internal/catch_version.h index 9f6bc283..567ac253 100644 --- a/include/internal/catch_version.h +++ b/include/internal/catch_version.h @@ -8,6 +8,8 @@ #ifndef TWOBLUECUBES_CATCH_VERSION_H_INCLUDED #define TWOBLUECUBES_CATCH_VERSION_H_INCLUDED +#include + namespace Catch { // Versioning information @@ -32,7 +34,7 @@ namespace Catch { void operator=( Version const& ); }; - inline Version libraryVersion(); + Version libraryVersion(); } #endif // TWOBLUECUBES_CATCH_VERSION_H_INCLUDED diff --git a/include/reporters/catch_reporter_bases.hpp b/include/reporters/catch_reporter_bases.hpp index 27767060..4724c611 100644 --- a/include/reporters/catch_reporter_bases.hpp +++ b/include/reporters/catch_reporter_bases.hpp @@ -9,7 +9,7 @@ #define TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED #include "../internal/catch_interfaces_reporter.h" -#include "../internal/catch_errno_guard.hpp" +#include "../internal/catch_errno_guard.h" #include #include diff --git a/projects/SelfTest/SurrogateCpps/catch_common.cpp b/projects/SelfTest/SurrogateCpps/catch_common.cpp deleted file mode 100644 index 65377f30..00000000 --- a/projects/SelfTest/SurrogateCpps/catch_common.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// This file is only here to verify (to the extent possible) the self sufficiency of the header -#include "internal/catch_suppress_warnings.h" -#include "internal/catch_common.h" diff --git a/projects/SelfTest/SurrogateCpps/catch_message.cpp b/projects/SelfTest/SurrogateCpps/catch_message.cpp deleted file mode 100644 index 40f4403c..00000000 --- a/projects/SelfTest/SurrogateCpps/catch_message.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// This file is only here to verify (to the extent possible) the self sufficiency of the header -#include "internal/catch_suppress_warnings.h" -#include "internal/catch_message.h"