diff options
| author | Martin Hořeňovský | 2019-12-05 16:00:20 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2019-12-05 16:00:20 +0100 |
| commit | 0fea081ad1a678b379182930a3ec22a3e275dbf0 (patch) | |
| tree | 3afa04ce6805d7a86e9c59f87ac68cb1d21eb8b2 /tests/SelfTest/UsageTests/ToStringTuple.tests.cpp | |
| parent | 90e2549cecc2e886d563b7a88e752c9b4104f798 (diff) | |
| download | catch3-0fea081ad1a678b379182930a3ec22a3e275dbf0.tar.gz | |
Move tests from projects/ to tests/
Diffstat (limited to 'tests/SelfTest/UsageTests/ToStringTuple.tests.cpp')
| -rw-r--r-- | tests/SelfTest/UsageTests/ToStringTuple.tests.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/SelfTest/UsageTests/ToStringTuple.tests.cpp b/tests/SelfTest/UsageTests/ToStringTuple.tests.cpp new file mode 100644 index 00000000..983ba550 --- /dev/null +++ b/tests/SelfTest/UsageTests/ToStringTuple.tests.cpp @@ -0,0 +1,47 @@ +#define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER +#include <catch2/catch.hpp> + +#include <tuple> + +TEST_CASE( "tuple<>", "[toString][tuple]" ) +{ + typedef std::tuple<> type; + CHECK( "{ }" == ::Catch::Detail::stringify(type{}) ); + type value {}; + CHECK( "{ }" == ::Catch::Detail::stringify(value) ); +} + +TEST_CASE( "tuple<int>", "[toString][tuple]" ) +{ + typedef std::tuple<int> type; + CHECK( "{ 0 }" == ::Catch::Detail::stringify(type{0}) ); +} + + +TEST_CASE( "tuple<float,int>", "[toString][tuple]" ) +{ + typedef std::tuple<float,int> type; + CHECK( "1.2f" == ::Catch::Detail::stringify(float(1.2)) ); + CHECK( "{ 1.2f, 0 }" == ::Catch::Detail::stringify(type{1.2f,0}) ); +} + +TEST_CASE( "tuple<string,string>", "[toString][tuple]" ) +{ + typedef std::tuple<std::string,std::string> type; + CHECK( "{ \"hello\", \"world\" }" == ::Catch::Detail::stringify(type{"hello","world"}) ); +} + +TEST_CASE( "tuple<tuple<int>,tuple<>,float>", "[toString][tuple]" ) +{ + typedef std::tuple<std::tuple<int>,std::tuple<>,float> type; + type value { std::tuple<int>{42}, {}, 1.2f }; + CHECK( "{ { 42 }, { }, 1.2f }" == ::Catch::Detail::stringify(value) ); +} + +TEST_CASE( "tuple<nullptr,int,const char *>", "[toString][tuple]" ) +{ + typedef std::tuple<std::nullptr_t,int,const char *> type; + type value { nullptr, 42, "Catch me" }; + CHECK( "{ nullptr, 42, \"Catch me\" }" == ::Catch::Detail::stringify(value) ); +} + |