mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 11:43:29 +01:00
Rename Catch::Option to Optional
This commit is contained in:
parent
c6c46a168f
commit
4e6d306742
@ -100,7 +100,7 @@ set(INTERNAL_HEADERS
|
|||||||
${SOURCES_DIR}/internal/catch_message_info.hpp
|
${SOURCES_DIR}/internal/catch_message_info.hpp
|
||||||
${SOURCES_DIR}/internal/catch_meta.hpp
|
${SOURCES_DIR}/internal/catch_meta.hpp
|
||||||
${SOURCES_DIR}/internal/catch_move_and_forward.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_output_redirect.hpp
|
||||||
${SOURCES_DIR}/internal/catch_platform.hpp
|
${SOURCES_DIR}/internal/catch_platform.hpp
|
||||||
${SOURCES_DIR}/internal/catch_polyfills.hpp
|
${SOURCES_DIR}/internal/catch_polyfills.hpp
|
||||||
|
@ -74,7 +74,7 @@
|
|||||||
#include <catch2/internal/catch_meta.hpp>
|
#include <catch2/internal/catch_meta.hpp>
|
||||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
#include <catch2/internal/catch_noncopyable.hpp>
|
#include <catch2/internal/catch_noncopyable.hpp>
|
||||||
#include <catch2/internal/catch_option.hpp>
|
#include <catch2/internal/catch_optional.hpp>
|
||||||
#include <catch2/internal/catch_output_redirect.hpp>
|
#include <catch2/internal/catch_output_redirect.hpp>
|
||||||
#include <catch2/internal/catch_platform.hpp>
|
#include <catch2/internal/catch_platform.hpp>
|
||||||
#include <catch2/internal/catch_polyfills.hpp>
|
#include <catch2/internal/catch_polyfills.hpp>
|
||||||
|
@ -5,28 +5,28 @@
|
|||||||
// https://www.boost.org/LICENSE_1_0.txt)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
#ifndef CATCH_OPTION_HPP_INCLUDED
|
#ifndef CATCH_OPTIONAL_HPP_INCLUDED
|
||||||
#define CATCH_OPTION_HPP_INCLUDED
|
#define CATCH_OPTIONAL_HPP_INCLUDED
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
// An optional type
|
// An optional type
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class Option {
|
class Optional {
|
||||||
public:
|
public:
|
||||||
Option() : nullableValue( nullptr ) {}
|
Optional() : nullableValue( nullptr ) {}
|
||||||
Option( T const& _value )
|
Optional( T const& _value )
|
||||||
: nullableValue( new( storage ) T( _value ) )
|
: nullableValue( new( storage ) T( _value ) )
|
||||||
{}
|
{}
|
||||||
Option( Option const& _other )
|
Optional( Optional const& _other )
|
||||||
: nullableValue( _other ? new( storage ) T( *_other ) : nullptr )
|
: nullableValue( _other ? new( storage ) T( *_other ) : nullptr )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~Option() {
|
~Optional() {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
Option& operator= ( Option const& _other ) {
|
Optional& operator= ( Optional const& _other ) {
|
||||||
if( &_other != this ) {
|
if( &_other != this ) {
|
||||||
reset();
|
reset();
|
||||||
if( _other )
|
if( _other )
|
||||||
@ -34,7 +34,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
Option& operator = ( T const& _value ) {
|
Optional& operator = ( T const& _value ) {
|
||||||
reset();
|
reset();
|
||||||
nullableValue = new( storage ) T( _value );
|
nullableValue = new( storage ) T( _value );
|
||||||
return *this;
|
return *this;
|
||||||
@ -82,4 +82,4 @@ namespace Catch {
|
|||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#endif // CATCH_OPTION_HPP_INCLUDED
|
#endif // CATCH_OPTIONAL_HPP_INCLUDED
|
@ -17,7 +17,7 @@
|
|||||||
#include <catch2/internal/catch_test_case_tracker.hpp>
|
#include <catch2/internal/catch_test_case_tracker.hpp>
|
||||||
#include <catch2/catch_assertion_info.hpp>
|
#include <catch2/catch_assertion_info.hpp>
|
||||||
#include <catch2/catch_assertion_result.hpp>
|
#include <catch2/catch_assertion_result.hpp>
|
||||||
#include <catch2/internal/catch_option.hpp>
|
#include <catch2/internal/catch_optional.hpp>
|
||||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -126,7 +126,7 @@ namespace Catch {
|
|||||||
IMutableContext& m_context;
|
IMutableContext& m_context;
|
||||||
TestCaseHandle const* m_activeTestCase = nullptr;
|
TestCaseHandle const* m_activeTestCase = nullptr;
|
||||||
ITracker* m_testCaseTracker = nullptr;
|
ITracker* m_testCaseTracker = nullptr;
|
||||||
Option<AssertionResult> m_lastResult;
|
Optional<AssertionResult> m_lastResult;
|
||||||
|
|
||||||
IConfig const* m_config;
|
IConfig const* m_config;
|
||||||
Totals m_totals;
|
Totals m_totals;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
||||||
|
|
||||||
#include <catch2/internal/catch_option.hpp>
|
#include <catch2/internal/catch_optional.hpp>
|
||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -19,14 +19,14 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct LazyStat : Option<T> {
|
struct LazyStat : Optional<T> {
|
||||||
LazyStat& operator=(T const& _value) {
|
LazyStat& operator=(T const& _value) {
|
||||||
Option<T>::operator=(_value);
|
Optional<T>::operator=(_value);
|
||||||
used = false;
|
used = false;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
void reset() {
|
void reset() {
|
||||||
Option<T>::reset();
|
Optional<T>::reset();
|
||||||
used = false;
|
used = false;
|
||||||
}
|
}
|
||||||
bool used = false;
|
bool used = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user