Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/internal
diff options
context:
space:
mode:
authorMartin Hořeňovský2020-03-30 10:34:21 +0200
committerMartin Hořeňovský2020-04-24 18:58:44 +0200
commite1e6872c4c0f79731894c9b763843af33d16bdab (patch)
tree46761d72b6bf87088e152aa8f42d1b092f2c5c8b /src/catch2/internal
parent3836aa9cebbd546fc3036836aac3b2e3f5fd9b74 (diff)
downloadcatch3-e1e6872c4c0f79731894c9b763843af33d16bdab.tar.gz
Standardize header names and file locations
This is both a really big and a really small commit. It is small in that it only contains renaming, moving and modification of include directives caused by this. It is really big in the obvious way of touching something like 200 files. The new rules for naming files is simple: headers use the `.hpp` extension. The rules for physical file layout is still kinda in progress, but the basics are also simple: * Significant parts of functionality get their own subfolder * Benchmarking is in `catch2/benchmark` * Matchers are in `catch2/matchers` * Generators are in `catch2/generators` * Reporters are in `catch2/reporters` * Baseline testing facilities are in `catch2/` * Various top level folders also contain `internal` subfolder, with files that users probably do not want to include directly, at least not until they have to write something like their own reporter. * The exact files in these subfolders is likely to change later on Note that while some includes were cleaned up in this commit, it is only the low hanging fruit and further cleanup using automatic tooling will happen later. Also note that various include guards, copyright notices and file headers will also be standardized later, rather than in this commit.
Diffstat (limited to 'src/catch2/internal')
-rw-r--r--src/catch2/internal/catch_assertionhandler.cpp123
-rw-r--r--src/catch2/internal/catch_assertionhandler.hpp88
-rw-r--r--src/catch2/internal/catch_capture.hpp164
-rw-r--r--src/catch2/internal/catch_capture_matchers.cpp4
-rw-r--r--src/catch2/internal/catch_capture_matchers.hpp (renamed from src/catch2/internal/catch_capture_matchers.h)4
-rw-r--r--src/catch2/internal/catch_clara.hpp38
-rw-r--r--src/catch2/internal/catch_commandline.cpp224
-rw-r--r--src/catch2/internal/catch_commandline.hpp20
-rw-r--r--src/catch2/internal/catch_common.cpp40
-rw-r--r--src/catch2/internal/catch_common.hpp89
-rw-r--r--src/catch2/internal/catch_compiler_capabilities.hpp369
-rw-r--r--src/catch2/internal/catch_console_colour.cpp243
-rw-r--r--src/catch2/internal/catch_console_colour.hpp69
-rw-r--r--src/catch2/internal/catch_container_nonmembers.hpp2
-rw-r--r--src/catch2/internal/catch_context.cpp70
-rw-r--r--src/catch2/internal/catch_context.hpp64
-rw-r--r--src/catch2/internal/catch_debug_console.cpp41
-rw-r--r--src/catch2/internal/catch_debug_console.hpp17
-rw-r--r--src/catch2/internal/catch_debugger.cpp123
-rw-r--r--src/catch2/internal/catch_debugger.hpp61
-rw-r--r--src/catch2/internal/catch_decomposer.cpp24
-rw-r--r--src/catch2/internal/catch_decomposer.hpp260
-rw-r--r--src/catch2/internal/catch_default_main.hpp60
-rw-r--r--src/catch2/internal/catch_enforce.cpp40
-rw-r--r--src/catch2/internal/catch_enforce.hpp53
-rw-r--r--src/catch2/internal/catch_enum_values_registry.cpp75
-rw-r--r--src/catch2/internal/catch_enum_values_registry.hpp35
-rw-r--r--src/catch2/internal/catch_errno_guard.cpp15
-rw-r--r--src/catch2/internal/catch_errno_guard.hpp22
-rw-r--r--src/catch2/internal/catch_exception_translator_registry.cpp89
-rw-r--r--src/catch2/internal/catch_exception_translator_registry.hpp30
-rw-r--r--src/catch2/internal/catch_fatal_condition.cpp176
-rw-r--r--src/catch2/internal/catch_fatal_condition.hpp69
-rw-r--r--src/catch2/internal/catch_leak_detector.cpp37
-rw-r--r--src/catch2/internal/catch_leak_detector.hpp18
-rw-r--r--src/catch2/internal/catch_list.cpp111
-rw-r--r--src/catch2/internal/catch_list.hpp38
-rw-r--r--src/catch2/internal/catch_main.cpp6
-rw-r--r--src/catch2/internal/catch_meta.hpp50
-rw-r--r--src/catch2/internal/catch_option.hpp73
-rw-r--r--src/catch2/internal/catch_output_redirect.cpp146
-rw-r--r--src/catch2/internal/catch_output_redirect.hpp116
-rw-r--r--src/catch2/internal/catch_platform.hpp27
-rw-r--r--src/catch2/internal/catch_polyfills.cpp31
-rw-r--r--src/catch2/internal/catch_polyfills.hpp15
-rw-r--r--src/catch2/internal/catch_preprocessor.hpp243
-rw-r--r--src/catch2/internal/catch_random_number_generator.cpp73
-rw-r--r--src/catch2/internal/catch_random_number_generator.hpp58
-rw-r--r--src/catch2/internal/catch_reporter_registry.cpp58
-rw-r--r--src/catch2/internal/catch_reporter_registry.hpp37
-rw-r--r--src/catch2/internal/catch_result_type.cpp27
-rw-r--r--src/catch2/internal/catch_result_type.hpp55
-rw-r--r--src/catch2/internal/catch_run_context.cpp521
-rw-r--r--src/catch2/internal/catch_run_context.hpp154
-rw-r--r--src/catch2/internal/catch_section.cpp38
-rw-r--r--src/catch2/internal/catch_section.hpp51
-rw-r--r--src/catch2/internal/catch_singletons.cpp36
-rw-r--r--src/catch2/internal/catch_singletons.hpp44
-rw-r--r--src/catch2/internal/catch_startup_exception_registry.cpp26
-rw-r--r--src/catch2/internal/catch_startup_exception_registry.hpp27
-rw-r--r--src/catch2/internal/catch_stream.cpp187
-rw-r--r--src/catch2/internal/catch_stream.hpp67
-rw-r--r--src/catch2/internal/catch_string_manip.cpp109
-rw-r--r--src/catch2/internal/catch_string_manip.hpp45
-rw-r--r--src/catch2/internal/catch_stringref.cpp47
-rw-r--r--src/catch2/internal/catch_tag_alias_registry.cpp58
-rw-r--r--src/catch2/internal/catch_tag_alias_registry.hpp31
-rw-r--r--src/catch2/internal/catch_test_case_registry_impl.cpp120
-rw-r--r--src/catch2/internal/catch_test_case_registry_impl.hpp73
-rw-r--r--src/catch2/internal/catch_test_case_tracker.cpp247
-rw-r--r--src/catch2/internal/catch_test_case_tracker.hpp160
-rw-r--r--src/catch2/internal/catch_test_registry.cpp34
-rw-r--r--src/catch2/internal/catch_test_registry.hpp422
-rw-r--r--src/catch2/internal/catch_test_spec_parser.cpp241
-rw-r--r--src/catch2/internal/catch_test_spec_parser.hpp78
-rw-r--r--src/catch2/internal/catch_text.hpp17
-rw-r--r--src/catch2/internal/catch_to_string.hpp28
-rw-r--r--src/catch2/internal/catch_uncaught_exceptions.cpp21
-rw-r--r--src/catch2/internal/catch_uncaught_exceptions.hpp15
-rw-r--r--src/catch2/internal/catch_wildcard_pattern.cpp47
-rw-r--r--src/catch2/internal/catch_wildcard_pattern.hpp38
-rw-r--r--src/catch2/internal/catch_windows_h_proxy.hpp39
-rw-r--r--src/catch2/internal/catch_xmlwriter.cpp334
-rw-r--r--src/catch2/internal/catch_xmlwriter.hpp116
84 files changed, 7486 insertions, 5 deletions
diff --git a/src/catch2/internal/catch_assertionhandler.cpp b/src/catch2/internal/catch_assertionhandler.cpp
new file mode 100644
index 00000000..0fe95f50
--- /dev/null
+++ b/src/catch2/internal/catch_assertionhandler.cpp
@@ -0,0 +1,123 @@
+/*
+ * Created by Phil on 8/8/2017.
+ * Copyright 2017 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 <catch2/internal/catch_assertionhandler.hpp>
+#include <catch2/catch_assertion_result.hpp>
+#include <catch2/interfaces/catch_interfaces_runner.hpp>
+#include <catch2/interfaces/catch_interfaces_config.hpp>
+#include <catch2/internal/catch_context.hpp>
+#include <catch2/internal/catch_enforce.hpp>
+#include <catch2/internal/catch_debugger.hpp>
+#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
+#include <catch2/internal/catch_capture_matchers.hpp>
+#include <catch2/internal/catch_run_context.hpp>
+#include <catch2/matchers/catch_matchers_string.hpp>
+
+namespace Catch {
+
+ namespace {
+ auto operator <<( std::ostream& os, ITransientExpression const& expr ) -> std::ostream& {
+ expr.streamReconstructedExpression( os );
+ return os;
+ }
+ }
+
+ LazyExpression::LazyExpression( bool isNegated )
+ : m_isNegated( isNegated )
+ {}
+
+ LazyExpression::LazyExpression( LazyExpression const& other ) : m_isNegated( other.m_isNegated ) {}
+
+ LazyExpression::operator bool() const {
+ return m_transientExpression != nullptr;
+ }
+
+ auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream& {
+ if( lazyExpr.m_isNegated )
+ os << "!";
+
+ if( lazyExpr ) {
+ if( lazyExpr.m_isNegated && lazyExpr.m_transientExpression->isBinaryExpression() )
+ os << "(" << *lazyExpr.m_transientExpression << ")";
+ else
+ os << *lazyExpr.m_transientExpression;
+ }
+ else {
+ os << "{** error - unchecked empty expression requested **}";
+ }
+ return os;
+ }
+
+ AssertionHandler::AssertionHandler
+ ( StringRef const& macroName,
+ SourceLineInfo const& lineInfo,
+ StringRef capturedExpression,
+ ResultDisposition::Flags resultDisposition )
+ : m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition },
+ m_resultCapture( getResultCapture() )
+ {}
+
+ void AssertionHandler::handleExpr( ITransientExpression const& expr ) {
+ m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction );
+ }
+ void AssertionHandler::handleMessage(ResultWas::OfType resultType, StringRef const& message) {
+ m_resultCapture.handleMessage( m_assertionInfo, resultType, message, m_reaction );
+ }
+
+ auto AssertionHandler::allowThrows() const -> bool {
+ return getCurrentContext().getConfig()->allowThrows();
+ }
+
+ void AssertionHandler::complete() {
+ setCompleted();
+ if( m_reaction.shouldDebugBreak ) {
+
+ // If you find your debugger stopping you here then go one level up on the
+ // call-stack for the code that caused it (typically a failed assertion)
+
+ // (To go back to the test and change execution, jump over the throw, next)
+ CATCH_BREAK_INTO_DEBUGGER();
+ }
+ if (m_reaction.shouldThrow) {
+#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
+ throw Catch::TestFailureException();
+#else
+ CATCH_ERROR( "Test failure requires aborting test!" );
+#endif
+ }
+ }
+ void AssertionHandler::setCompleted() {
+ m_completed = true;
+ }
+
+ void AssertionHandler::handleUnexpectedInflightException() {
+ m_resultCapture.handleUnexpectedInflightException( m_assertionInfo, Catch::translateActiveException(), m_reaction );
+ }
+
+ void AssertionHandler::handleExceptionThrownAsExpected() {
+ m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction);
+ }
+ void AssertionHandler::handleExceptionNotThrownAsExpected() {
+ m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction);
+ }
+
+ void AssertionHandler::handleUnexpectedExceptionNotThrown() {
+ m_resultCapture.handleUnexpectedExceptionNotThrown( m_assertionInfo, m_reaction );
+ }
+
+ void AssertionHandler::handleThrowingCallSkipped() {
+ m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction);
+ }
+
+ // This is the overload that takes a string and infers the Equals matcher from it
+ // The more general overload, that takes any string matcher, is in catch_capture_matchers.cpp
+ void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef const& matcherString ) {
+ handleExceptionMatchExpr( handler, Matchers::Equals( str ), matcherString );
+ }
+
+} // namespace Catch
diff --git a/src/catch2/internal/catch_assertionhandler.hpp b/src/catch2/internal/catch_assertionhandler.hpp
new file mode 100644
index 00000000..b3bf031d
--- /dev/null
+++ b/src/catch2/internal/catch_assertionhandler.hpp
@@ -0,0 +1,88 @@
+/*
+ * Created by Phil on 8/8/2017.
+ * Copyright 2017 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_ASSERTIONHANDLER_H_INCLUDED
+#define TWOBLUECUBES_CATCH_ASSERTIONHANDLER_H_INCLUDED
+
+#include <catch2/catch_assertion_info.hpp>
+#include <catch2/internal/catch_decomposer.hpp>
+#include <catch2/interfaces/catch_interfaces_capture.hpp>
+
+namespace Catch {
+
+ struct TestFailureException{};
+ struct AssertionResultData;
+ struct IResultCapture;
+ class RunContext;
+
+ class LazyExpression {
+ friend class AssertionHandler;
+ friend struct AssertionStats;
+ friend class RunContext;
+
+ ITransientExpression const* m_transientExpression = nullptr;
+ bool m_isNegated;
+ public:
+ LazyExpression( bool isNegated );
+ LazyExpression( LazyExpression const& other );
+ LazyExpression& operator = ( LazyExpression const& ) = delete;
+
+ explicit operator bool() const;
+
+ friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&;
+ };
+
+ struct AssertionReaction {
+ bool shouldDebugBreak = false;
+ bool shouldThrow = false;
+ };
+
+ class AssertionHandler {
+ AssertionInfo m_assertionInfo;
+ AssertionReaction m_reaction;
+ bool m_completed = false;
+ IResultCapture& m_resultCapture;
+
+ public:
+ AssertionHandler
+ ( StringRef const& macroName,
+ SourceLineInfo const& lineInfo,
+ StringRef capturedExpression,
+ ResultDisposition::Flags resultDisposition );
+ ~AssertionHandler() {
+ if ( !m_completed ) {
+ m_resultCapture.handleIncomplete( m_assertionInfo );
+ }
+ }
+
+
+ template<typename T>
+ void handleExpr( ExprLhs<T> const& expr ) {
+ handleExpr( expr.makeUnaryExpr() );
+ }
+ void handleExpr( ITransientExpression const& expr );
+
+ void handleMessage(ResultWas::OfType resultType, StringRef const& message);
+
+ void handleExceptionThrownAsExpected();
+ void handleUnexpectedExceptionNotThrown();
+ void handleExceptionNotThrownAsExpected();
+ void handleThrowingCallSkipped();
+ void handleUnexpectedInflightException();
+
+ void complete();
+ void setCompleted();
+
+ // query
+ auto allowThrows() const -> bool;
+ };
+
+ void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef const& matcherString );
+
+} // namespace Catch
+
+#endif // TWOBLUECUBES_CATCH_ASSERTIONHANDLER_H_INCLUDED
diff --git a/src/catch2/internal/catch_capture.hpp b/src/catch2/internal/catch_capture.hpp
new file mode 100644
index 00000000..369076a7
--- /dev/null
+++ b/src/catch2/internal/catch_capture.hpp
@@ -0,0 +1,164 @@
+/*
+ * Created by Phil on 18/10/2010.
+ * Copyright 2010 Two Blue Cubes Ltd. All rights reserved.