From 4e6d306742cdaab773bf98277e30e77922bb8ee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Tue, 5 Oct 2021 20:11:42 +0200 Subject: [PATCH] Rename Catch::Option to Optional --- src/CMakeLists.txt | 2 +- src/catch2/catch_all.hpp | 2 +- .../{catch_option.hpp => catch_optional.hpp} | 20 +++++++++---------- src/catch2/internal/catch_run_context.hpp | 4 ++-- .../catch_reporter_streaming_base.hpp | 8 ++++---- 5 files changed, 18 insertions(+), 18 deletions(-) rename src/catch2/internal/{catch_option.hpp => catch_optional.hpp} (83%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7e30c1a4..1a6b0215 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -100,7 +100,7 @@ set(INTERNAL_HEADERS ${SOURCES_DIR}/internal/catch_message_info.hpp ${SOURCES_DIR}/internal/catch_meta.hpp ${SOURCES_DIR}/internal/catch_move_and_forward.hpp - ${SOURCES_DIR}/internal/catch_option.hpp + ${SOURCES_DIR}/internal/catch_optional.hpp ${SOURCES_DIR}/internal/catch_output_redirect.hpp ${SOURCES_DIR}/internal/catch_platform.hpp ${SOURCES_DIR}/internal/catch_polyfills.hpp diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp index 35bd9741..e9fadf96 100644 --- a/src/catch2/catch_all.hpp +++ b/src/catch2/catch_all.hpp @@ -74,7 +74,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/catch2/internal/catch_option.hpp b/src/catch2/internal/catch_optional.hpp similarity index 83% rename from src/catch2/internal/catch_option.hpp rename to src/catch2/internal/catch_optional.hpp index da335653..e2d7b057 100644 --- a/src/catch2/internal/catch_option.hpp +++ b/src/catch2/internal/catch_optional.hpp @@ -5,28 +5,28 @@ // https://www.boost.org/LICENSE_1_0.txt) // SPDX-License-Identifier: BSL-1.0 -#ifndef CATCH_OPTION_HPP_INCLUDED -#define CATCH_OPTION_HPP_INCLUDED +#ifndef CATCH_OPTIONAL_HPP_INCLUDED +#define CATCH_OPTIONAL_HPP_INCLUDED namespace Catch { // An optional type template - class Option { + class Optional { public: - Option() : nullableValue( nullptr ) {} - Option( T const& _value ) + Optional() : nullableValue( nullptr ) {} + Optional( T const& _value ) : nullableValue( new( storage ) T( _value ) ) {} - Option( Option const& _other ) + Optional( Optional const& _other ) : nullableValue( _other ? new( storage ) T( *_other ) : nullptr ) {} - ~Option() { + ~Optional() { reset(); } - Option& operator= ( Option const& _other ) { + Optional& operator= ( Optional const& _other ) { if( &_other != this ) { reset(); if( _other ) @@ -34,7 +34,7 @@ namespace Catch { } return *this; } - Option& operator = ( T const& _value ) { + Optional& operator = ( T const& _value ) { reset(); nullableValue = new( storage ) T( _value ); return *this; @@ -82,4 +82,4 @@ namespace Catch { } // end namespace Catch -#endif // CATCH_OPTION_HPP_INCLUDED +#endif // CATCH_OPTIONAL_HPP_INCLUDED diff --git a/src/catch2/internal/catch_run_context.hpp b/src/catch2/internal/catch_run_context.hpp index 7c315e9a..e0b64a04 100644 --- a/src/catch2/internal/catch_run_context.hpp +++ b/src/catch2/internal/catch_run_context.hpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include @@ -126,7 +126,7 @@ namespace Catch { IMutableContext& m_context; TestCaseHandle const* m_activeTestCase = nullptr; ITracker* m_testCaseTracker = nullptr; - Option m_lastResult; + Optional m_lastResult; IConfig const* m_config; Totals m_totals; diff --git a/src/catch2/reporters/catch_reporter_streaming_base.hpp b/src/catch2/reporters/catch_reporter_streaming_base.hpp index e7b6e5b3..ee40fbeb 100644 --- a/src/catch2/reporters/catch_reporter_streaming_base.hpp +++ b/src/catch2/reporters/catch_reporter_streaming_base.hpp @@ -10,7 +10,7 @@ #include -#include +#include #include #include @@ -19,14 +19,14 @@ namespace Catch { template - struct LazyStat : Option { + struct LazyStat : Optional { LazyStat& operator=(T const& _value) { - Option::operator=(_value); + Optional::operator=(_value); used = false; return *this; } void reset() { - Option::reset(); + Optional::reset(); used = false; } bool used = false;