Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/projects/SelfTest/ToStringTuple.cpp
diff options
context:
space:
mode:
authorPhil Nash2014-12-30 18:42:17 +0000
committerPhil Nash2014-12-30 18:42:17 +0000
commit75a08bbc6c88826ba08d1ba6b2655c5200abc4a3 (patch)
tree7e2be0722513f96fa72275fdf0ed46cc6edf9b54 /projects/SelfTest/ToStringTuple.cpp
parentd76e08113b30997299200c654b27a71ec04af91b (diff)
parentf559a51926c6590db94029fd116e5cec6088d41f (diff)
downloadcatch3-75a08bbc6c88826ba08d1ba6b2655c5200abc4a3.tar.gz
Merge branch 'tuple_to_string' of https://github.com/PureAbstract/Catch into PureAbstract-tuple_to_string
Diffstat (limited to 'projects/SelfTest/ToStringTuple.cpp')
-rw-r--r--projects/SelfTest/ToStringTuple.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/projects/SelfTest/ToStringTuple.cpp b/projects/SelfTest/ToStringTuple.cpp
new file mode 100644
index 00000000..012ee665
--- /dev/null
+++ b/projects/SelfTest/ToStringTuple.cpp
@@ -0,0 +1,48 @@
+#include "catch.hpp"
+
+#ifdef CATCH_CPP11_OR_GREATER
+
+TEST_CASE( "tuple<>", "[toString][tuple]" )
+{
+ typedef std::tuple<> type;
+ CHECK( "{ }" == Catch::toString(type{}) );
+ type value {};
+ CHECK( "{ }" == Catch::toString(value) );
+}
+
+TEST_CASE( "tuple<int>", "[toString][tuple]" )
+{
+ typedef std::tuple<int> type;
+ CHECK( "{ 0 }" == Catch::toString(type{0}) );
+}
+
+
+TEST_CASE( "tuple<float,int>", "[toString][tuple]" )
+{
+ typedef std::tuple<float,int> type;
+ CHECK( "1.2f" == Catch::toString(float(1.2)) );
+ CHECK( "{ 1.2f, 0 }" == Catch::toString(type{1.2,0}) );
+}
+
+TEST_CASE( "tuple<string,string>", "[toString][tuple]" )
+{
+ typedef std::tuple<std::string,std::string> type;
+ CHECK( "{ \"hello\", \"world\" }" == Catch::toString(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::toString(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::toString(value) );
+}
+
+#endif /* #ifdef CATCH_CPP11_OR_GREATER */
+