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

summaryrefslogtreecommitdiffhomepage
path: root/projects/SelfTest/UsageTests/ToStringOptional.tests.cpp
diff options
context:
space:
mode:
authorRobin Moussu2019-01-25 22:05:40 +0100
committerMartin Hořeňovský2019-01-31 15:35:13 +0100
commit16dc2197046dd1362e26027e789f15d65275a185 (patch)
tree27cb5136901b4fb46a9563467e4ea801c4b2a79c /projects/SelfTest/UsageTests/ToStringOptional.tests.cpp
parent63d1a96908ac40dd7f474a35085120bb3992ded7 (diff)
downloadcatch3-16dc2197046dd1362e26027e789f15d65275a185.tar.gz
Add to string for std::optional
Diffstat (limited to 'projects/SelfTest/UsageTests/ToStringOptional.tests.cpp')
-rw-r--r--projects/SelfTest/UsageTests/ToStringOptional.tests.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/projects/SelfTest/UsageTests/ToStringOptional.tests.cpp b/projects/SelfTest/UsageTests/ToStringOptional.tests.cpp
new file mode 100644
index 00000000..d78579d9
--- /dev/null
+++ b/projects/SelfTest/UsageTests/ToStringOptional.tests.cpp
@@ -0,0 +1,23 @@
+#define CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER
+#include "catch.hpp"
+
+#if defined(CATCH_CONFIG_CPP17_OPTIONAL)
+
+TEST_CASE( "std::optional<int> -> toString", "[toString][optional][approvals]" ) {
+ using type = std::optional<int>;
+ REQUIRE( "{ }" == ::Catch::Detail::stringify( type{} ) );
+ REQUIRE( "0" == ::Catch::Detail::stringify( type{ 0 } ) );
+}
+
+TEST_CASE( "std::optional<std::string> -> toString", "[toString][optional][approvals]" ) {
+ using type = std::optional<std::string>;
+ REQUIRE( "{ }" == ::Catch::Detail::stringify( type{} ) );
+ REQUIRE( "\"abc\"" == ::Catch::Detail::stringify( type{ "abc" } ) );
+}
+
+TEST_CASE( "std::vector<std::optional<int> > -> toString", "[toString][optional][approvals]" ) {
+ using type = std::vector<std::optional<int> >;
+ REQUIRE( "{ 0, { }, 2 }" == ::Catch::Detail::stringify( type{ 0, {}, 2 } ) );
+}
+
+#endif // CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL