diff --git a/extras/catch_amalgamated.cpp b/extras/catch_amalgamated.cpp index b931d47c..c85f39b3 100644 --- a/extras/catch_amalgamated.cpp +++ b/extras/catch_amalgamated.cpp @@ -84,7 +84,7 @@ namespace Catch { std::vector samples2; samples2.reserve(samples.size()); for (auto s : samples) { - samples2.emplace_back( s ); + samples2.push_back( FDuration( s ) ); } return { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 10e38dda..1b5a7a8b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -101,7 +101,6 @@ set(IMPL_HEADERS ${SOURCES_DIR}/internal/catch_meta.hpp ${SOURCES_DIR}/internal/catch_move_and_forward.hpp ${SOURCES_DIR}/internal/catch_noncopyable.hpp - ${SOURCES_DIR}/internal/catch_optional.hpp ${SOURCES_DIR}/internal/catch_output_redirect.hpp ${SOURCES_DIR}/internal/catch_parse_numbers.hpp ${SOURCES_DIR}/internal/catch_platform.hpp diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp index 74db3ef0..4c9ea994 100644 --- a/src/catch2/catch_all.hpp +++ b/src/catch2/catch_all.hpp @@ -82,7 +82,6 @@ #include #include #include -#include #include #include #include diff --git a/src/catch2/catch_config.cpp b/src/catch2/catch_config.cpp index 352c1f42..4e5c9e2c 100644 --- a/src/catch2/catch_config.cpp +++ b/src/catch2/catch_config.cpp @@ -17,6 +17,7 @@ #include #include +#include namespace Catch { @@ -34,7 +35,7 @@ namespace Catch { std::string shardFilePath; }; - static Optional readBazelShardingOptions() { + static std::optional readBazelShardingOptions() { const auto bazelShardIndex = Detail::getEnv( "TEST_SHARD_INDEX" ); const auto bazelShardTotal = Detail::getEnv( "TEST_TOTAL_SHARDS" ); const auto bazelShardInfoFile = Detail::getEnv( "TEST_SHARD_STATUS_FILE" ); @@ -142,7 +143,7 @@ namespace Catch { // We do the default-output check separately, while always // using the default output below to make the code simpler // and avoid superfluous copies. - if ( reporterSpec.outputFile().none() ) { + if ( !reporterSpec.outputFile() ) { CATCH_ENFORCE( !defaultOutputUsed, "Internal error: cannot use default output for " "multiple reporters" ); @@ -153,7 +154,7 @@ namespace Catch { reporterSpec.name(), reporterSpec.outputFile() ? *reporterSpec.outputFile() : data.defaultOutputFilename, - reporterSpec.colourMode().valueOr( data.defaultColourMode ), + reporterSpec.colourMode().value_or( data.defaultColourMode ), reporterSpec.customOptions() } ); } } diff --git a/src/catch2/catch_config.hpp b/src/catch2/catch_config.hpp index b7b1315e..e22f2d3e 100644 --- a/src/catch2/catch_config.hpp +++ b/src/catch2/catch_config.hpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/src/catch2/internal/catch_commandline.cpp b/src/catch2/internal/catch_commandline.cpp index 212f1774..67465089 100644 --- a/src/catch2/internal/catch_commandline.cpp +++ b/src/catch2/internal/catch_commandline.cpp @@ -88,7 +88,7 @@ namespace Catch { return ParserResult::ok( ParseResultType::Matched ); }; auto const setDefaultColourMode = [&]( std::string const& colourMode ) { - Optional maybeMode = Catch::Detail::stringToColourMode(toLower( colourMode )); + std::optional maybeMode = Catch::Detail::stringToColourMode(toLower( colourMode )); if ( !maybeMode ) { return ParserResult::runtimeError( "colour mode must be one of: default, ansi, win32, " @@ -135,7 +135,7 @@ namespace Catch { return ParserResult::runtimeError( "Received empty reporter spec." ); } - Optional parsed = + std::optional parsed = parseReporterSpec( userReporterSpec ); if ( !parsed ) { return ParserResult::runtimeError( @@ -156,7 +156,7 @@ namespace Catch { } - const bool hadOutputFile = reporterSpec.outputFile().some(); + const bool hadOutputFile = reporterSpec.outputFile().has_value(); config.reporterSpecifications.push_back( CATCH_MOVE( *parsed ) ); // It would be enough to check this only once at the very end, but // there is not a place where we could call this check, so do it @@ -165,7 +165,7 @@ namespace Catch { if (!hadOutputFile) { int n_reporters_without_file = 0; for (auto const& spec : config.reporterSpecifications) { - if (spec.outputFile().none()) { + if (!spec.outputFile()) { n_reporters_without_file++; } } diff --git a/src/catch2/internal/catch_optional.hpp b/src/catch2/internal/catch_optional.hpp deleted file mode 100644 index d1e953ad..00000000 --- a/src/catch2/internal/catch_optional.hpp +++ /dev/null @@ -1,117 +0,0 @@ - -// Copyright Catch2 Authors -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.txt or copy at -// https://www.boost.org/LICENSE_1_0.txt) - -// SPDX-License-Identifier: BSL-1.0 -#ifndef CATCH_OPTIONAL_HPP_INCLUDED -#define CATCH_OPTIONAL_HPP_INCLUDED - -#include - -#include - -namespace Catch { - - // An optional type - template - class Optional { - public: - Optional(): nullableValue( nullptr ) {} - ~Optional() { reset(); } - - Optional( T const& _value ): - nullableValue( new ( storage ) T( _value ) ) {} - Optional( T&& _value ): - nullableValue( new ( storage ) T( CATCH_MOVE( _value ) ) ) {} - - Optional& operator=( T const& _value ) { - reset(); - nullableValue = new ( storage ) T( _value ); - return *this; - } - Optional& operator=( T&& _value ) { - reset(); - nullableValue = new ( storage ) T( CATCH_MOVE( _value ) ); - return *this; - } - - Optional( Optional const& _other ): - nullableValue( _other ? new ( storage ) T( *_other ) : nullptr ) {} - Optional( Optional&& _other ): - nullableValue( _other ? new ( storage ) T( CATCH_MOVE( *_other ) ) - : nullptr ) {} - - Optional& operator=( Optional const& _other ) { - if ( &_other != this ) { - reset(); - if ( _other ) { nullableValue = new ( storage ) T( *_other ); } - } - return *this; - } - Optional& operator=( Optional&& _other ) { - if ( &_other != this ) { - reset(); - if ( _other ) { - nullableValue = new ( storage ) T( CATCH_MOVE( *_other ) ); - } - } - return *this; - } - - void reset() { - if ( nullableValue ) { nullableValue->~T(); } - nullableValue = nullptr; - } - - T& operator*() { - assert(nullableValue); - return *nullableValue; - } - T const& operator*() const { - assert(nullableValue); - return *nullableValue; - } - T* operator->() { - assert(nullableValue); - return nullableValue; - } - const T* operator->() const { - assert(nullableValue); - return nullableValue; - } - - T valueOr( T const& defaultValue ) const { - return nullableValue ? *nullableValue : defaultValue; - } - - bool some() const { return nullableValue != nullptr; } - bool none() const { return nullableValue == nullptr; } - - bool operator !() const { return nullableValue == nullptr; } - explicit operator bool() const { - return some(); - } - - friend bool operator==(Optional const& a, Optional const& b) { - if (a.none() && b.none()) { - return true; - } else if (a.some() && b.some()) { - return *a == *b; - } else { - return false; - } - } - friend bool operator!=(Optional const& a, Optional const& b) { - return !( a == b ); - } - - private: - T* nullableValue; - alignas(alignof(T)) char storage[sizeof(T)]; - }; - -} // end namespace Catch - -#endif // CATCH_OPTIONAL_HPP_INCLUDED diff --git a/src/catch2/internal/catch_parse_numbers.cpp b/src/catch2/internal/catch_parse_numbers.cpp index d949ac19..9e46699d 100644 --- a/src/catch2/internal/catch_parse_numbers.cpp +++ b/src/catch2/internal/catch_parse_numbers.cpp @@ -12,10 +12,11 @@ #include #include +#include namespace Catch { - Optional parseUInt(std::string const& input, int base) { + std::optional parseUInt(std::string const& input, int base) { auto trimmed = trim( input ); // std::stoull is annoying and accepts numbers starting with '-', // it just negates them into unsigned int diff --git a/src/catch2/internal/catch_parse_numbers.hpp b/src/catch2/internal/catch_parse_numbers.hpp index 3dabf95f..ee67a534 100644 --- a/src/catch2/internal/catch_parse_numbers.hpp +++ b/src/catch2/internal/catch_parse_numbers.hpp @@ -8,8 +8,7 @@ #ifndef CATCH_PARSE_NUMBERS_HPP_INCLUDED #define CATCH_PARSE_NUMBERS_HPP_INCLUDED -#include - +#include #include namespace Catch { @@ -20,7 +19,7 @@ namespace Catch { * Effectively a wrapper around std::stoul but with better error checking * e.g. "-1" is rejected, instead of being parsed as UINT_MAX. */ - Optional parseUInt(std::string const& input, int base = 10); + std::optional parseUInt(std::string const& input, int base = 10); } #endif // CATCH_PARSE_NUMBERS_HPP_INCLUDED diff --git a/src/catch2/internal/catch_reporter_spec_parser.cpp b/src/catch2/internal/catch_reporter_spec_parser.cpp index 2b08758a..fef96ee8 100644 --- a/src/catch2/internal/catch_reporter_spec_parser.cpp +++ b/src/catch2/internal/catch_reporter_spec_parser.cpp @@ -80,7 +80,7 @@ namespace Catch { return parts; } - Optional stringToColourMode( StringRef colourMode ) { + std::optional stringToColourMode( StringRef colourMode ) { if ( colourMode == "default" ) { return ColourMode::PlatformDefault; } else if ( colourMode == "ansi" ) { @@ -103,14 +103,14 @@ namespace Catch { lhs.m_customOptions == rhs.m_customOptions; } - Optional parseReporterSpec( StringRef reporterSpec ) { + std::optional parseReporterSpec( StringRef reporterSpec ) { auto parts = Detail::splitReporterSpec( reporterSpec ); assert( parts.size() > 0 && "Split should never return empty vector" ); std::map kvPairs; - Optional outputFileName; - Optional colourMode; + std::optional outputFileName; + std::optional colourMode; // First part is always reporter name, so we skip it for ( size_t i = 1; i < parts.size(); ++i ) { @@ -162,8 +162,8 @@ namespace Catch { ReporterSpec::ReporterSpec( std::string name, - Optional outputFileName, - Optional colourMode, + std::optional outputFileName, + std::optional colourMode, std::map customOptions ): m_name( CATCH_MOVE( name ) ), m_outputFileName( CATCH_MOVE( outputFileName ) ), diff --git a/src/catch2/internal/catch_reporter_spec_parser.hpp b/src/catch2/internal/catch_reporter_spec_parser.hpp index 9f447ee2..daad31df 100644 --- a/src/catch2/internal/catch_reporter_spec_parser.hpp +++ b/src/catch2/internal/catch_reporter_spec_parser.hpp @@ -9,12 +9,12 @@ #define CATCH_REPORTER_SPEC_PARSER_HPP_INCLUDED #include -#include #include #include #include #include +#include namespace Catch { @@ -24,7 +24,7 @@ namespace Catch { //! Splits the reporter spec into reporter name and kv-pair options std::vector splitReporterSpec( StringRef reporterSpec ); - Optional stringToColourMode( StringRef colourMode ); + std::optional stringToColourMode( StringRef colourMode ); } /** @@ -37,8 +37,8 @@ namespace Catch { */ class ReporterSpec { std::string m_name; - Optional m_outputFileName; - Optional m_colourMode; + std::optional m_outputFileName; + std::optional m_colourMode; std::map m_customOptions; friend bool operator==( ReporterSpec const& lhs, @@ -51,17 +51,17 @@ namespace Catch { public: ReporterSpec( std::string name, - Optional outputFileName, - Optional colourMode, + std::optional outputFileName, + std::optional colourMode, std::map customOptions ); std::string const& name() const { return m_name; } - Optional const& outputFile() const { + std::optional const& outputFile() const { return m_outputFileName; } - Optional const& colourMode() const { return m_colourMode; } + std::optional const& colourMode() const { return m_colourMode; } std::map const& customOptions() const { return m_customOptions; @@ -78,7 +78,7 @@ namespace Catch { * * empty key/value in an custom kv pair * * ... */ - Optional parseReporterSpec( StringRef reporterSpec ); + std::optional parseReporterSpec( StringRef reporterSpec ); } diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp index 3ca15fd0..e7f43fea 100644 --- a/src/catch2/internal/catch_run_context.cpp +++ b/src/catch2/internal/catch_run_context.cpp @@ -355,7 +355,7 @@ namespace Catch { // Reset working state. assertion info will be reset after // populateReaction is run if it is needed - m_lastResult = CATCH_MOVE( result ); + m_lastResult.emplace(CATCH_MOVE( result )); } void RunContext::notifyAssertionStarted( AssertionInfo const& info ) { diff --git a/src/catch2/internal/catch_run_context.hpp b/src/catch2/internal/catch_run_context.hpp index 1ff9caf6..a98608cf 100644 --- a/src/catch2/internal/catch_run_context.hpp +++ b/src/catch2/internal/catch_run_context.hpp @@ -18,10 +18,10 @@ #include #include #include -#include #include #include +#include #include namespace Catch { @@ -144,7 +144,7 @@ namespace Catch { TestRunInfo m_runInfo; TestCaseHandle const* m_activeTestCase = nullptr; ITracker* m_testCaseTracker = nullptr; - Optional m_lastResult; + std::optional m_lastResult; IConfig const* m_config; Totals m_totals; Detail::AtomicCounts m_atomicAssertionCount; diff --git a/src/catch2/meson.build b/src/catch2/meson.build index 861869a2..7116c85c 100644 --- a/src/catch2/meson.build +++ b/src/catch2/meson.build @@ -108,7 +108,6 @@ internal_headers = [ 'internal/catch_meta.hpp', 'internal/catch_move_and_forward.hpp', 'internal/catch_noncopyable.hpp', - 'internal/catch_optional.hpp', 'internal/catch_output_redirect.hpp', 'internal/catch_parse_numbers.hpp', 'internal/catch_platform.hpp', diff --git a/src/catch2/reporters/catch_reporter_cumulative_base.cpp b/src/catch2/reporters/catch_reporter_cumulative_base.cpp index 09169632..d31f3c37 100644 --- a/src/catch2/reporters/catch_reporter_cumulative_base.cpp +++ b/src/catch2/reporters/catch_reporter_cumulative_base.cpp @@ -42,19 +42,19 @@ namespace Catch { m_benchmark( benchmark ) {} bool AssertionOrBenchmarkResult::isAssertion() const { - return m_assertion.some(); + return m_assertion.has_value(); } bool AssertionOrBenchmarkResult::isBenchmark() const { - return m_benchmark.some(); + return m_benchmark.has_value(); } AssertionStats const& AssertionOrBenchmarkResult::asAssertion() const { - assert(m_assertion.some()); + assert(m_assertion.has_value()); return *m_assertion; } BenchmarkStats<> const& AssertionOrBenchmarkResult::asBenchmark() const { - assert(m_benchmark.some()); + assert(m_benchmark.has_value()); return *m_benchmark; } diff --git a/src/catch2/reporters/catch_reporter_cumulative_base.hpp b/src/catch2/reporters/catch_reporter_cumulative_base.hpp index 267b39fd..964e97b8 100644 --- a/src/catch2/reporters/catch_reporter_cumulative_base.hpp +++ b/src/catch2/reporters/catch_reporter_cumulative_base.hpp @@ -11,8 +11,8 @@ #include #include #include -#include +#include #include #include @@ -25,8 +25,8 @@ namespace Catch { // This should really be a variant, but this is much faster // to write and the data layout here is already terrible // enough that we do not have to care about the object size. - Optional m_assertion; - Optional> m_benchmark; + std::optional m_assertion; + std::optional> m_benchmark; public: AssertionOrBenchmarkResult(AssertionStats const& assertion); AssertionOrBenchmarkResult(BenchmarkStats<> const& benchmark); diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt index 229292ab..fe41ba85 100644 --- a/tests/SelfTest/Baselines/compact.sw.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.approved.txt @@ -1364,10 +1364,10 @@ Matchers.tests.cpp:: passed: ( EvilMatcher(), EvilMatcher() ), Evil Matchers.tests.cpp:: passed: &EvilMatcher(), EvilAddressOfOperatorUsed Matchers.tests.cpp:: passed: EvilMatcher() || ( EvilMatcher() && !EvilMatcher() ) Matchers.tests.cpp:: passed: ( EvilMatcher() && EvilMatcher() ) || !EvilMatcher() -Parse.tests.cpp:: passed: parseUInt( "0" ) == Optional{ 0 } for: {?} == {?} -Parse.tests.cpp:: passed: parseUInt( "100" ) == Optional{ 100 } for: {?} == {?} -Parse.tests.cpp:: passed: parseUInt( "4294967295" ) == Optional{ 4294967295 } for: {?} == {?} -Parse.tests.cpp:: passed: parseUInt( "0x", 16 ) == Optional{ 255 } for: {?} == {?} +Parse.tests.cpp:: passed: parseUInt( "0" ) == std::optional{ 0 } for: {?} == {?} +Parse.tests.cpp:: passed: parseUInt( "100" ) == std::optional{ 100 } for: {?} == {?} +Parse.tests.cpp:: passed: parseUInt( "4294967295" ) == std::optional{ 4294967295 } for: {?} == {?} +Parse.tests.cpp:: passed: parseUInt( "0x", 16 ) == std::optional{ 255 } for: {?} == {?} Parse.tests.cpp:: passed: !(parseUInt( "" )) for: !{?} Parse.tests.cpp:: passed: !(parseUInt( "!!KJHF*#" )) for: !{?} Parse.tests.cpp:: passed: !(parseUInt( "-1" )) for: !{?} diff --git a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt index ecec0bf5..eb8ecd60 100644 --- a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt @@ -1362,10 +1362,10 @@ Matchers.tests.cpp:: passed: ( EvilMatcher(), EvilMatcher() ), Evil Matchers.tests.cpp:: passed: &EvilMatcher(), EvilAddressOfOperatorUsed Matchers.tests.cpp:: passed: EvilMatcher() || ( EvilMatcher() && !EvilMatcher() ) Matchers.tests.cpp:: passed: ( EvilMatcher() && EvilMatcher() ) || !EvilMatcher() -Parse.tests.cpp:: passed: parseUInt( "0" ) == Optional{ 0 } for: {?} == {?} -Parse.tests.cpp:: passed: parseUInt( "100" ) == Optional{ 100 } for: {?} == {?} -Parse.tests.cpp:: passed: parseUInt( "4294967295" ) == Optional{ 4294967295 } for: {?} == {?} -Parse.tests.cpp:: passed: parseUInt( "0x", 16 ) == Optional{ 255 } for: {?} == {?} +Parse.tests.cpp:: passed: parseUInt( "0" ) == std::optional{ 0 } for: {?} == {?} +Parse.tests.cpp:: passed: parseUInt( "100" ) == std::optional{ 100 } for: {?} == {?} +Parse.tests.cpp:: passed: parseUInt( "4294967295" ) == std::optional{ 4294967295 } for: {?} == {?} +Parse.tests.cpp:: passed: parseUInt( "0x", 16 ) == std::optional{ 255 } for: {?} == {?} Parse.tests.cpp:: passed: !(parseUInt( "" )) for: !{?} Parse.tests.cpp:: passed: !(parseUInt( "!!KJHF*#" )) for: !{?} Parse.tests.cpp:: passed: !(parseUInt( "-1" )) for: !{?} diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt index 3faeea4c..28e344fb 100644 --- a/tests/SelfTest/Baselines/console.sw.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.approved.txt @@ -8848,22 +8848,22 @@ Parse.tests.cpp: ............................................................................... Parse.tests.cpp:: PASSED: - REQUIRE( parseUInt( "0" ) == Optional{ 0 } ) + REQUIRE( parseUInt( "0" ) == std::optional{ 0 } ) with expansion: {?} == {?} Parse.tests.cpp:: PASSED: - REQUIRE( parseUInt( "100" ) == Optional{ 100 } ) + REQUIRE( parseUInt( "100" ) == std::optional{ 100 } ) with expansion: {?} == {?} Parse.tests.cpp:: PASSED: - REQUIRE( parseUInt( "4294967295" ) == Optional{ 4294967295 } ) + REQUIRE( parseUInt( "4294967295" ) == std::optional{ 4294967295 } ) with expansion: {?} == {?} Parse.tests.cpp:: PASSED: - REQUIRE( parseUInt( "0x", 16 ) == Optional{ 255 } ) + REQUIRE( parseUInt( "0x", 16 ) == std::optional{ 255 } ) with expansion: {?} == {?} diff --git a/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/tests/SelfTest/Baselines/console.sw.multi.approved.txt index b3f60920..fa4ee763 100644 --- a/tests/SelfTest/Baselines/console.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.multi.approved.txt @@ -8846,22 +8846,22 @@ Parse.tests.cpp: ............................................................................... Parse.tests.cpp:: PASSED: - REQUIRE( parseUInt( "0" ) == Optional{ 0 } ) + REQUIRE( parseUInt( "0" ) == std::optional{ 0 } ) with expansion: {?} == {?} Parse.tests.cpp:: PASSED: - REQUIRE( parseUInt( "100" ) == Optional{ 100 } ) + REQUIRE( parseUInt( "100" ) == std::optional{ 100 } ) with expansion: {?} == {?} Parse.tests.cpp:: PASSED: - REQUIRE( parseUInt( "4294967295" ) == Optional{ 4294967295 } ) + REQUIRE( parseUInt( "4294967295" ) == std::optional{ 4294967295 } ) with expansion: {?} == {?} Parse.tests.cpp:: PASSED: - REQUIRE( parseUInt( "0x", 16 ) == Optional{ 255 } ) + REQUIRE( parseUInt( "0x", 16 ) == std::optional{ 255 } ) with expansion: {?} == {?} diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt index 4ef99012..28427811 100644 --- a/tests/SelfTest/Baselines/tap.sw.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.approved.txt @@ -2207,13 +2207,13 @@ ok {test-number} - EvilMatcher() || ( EvilMatcher() && !EvilMatcher() ) # Overloaded comma or address-of operators are not used ok {test-number} - ( EvilMatcher() && EvilMatcher() ) || !EvilMatcher() # Parse uints -ok {test-number} - parseUInt( "0" ) == Optional{ 0 } for: {?} == {?} +ok {test-number} - parseUInt( "0" ) == std::optional{ 0 } for: {?} == {?} # Parse uints -ok {test-number} - parseUInt( "100" ) == Optional{ 100 } for: {?} == {?} +ok {test-number} - parseUInt( "100" ) == std::optional{ 100 } for: {?} == {?} # Parse uints -ok {test-number} - parseUInt( "4294967295" ) == Optional{ 4294967295 } for: {?} == {?} +ok {test-number} - parseUInt( "4294967295" ) == std::optional{ 4294967295 } for: {?} == {?} # Parse uints -ok {test-number} - parseUInt( "0x", 16 ) == Optional{ 255 } for: {?} == {?} +ok {test-number} - parseUInt( "0x", 16 ) == std::optional{ 255 } for: {?} == {?} # Parse uints ok {test-number} - !(parseUInt( "" )) for: !{?} # Parse uints diff --git a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt index 81322cf9..811a516f 100644 --- a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt @@ -2205,13 +2205,13 @@ ok {test-number} - EvilMatcher() || ( EvilMatcher() && !EvilMatcher() ) # Overloaded comma or address-of operators are not used ok {test-number} - ( EvilMatcher() && EvilMatcher() ) || !EvilMatcher() # Parse uints -ok {test-number} - parseUInt( "0" ) == Optional{ 0 } for: {?} == {?} +ok {test-number} - parseUInt( "0" ) == std::optional{ 0 } for: {?} == {?} # Parse uints -ok {test-number} - parseUInt( "100" ) == Optional{ 100 } for: {?} == {?} +ok {test-number} - parseUInt( "100" ) == std::optional{ 100 } for: {?} == {?} # Parse uints -ok {test-number} - parseUInt( "4294967295" ) == Optional{ 4294967295 } for: {?} == {?} +ok {test-number} - parseUInt( "4294967295" ) == std::optional{ 4294967295 } for: {?} == {?} # Parse uints -ok {test-number} - parseUInt( "0x", 16 ) == Optional{ 255 } for: {?} == {?} +ok {test-number} - parseUInt( "0x", 16 ) == std::optional{ 255 } for: {?} == {?} # Parse uints ok {test-number} - !(parseUInt( "" )) for: !{?} # Parse uints diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt index 8f606c38..98c04b4a 100644 --- a/tests/SelfTest/Baselines/xml.sw.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.approved.txt @@ -10530,7 +10530,7 @@ Approx( 1.21999999999999997 )
- parseUInt( "0" ) == Optional<unsigned int>{ 0 } + parseUInt( "0" ) == std::optional<unsigned int>{ 0 } {?} == {?} @@ -10538,7 +10538,7 @@ Approx( 1.21999999999999997 ) - parseUInt( "100" ) == Optional<unsigned int>{ 100 } + parseUInt( "100" ) == std::optional<unsigned int>{ 100 } {?} == {?} @@ -10546,7 +10546,7 @@ Approx( 1.21999999999999997 ) - parseUInt( "4294967295" ) == Optional<unsigned int>{ 4294967295 } + parseUInt( "4294967295" ) == std::optional<unsigned int>{ 4294967295 } {?} == {?} @@ -10554,7 +10554,7 @@ Approx( 1.21999999999999997 ) - parseUInt( "0x", 16 ) == Optional<unsigned int>{ 255 } + parseUInt( "0x", 16 ) == std::optional<unsigned int>{ 255 } {?} == {?} diff --git a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt index de6ee1fc..9e3d3db5 100644 --- a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt @@ -10530,7 +10530,7 @@ Approx( 1.21999999999999997 )
- parseUInt( "0" ) == Optional<unsigned int>{ 0 } + parseUInt( "0" ) == std::optional<unsigned int>{ 0 } {?} == {?} @@ -10538,7 +10538,7 @@ Approx( 1.21999999999999997 ) - parseUInt( "100" ) == Optional<unsigned int>{ 100 } + parseUInt( "100" ) == std::optional<unsigned int>{ 100 } {?} == {?} @@ -10546,7 +10546,7 @@ Approx( 1.21999999999999997 ) - parseUInt( "4294967295" ) == Optional<unsigned int>{ 4294967295 } + parseUInt( "4294967295" ) == std::optional<unsigned int>{ 4294967295 } {?} == {?} @@ -10554,7 +10554,7 @@ Approx( 1.21999999999999997 ) - parseUInt( "0x", 16 ) == Optional<unsigned int>{ 255 } + parseUInt( "0x", 16 ) == std::optional<unsigned int>{ 255 } {?} == {?} diff --git a/tests/SelfTest/IntrospectiveTests/Details.tests.cpp b/tests/SelfTest/IntrospectiveTests/Details.tests.cpp index 5566bb59..46d77f80 100644 --- a/tests/SelfTest/IntrospectiveTests/Details.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/Details.tests.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include @@ -62,74 +61,6 @@ TEST_CASE( "CaseInsensitiveEqualsTo is case insensitive", } } -TEST_CASE("Optional comparison ops", "[optional][approvals]") { - using Catch::Optional; - - Optional a, b; - - SECTION( "Empty optionals are equal" ) { - REQUIRE( a == b ); - REQUIRE_FALSE( a != b ); - } - SECTION( "Empty and non-empty optionals are never equal" ) { - a = 1; - REQUIRE_FALSE( a == b ); - REQUIRE( a != b ); - } - SECTION( - "non-empty optionals are equal if the contained elements are equal") { - a = 1; - b = 2; - REQUIRE( a != b ); - REQUIRE_FALSE( a == b ); - - a = 2; - REQUIRE( a == b ); - REQUIRE_FALSE( a != b ); - } -} - -namespace { - struct MoveChecker { - bool has_moved = false; - MoveChecker() = default; - MoveChecker( MoveChecker const& rhs ) = default; - MoveChecker& operator=( MoveChecker const& rhs ) = default; - MoveChecker( MoveChecker&& rhs ) noexcept { rhs.has_moved = true; } - MoveChecker& operator=( MoveChecker&& rhs ) noexcept { - rhs.has_moved = true; - return *this; - } - }; -} - -TEST_CASE( "Optional supports move ops", "[optional][approvals]" ) { - using Catch::Optional; - MoveChecker a; - Optional opt_A( a ); - REQUIRE_FALSE( a.has_moved ); - REQUIRE_FALSE( opt_A->has_moved ); - - SECTION( "Move construction from element" ) { - Optional opt_B( CATCH_MOVE( a ) ); - REQUIRE( a.has_moved ); - } - SECTION( "Move assignment from element" ) { - opt_A = CATCH_MOVE( a ); - REQUIRE( a.has_moved ); - } - SECTION( "Move construction from optional" ) { - Optional opt_B( CATCH_MOVE( opt_A ) ); - REQUIRE( opt_A->has_moved ); // NOLINT(clang-analyzer-cplusplus.Move) - } - SECTION( "Move assignment from optional" ) { - Optional opt_B( opt_A ); - REQUIRE_FALSE( opt_A->has_moved ); - opt_B = CATCH_MOVE( opt_A ); - REQUIRE( opt_A->has_moved ); // NOLINT(clang-analyzer-cplusplus.Move) - } -} - TEST_CASE( "Decomposer checks that the argument is 0 when handling " "only-0-comparable types", "[decomposition][approvals]" ) { diff --git a/tests/SelfTest/IntrospectiveTests/Parse.tests.cpp b/tests/SelfTest/IntrospectiveTests/Parse.tests.cpp index 7791355f..b6c83874 100644 --- a/tests/SelfTest/IntrospectiveTests/Parse.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/Parse.tests.cpp @@ -12,14 +12,13 @@ TEST_CASE("Parse uints", "[parse-numbers]") { using Catch::parseUInt; - using Catch::Optional; SECTION("proper inputs") { - REQUIRE( parseUInt( "0" ) == Optional{ 0 } ); - REQUIRE( parseUInt( "100" ) == Optional{ 100 } ); + REQUIRE( parseUInt( "0" ) == std::optional{ 0 } ); + REQUIRE( parseUInt( "100" ) == std::optional{ 100 } ); REQUIRE( parseUInt( "4294967295" ) == - Optional{ 4294967295 } ); - REQUIRE( parseUInt( "0xFF", 16 ) == Optional{ 255 } ); + std::optional{ 4294967295 } ); + REQUIRE( parseUInt( "0xFF", 16 ) == std::optional{ 255 } ); } SECTION( "Bad inputs" ) { // empty