From bc524d70253a4ab2fe40c3ca3e5666e267c0a4d1 Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Sun, 29 Jun 2025 19:25:29 +0100 Subject: import catch2 3.8.1 --- tests/SelfTest/UsageTests/ToStringPair.tests.cpp | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/SelfTest/UsageTests/ToStringPair.tests.cpp (limited to 'tests/SelfTest/UsageTests/ToStringPair.tests.cpp') diff --git a/tests/SelfTest/UsageTests/ToStringPair.tests.cpp b/tests/SelfTest/UsageTests/ToStringPair.tests.cpp new file mode 100644 index 0000000..f5cb239 --- /dev/null +++ b/tests/SelfTest/UsageTests/ToStringPair.tests.cpp @@ -0,0 +1,38 @@ + +// 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 + +#define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER +#include + +TEST_CASE( "std::pair -> toString", "[toString][pair]" ) { + std::pair value( 34, "xyzzy" ); + REQUIRE( ::Catch::Detail::stringify( value ) == "{ 34, \"xyzzy\" }" ); +} + +TEST_CASE( "std::pair -> toString", "[toString][pair]" ) { + std::pair value( 34, "xyzzy" ); + REQUIRE( ::Catch::Detail::stringify(value) == "{ 34, \"xyzzy\" }" ); +} + +TEST_CASE( "std::vector > -> toString", "[toString][pair]" ) { + std::vector > pr; + pr.push_back( std::make_pair("green", 55 ) ); + REQUIRE( ::Catch::Detail::stringify( pr ) == "{ { \"green\", 55 } }" ); +} + +// This is pretty contrived - I figure if this works, anything will... +TEST_CASE( "pair > -> toString", "[toString][pair]" ) { + typedef std::pair left_t; + typedef std::pair right_t; + + left_t left( 42, "Arthur" ); + right_t right( "Ford", 24 ); + + std::pair pair( left, right ); + REQUIRE( ::Catch::Detail::stringify( pair ) == "{ { 42, \"Arthur\" }, { \"Ford\", 24 } }" ); +} -- cgit v1.2.3