Skip to content

Commit a9a71b6

Browse files
authored
[libc++][test] Don't pass ill-formed UTF-8 to MAKE_STRING_VIEW (#136403)
1 parent 3e795c6 commit a9a71b6

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

libcxx/test/std/utilities/format/format.functions/escaped_output.unicode.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ void test_string() {
337337

338338
// Ill-formed
339339
if constexpr (sizeof(CharT) == 1)
340-
test_format(SV(R"("\x{80}")"), SV("{:?}"), SV("\x80"));
340+
test_format(SV(R"("\x{80}")"), SV("{:?}"), "\x80");
341341

342342
// *** P2713R1 examples ***
343343
test_format(SV(R"(["\u{301}"])"), SV("[{:?}]"), SV("\u0301"));

libcxx/test/std/utilities/format/format.functions/fill.unicode.pass.cpp

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,30 +75,40 @@ void test() {
7575

7676
// Invalid Unicode Scalar Values
7777
if constexpr (std::same_as<CharT, char>) {
78-
check_exception("The format specifier contains malformed Unicode characters", SV("{:\xed\xa0\x80^}"), 42); // U+D800
79-
check_exception("The format specifier contains malformed Unicode characters", SV("{:\xed\xa0\xbf^}"), 42); // U+DBFF
80-
check_exception("The format specifier contains malformed Unicode characters", SV("{:\xed\xbf\x80^}"), 42); // U+DC00
81-
check_exception("The format specifier contains malformed Unicode characters", SV("{:\xed\xbf\xbf^}"), 42); // U+DFFF
78+
check_exception("The format specifier contains malformed Unicode characters",
79+
std::string_view{"{:\xed\xa0\x80^}"},
80+
42); // U+D800
81+
check_exception("The format specifier contains malformed Unicode characters",
82+
std::string_view{"{:\xed\xa0\xbf^}"},
83+
42); // U+DBFF
84+
check_exception("The format specifier contains malformed Unicode characters",
85+
std::string_view{"{:\xed\xbf\x80^}"},
86+
42); // U+DC00
87+
check_exception("The format specifier contains malformed Unicode characters",
88+
std::string_view{"{:\xed\xbf\xbf^}"},
89+
42); // U+DFFF
8290

83-
check_exception(
84-
"The format specifier contains malformed Unicode characters", SV("{:\xf4\x90\x80\x80^}"), 42); // U+110000
85-
check_exception(
86-
"The format specifier contains malformed Unicode characters", SV("{:\xf4\x90\xbf\xbf^}"), 42); // U+11FFFF
91+
check_exception("The format specifier contains malformed Unicode characters",
92+
std::string_view{"{:\xf4\x90\x80\x80^}"},
93+
42); // U+110000
94+
check_exception("The format specifier contains malformed Unicode characters",
95+
std::string_view{"{:\xf4\x90\xbf\xbf^}"},
96+
42); // U+11FFFF
8797

8898
check_exception("The format specifier contains malformed Unicode characters",
89-
SV("{:\x80^}"),
99+
std::string_view{"{:\x80^}"},
90100
42); // Trailing code unit with no leading one.
91101
check_exception("The format specifier contains malformed Unicode characters",
92-
SV("{:\xc0^}"),
102+
std::string_view{"{:\xc0^}"},
93103
42); // Missing trailing code unit.
94104
check_exception("The format specifier contains malformed Unicode characters",
95-
SV("{:\xe0\x80^}"),
105+
std::string_view{"{:\xe0\x80^}"},
96106
42); // Missing trailing code unit.
97107
check_exception("The format specifier contains malformed Unicode characters",
98-
SV("{:\xf0\x80^}"),
108+
std::string_view{"{:\xf0\x80^}"},
99109
42); // Missing two trailing code units.
100110
check_exception("The format specifier contains malformed Unicode characters",
101-
SV("{:\xf0\x80\x80^}"),
111+
std::string_view{"{:\xf0\x80\x80^}"},
102112
42); // Missing trailing code unit.
103113

104114
#ifndef TEST_HAS_NO_WIDE_CHARACTERS

0 commit comments

Comments
 (0)