2017-10-09 12:31:22 +02:00
|
|
|
#define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER
|
2014-09-04 01:32:05 +02:00
|
|
|
#include "catch.hpp"
|
|
|
|
|
2017-04-25 13:40:52 +02:00
|
|
|
#include <tuple>
|
2015-05-19 19:23:52 +02:00
|
|
|
|
2017-07-13 09:52:51 +02:00
|
|
|
TEST_CASE( "tuple<>", "[toString][tuple]" )
|
2014-09-04 01:32:05 +02:00
|
|
|
{
|
|
|
|
typedef std::tuple<> type;
|
2017-05-02 23:51:03 +02:00
|
|
|
CHECK( "{ }" == ::Catch::Detail::stringify(type{}) );
|
2014-09-04 01:32:05 +02:00
|
|
|
type value {};
|
2017-05-02 23:51:03 +02:00
|
|
|
CHECK( "{ }" == ::Catch::Detail::stringify(value) );
|
2014-09-04 01:32:05 +02:00
|
|
|
}
|
|
|
|
|
2017-07-13 09:52:51 +02:00
|
|
|
TEST_CASE( "tuple<int>", "[toString][tuple]" )
|
2014-09-04 01:32:05 +02:00
|
|
|
{
|
|
|
|
typedef std::tuple<int> type;
|
2017-05-02 23:51:03 +02:00
|
|
|
CHECK( "{ 0 }" == ::Catch::Detail::stringify(type{0}) );
|
2014-09-04 01:32:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-13 09:52:51 +02:00
|
|
|
TEST_CASE( "tuple<float,int>", "[toString][tuple]" )
|
2014-09-04 01:32:05 +02:00
|
|
|
{
|
|
|
|
typedef std::tuple<float,int> type;
|
2017-05-02 23:51:03 +02:00
|
|
|
CHECK( "1.2f" == ::Catch::Detail::stringify(float(1.2)) );
|
|
|
|
CHECK( "{ 1.2f, 0 }" == ::Catch::Detail::stringify(type{1.2f,0}) );
|
2014-09-04 01:32:05 +02:00
|
|
|
}
|
|
|
|
|
2017-07-13 09:52:51 +02:00
|
|
|
TEST_CASE( "tuple<string,string>", "[toString][tuple]" )
|
2014-09-04 01:32:05 +02:00
|
|
|
{
|
|
|
|
typedef std::tuple<std::string,std::string> type;
|
2017-05-02 23:51:03 +02:00
|
|
|
CHECK( "{ \"hello\", \"world\" }" == ::Catch::Detail::stringify(type{"hello","world"}) );
|
2014-09-04 01:32:05 +02:00
|
|
|
}
|
|
|
|
|
2017-07-13 09:52:51 +02:00
|
|
|
TEST_CASE( "tuple<tuple<int>,tuple<>,float>", "[toString][tuple]" )
|
2014-09-04 01:32:05 +02:00
|
|
|
{
|
|
|
|
typedef std::tuple<std::tuple<int>,std::tuple<>,float> type;
|
2014-09-04 02:05:51 +02:00
|
|
|
type value { std::tuple<int>{42}, {}, 1.2f };
|
2017-05-02 23:51:03 +02:00
|
|
|
CHECK( "{ { 42 }, { }, 1.2f }" == ::Catch::Detail::stringify(value) );
|
2014-09-04 01:32:05 +02:00
|
|
|
}
|
|
|
|
|
2017-07-13 09:52:51 +02:00
|
|
|
TEST_CASE( "tuple<nullptr,int,const char *>", "[toString][tuple]" )
|
2014-09-04 01:32:05 +02:00
|
|
|
{
|
|
|
|
typedef std::tuple<std::nullptr_t,int,const char *> type;
|
|
|
|
type value { nullptr, 42, "Catch me" };
|
2017-05-02 23:51:03 +02:00
|
|
|
CHECK( "{ nullptr, 42, \"Catch me\" }" == ::Catch::Detail::stringify(value) );
|
2014-09-04 01:32:05 +02:00
|
|
|
}
|
|
|
|
|