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

summaryrefslogtreecommitdiffhomepage
path: root/tests/SelfTest/UsageTests/ToStringGeneral.tests.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2024-03-01 15:09:06 +0100
committerMartin Hořeňovský2024-03-01 15:09:11 +0100
commitc3fd4eb17e28ace4d3d9df1fb0656f3975879709 (patch)
tree78c1fa9c4791c908770410144b3ea360258ee27a /tests/SelfTest/UsageTests/ToStringGeneral.tests.cpp
parentfb51116d5b20ea3fef6c5a89267e7d91856a60cf (diff)
downloadcatch3-c3fd4eb17e28ace4d3d9df1fb0656f3975879709.tar.gz
Update outdated tests for stringifying characters
Previously the tests relied purely on output changes in approvals. Now the stringification output is checked directly as part of the unit tests.
Diffstat (limited to 'tests/SelfTest/UsageTests/ToStringGeneral.tests.cpp')
-rw-r--r--tests/SelfTest/UsageTests/ToStringGeneral.tests.cpp31
1 files changed, 10 insertions, 21 deletions
diff --git a/tests/SelfTest/UsageTests/ToStringGeneral.tests.cpp b/tests/SelfTest/UsageTests/ToStringGeneral.tests.cpp
index 28d60196..e073a40a 100644
--- a/tests/SelfTest/UsageTests/ToStringGeneral.tests.cpp
+++ b/tests/SelfTest/UsageTests/ToStringGeneral.tests.cpp
@@ -14,31 +14,20 @@
TEST_CASE( "Character pretty printing" ){
SECTION("Specifically escaped"){
- char tab = '\t';
- char newline = '\n';
- char carr_return = '\r';
- char form_feed = '\f';
- CHECK(tab == '\t');
- CHECK(newline == '\n');
- CHECK(carr_return == '\r');
- CHECK(form_feed == '\f');
+ CHECK(::Catch::Detail::stringify('\t') == "'\\t'");
+ CHECK(::Catch::Detail::stringify('\n') == "'\\n'");
+ CHECK(::Catch::Detail::stringify('\r') == "'\\r'");
+ CHECK(::Catch::Detail::stringify('\f') == "'\\f'");
}
SECTION("General chars"){
- char space = ' ';
- CHECK(space == ' ');
- char chars[] = {'a', 'z', 'A', 'Z'};
- for (int i = 0; i < 4; ++i){
- char c = chars[i];
- REQUIRE(c == chars[i]);
- }
+ CHECK(::Catch::Detail::stringify( ' ' ) == "' '" );
+ CHECK(::Catch::Detail::stringify( 'A' ) == "'A'" );
+ CHECK(::Catch::Detail::stringify( 'z' ) == "'z'" );
}
SECTION("Low ASCII"){
- char null_terminator = '\0';
- CHECK(null_terminator == '\0');
- for (int i = 2; i < 6; ++i){
- char c = static_cast<char>(i);
- REQUIRE(c == i);
- }
+ CHECK(::Catch::Detail::stringify( '\0' ) == "0" );
+ CHECK(::Catch::Detail::stringify( static_cast<char>(2) ) == "2" );
+ CHECK(::Catch::Detail::stringify( static_cast<char>(5) ) == "5" );
}
}