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

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-05-03 10:49:45 +0200
committerMartin Hořeňovský2022-05-03 13:54:07 +0200
commit91ea25e51ac122b2ab2363f89f5a6ee0b91c858c (patch)
tree1fd51b51cd5898b3f9bb7166acd6e7ccea6bf963
parente2d07d35f4e31fa07fda89aadfb547e20b6b63b3 (diff)
downloadcatch3-91ea25e51ac122b2ab2363f89f5a6ee0b91c858c.tar.gz
Fix use of u8-literal that would break in C++20
-rw-r--r--CMake/CatchMiscFunctions.cmake1
-rw-r--r--tests/SelfTest/IntrospectiveTests/Xml.tests.cpp12
2 files changed, 6 insertions, 7 deletions
diff --git a/CMake/CatchMiscFunctions.cmake b/CMake/CatchMiscFunctions.cmake
index 21f4f6c0..ce66542b 100644
--- a/CMake/CatchMiscFunctions.cmake
+++ b/CMake/CatchMiscFunctions.cmake
@@ -45,6 +45,7 @@ function(add_warnings_to_targets targets)
set(CHECKED_WARNING_FLAGS
"-Wabsolute-value"
"-Wall"
+ "-Wc++20-compat"
"-Wcall-to-pure-virtual-from-ctor-dtor"
"-Wcast-align"
"-Wcatch-value"
diff --git a/tests/SelfTest/IntrospectiveTests/Xml.tests.cpp b/tests/SelfTest/IntrospectiveTests/Xml.tests.cpp
index 226e737c..9fe9416a 100644
--- a/tests/SelfTest/IntrospectiveTests/Xml.tests.cpp
+++ b/tests/SelfTest/IntrospectiveTests/Xml.tests.cpp
@@ -52,10 +52,9 @@ TEST_CASE( "XmlEncode", "[XML]" ) {
// Thanks to Peter Bindels (dascandy) for some of the tests
TEST_CASE("XmlEncode: UTF-8", "[XML][UTF-8][approvals]") {
-#define ESC(lit) reinterpret_cast<const char*>(lit)
SECTION("Valid utf-8 strings") {
- CHECK(encode(ESC(u8"Here be 👾")) == ESC(u8"Here be 👾"));
- CHECK(encode(ESC(u8"šš")) == ESC(u8"šš"));
+ CHECK(encode("Here be 👾") == "Here be 👾");
+ CHECK(encode("šš") == "šš");
CHECK(encode("\xDF\xBF") == "\xDF\xBF"); // 0x7FF
CHECK(encode("\xE0\xA0\x80") == "\xE0\xA0\x80"); // 0x800
@@ -67,10 +66,10 @@ TEST_CASE("XmlEncode: UTF-8", "[XML][UTF-8][approvals]") {
}
SECTION("Invalid utf-8 strings") {
SECTION("Various broken strings") {
- CHECK(encode(ESC("Here \xFF be \xF0\x9F\x91\xBE")) == ESC(u8"Here \\xFF be 👾"));
+ CHECK(encode("Here \xFF be \xF0\x9F\x91\xBE") == "Here \\xFF be 👾");
CHECK(encode("\xFF") == "\\xFF");
- CHECK(encode("\xC5\xC5\xA0") == ESC(u8"\\xC5Š"));
- CHECK(encode("\xF4\x90\x80\x80") == ESC(u8"\\xF4\\x90\\x80\\x80")); // 0x110000 -- out of unicode range
+ CHECK(encode("\xC5\xC5\xA0") == "\\xC5Š");
+ CHECK(encode("\xF4\x90\x80\x80") == "\\xF4\\x90\\x80\\x80"); // 0x110000 -- out of unicode range
}
SECTION("Overlong encodings") {
@@ -121,7 +120,6 @@ TEST_CASE("XmlEncode: UTF-8", "[XML][UTF-8][approvals]") {
CHECK(encode("\xF4\x80\x80") == "\\xF4\\x80\\x80");
}
}
-#undef ESC
}
TEST_CASE("XmlWriter writes boolean attributes as true/false", "[XML][XmlWriter]") {