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/ToStringTuple.tests.cpp | 54 +++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tests/SelfTest/UsageTests/ToStringTuple.tests.cpp (limited to 'tests/SelfTest/UsageTests/ToStringTuple.tests.cpp') diff --git a/tests/SelfTest/UsageTests/ToStringTuple.tests.cpp b/tests/SelfTest/UsageTests/ToStringTuple.tests.cpp new file mode 100644 index 0000000..9d1d2c4 --- /dev/null +++ b/tests/SelfTest/UsageTests/ToStringTuple.tests.cpp @@ -0,0 +1,54 @@ + +// 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_TUPLE_STRINGMAKER +#include + +#include + +TEST_CASE( "tuple<>", "[toString][tuple]" ) +{ + typedef std::tuple<> type; + CHECK( "{ }" == ::Catch::Detail::stringify(type{}) ); + type value {}; + CHECK( "{ }" == ::Catch::Detail::stringify(value) ); +} + +TEST_CASE( "tuple", "[toString][tuple]" ) +{ + typedef std::tuple type; + CHECK( "{ 0 }" == ::Catch::Detail::stringify(type{0}) ); +} + + +TEST_CASE( "tuple", "[toString][tuple]" ) +{ + typedef std::tuple type; + CHECK( "1.5f" == ::Catch::Detail::stringify(float(1.5)) ); + CHECK( "{ 1.5f, 0 }" == ::Catch::Detail::stringify(type{1.5f,0}) ); +} + +TEST_CASE( "tuple", "[toString][tuple]" ) +{ + typedef std::tuple type; + CHECK( "{ \"hello\", \"world\" }" == ::Catch::Detail::stringify(type{"hello","world"}) ); +} + +TEST_CASE( "tuple,tuple<>,float>", "[toString][tuple]" ) +{ + typedef std::tuple,std::tuple<>,float> type; + type value { std::tuple{42}, {}, 1.5f }; + CHECK( "{ { 42 }, { }, 1.5f }" == ::Catch::Detail::stringify(value) ); +} + +TEST_CASE( "tuple", "[approvals][toString][tuple]" ) { + typedef std::tuple type; + type value { nullptr, 42, "Catch me" }; + CHECK( "{ nullptr, 42, \"Catch me\" }" == ::Catch::Detail::stringify(value) ); +} + -- cgit v1.2.3