Provide useful and unambigous stringification for static arrays
diff --git a/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp b/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp
index 3c5a3d9..8ab3324 100644
--- a/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp
+++ b/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp
@@ -100,3 +100,18 @@
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" } })");
+ }
+}