| 1 |
|
| 2 |
// Copyright Catch2 Authors |
| 3 |
// Distributed under the Boost Software License, Version 1.0. |
| 4 |
// (See accompanying file LICENSE.txt or copy at |
| 5 |
// https://www.boost.org/LICENSE_1_0.txt) |
| 6 |
|
| 7 |
// SPDX-License-Identifier: BSL-1.0 |
| 8 |
|
| 9 |
#define CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER |
| 10 |
#include <catch2/catch_test_macros.hpp> |
| 11 |
|
| 12 |
#if defined(CATCH_CONFIG_CPP17_OPTIONAL) |
| 13 |
|
| 14 |
TEST_CASE( "std::optional<int> -> toString", "[toString][optional][approvals]" ) { |
| 15 |
using type = std::optional<int>; |
| 16 |
REQUIRE( "{ }" == ::Catch::Detail::stringify( type{} ) ); |
| 17 |
REQUIRE( "0" == ::Catch::Detail::stringify( type{ 0 } ) ); |
| 18 |
} |
| 19 |
|
| 20 |
TEST_CASE( "std::optional<std::string> -> toString", "[toString][optional][approvals]" ) { |
| 21 |
using type = std::optional<std::string>; |
| 22 |
REQUIRE( "{ }" == ::Catch::Detail::stringify( type{} ) ); |
| 23 |
REQUIRE( "\"abc\"" == ::Catch::Detail::stringify( type{ "abc" } ) ); |
| 24 |
} |
| 25 |
|
| 26 |
TEST_CASE( "std::vector<std::optional<int> > -> toString", "[toString][optional][approvals]" ) { |
| 27 |
using type = std::vector<std::optional<int> >; |
| 28 |
REQUIRE( "{ 0, { }, 2 }" == ::Catch::Detail::stringify( type{ 0, {}, 2 } ) ); |
| 29 |
} |
| 30 |
|
| 31 |
TEST_CASE( "std::nullopt -> toString", "[toString][optional][approvals]" ) { |
| 32 |
REQUIRE( "{ }" == ::Catch::Detail::stringify( std::nullopt ) ); |
| 33 |
} |
| 34 |
|
| 35 |
#endif // CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL |