2022-01-28 18:03:43 -05:00
|
|
|
|
|
|
|
// Copyright Catch2 Authors
|
|
|
|
// Distributed under the Boost Software License, Version 1.0.
|
2022-10-28 05:22:53 -04:00
|
|
|
// (See accompanying file LICENSE.txt or copy at
|
2022-01-28 18:03:43 -05:00
|
|
|
// https://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
|
2017-10-09 06:31:22 -04:00
|
|
|
#define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER
|
2020-01-20 17:24:04 -05:00
|
|
|
#include <catch2/catch_test_macros.hpp>
|
2014-09-03 19:32:05 -04:00
|
|
|
|
2017-04-25 07:40:52 -04:00
|
|
|
#include <tuple>
|
2015-05-19 13:23:52 -04:00
|
|
|
|
2017-07-13 03:52:51 -04:00
|
|
|
TEST_CASE( "tuple<>", "[toString][tuple]" )
|
2014-09-03 19:32:05 -04:00
|
|
|
{
|
|
|
|
typedef std::tuple<> type;
|
2017-05-02 17:51:03 -04:00
|
|
|
CHECK( "{ }" == ::Catch::Detail::stringify(type{}) );
|
2014-09-03 19:32:05 -04:00
|
|
|
type value {};
|
2017-05-02 17:51:03 -04:00
|
|
|
CHECK( "{ }" == ::Catch::Detail::stringify(value) );
|
2014-09-03 19:32:05 -04:00
|
|
|
}
|
|
|
|
|
2017-07-13 03:52:51 -04:00
|
|
|
TEST_CASE( "tuple<int>", "[toString][tuple]" )
|
2014-09-03 19:32:05 -04:00
|
|
|
{
|
|
|
|
typedef std::tuple<int> type;
|
2017-05-02 17:51:03 -04:00
|
|
|
CHECK( "{ 0 }" == ::Catch::Detail::stringify(type{0}) );
|
2014-09-03 19:32:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-13 03:52:51 -04:00
|
|
|
TEST_CASE( "tuple<float,int>", "[toString][tuple]" )
|
2014-09-03 19:32:05 -04:00
|
|
|
{
|
|
|
|
typedef std::tuple<float,int> type;
|
2024-04-30 10:43:05 -04:00
|
|
|
CHECK( "1.5f" == ::Catch::Detail::stringify(float(1.5)) );
|
|
|
|
CHECK( "{ 1.5f, 0 }" == ::Catch::Detail::stringify(type{1.5f,0}) );
|
2014-09-03 19:32:05 -04:00
|
|
|
}
|
|
|
|
|
2017-07-13 03:52:51 -04:00
|
|
|
TEST_CASE( "tuple<string,string>", "[toString][tuple]" )
|
2014-09-03 19:32:05 -04:00
|
|
|
{
|
|
|
|
typedef std::tuple<std::string,std::string> type;
|
2017-05-02 17:51:03 -04:00
|
|
|
CHECK( "{ \"hello\", \"world\" }" == ::Catch::Detail::stringify(type{"hello","world"}) );
|
2014-09-03 19:32:05 -04:00
|
|
|
}
|
|
|
|
|
2017-07-13 03:52:51 -04:00
|
|
|
TEST_CASE( "tuple<tuple<int>,tuple<>,float>", "[toString][tuple]" )
|
2014-09-03 19:32:05 -04:00
|
|
|
{
|
|
|
|
typedef std::tuple<std::tuple<int>,std::tuple<>,float> type;
|
2024-04-30 10:43:05 -04:00
|
|
|
type value { std::tuple<int>{42}, {}, 1.5f };
|
|
|
|
CHECK( "{ { 42 }, { }, 1.5f }" == ::Catch::Detail::stringify(value) );
|
2014-09-03 19:32:05 -04:00
|
|
|
}
|
|
|
|
|
2022-01-26 17:47:40 -05:00
|
|
|
TEST_CASE( "tuple<nullptr,int,const char *>", "[approvals][toString][tuple]" ) {
|
2014-09-03 19:32:05 -04:00
|
|
|
typedef std::tuple<std::nullptr_t,int,const char *> type;
|
|
|
|
type value { nullptr, 42, "Catch me" };
|
2017-05-02 17:51:03 -04:00
|
|
|
CHECK( "{ nullptr, 42, \"Catch me\" }" == ::Catch::Detail::stringify(value) );
|
2014-09-03 19:32:05 -04:00
|
|
|
}
|
|
|
|
|