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

summaryrefslogtreecommitdiffhomepage
path: root/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2018-01-14 18:06:21 +0100
committerMartin Hořeňovský2018-01-14 18:06:43 +0100
commit8d854c689b7f4388ced1a9fd0c71042b2075f26f (patch)
treed9478f0e37200981c86c17e05e3a40ab7d9b5664 /projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp
parentf0909dfe02df36e70c4c95ed00d53cb3eacf0262 (diff)
downloadcatch3-8d854c689b7f4388ced1a9fd0c71042b2075f26f.tar.gz
Provide useful and unambigous stringification for static arrays
Diffstat (limited to 'projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp')
-rw-r--r--projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp b/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp
index 3c5a3d94..8ab33249 100644
--- a/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp
+++ b/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp
@@ -100,3 +100,18 @@ TEST_CASE( "std::set is convertible string", "[toString]" ) {
REQUIRE( Catch::Detail::stringify( set ) == "{ \"abc\", \"def\", \"ghi\" }" );
}
}
+
+TEST_CASE("Static arrays are convertible to string", "[toString]") {
+ SECTION("Single item") {
+ int singular[1] = { 1 };
+ REQUIRE(Catch::Detail::stringify(singular) == "{ 1 }");
+ }
+ SECTION("Multiple") {
+ int arr[3] = { 3, 2, 1 };
+ REQUIRE(Catch::Detail::stringify(arr) == "{ 3, 2, 1 }");
+ }
+ SECTION("Non-trivial inner items") {
+ std::vector<std::string> arr[2] = { {"1:1", "1:2", "1:3"}, {"2:1", "2:2"} };
+ REQUIRE(Catch::Detail::stringify(arr) == R"({ { "1:1", "1:2", "1:3" }, { "2:1", "2:2" } })");
+ }
+}