diff options
| author | Martin Hořeňovský | 2018-01-14 18:06:21 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2018-01-14 18:06:43 +0100 |
| commit | 8d854c689b7f4388ced1a9fd0c71042b2075f26f (patch) | |
| tree | d9478f0e37200981c86c17e05e3a40ab7d9b5664 /projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp | |
| parent | f0909dfe02df36e70c4c95ed00d53cb3eacf0262 (diff) | |
| download | catch3-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.cpp | 15 |
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" } })"); + } +} |