1
0

fix: use more clear format spec in format test.

- this is designed to avoid different behavior between msvc and gcc.
	- gcc output char in default.
	- msvc output it as integer in default.
This commit is contained in:
2025-09-28 22:31:08 +08:00
parent 31c624797f
commit d6be8a11ac

View File

@ -11,25 +11,25 @@ namespace yycctest::patch::format {
static constexpr std::u8string_view PROBE_STRING_VIEW(PROBE); static constexpr std::u8string_view PROBE_STRING_VIEW(PROBE);
TEST(PatchFormat, OrdinaryFormat) { TEST(PatchFormat, OrdinaryFormat) {
auto rv = FORMAT::format("{}{}{}{}{}{} world!", auto rv = FORMAT::format("{:c}{}{}{}{}{} world!",
PROBE[0], PROBE[0],
PROBE_STRING.data(), PROBE_STRING.data(),
PROBE_STRING.c_str(), PROBE_STRING.c_str(),
PROBE, PROBE,
PROBE_STRING, PROBE_STRING,
PROBE_STRING_VIEW); PROBE_STRING_VIEW);
EXPECT_EQ(rv, "104hellohellohellohellohello world!"); EXPECT_EQ(rv, "hhellohellohellohellohello world!");
} }
TEST(PatchFormat, Utf8Format) { TEST(PatchFormat, Utf8Format) {
auto rv = FORMAT::format(u8"{}{}{}{}{}{} world!", auto rv = FORMAT::format(u8"{:c}{}{}{}{}{} world!",
PROBE[0], PROBE[0],
PROBE_STRING.data(), PROBE_STRING.data(),
PROBE_STRING.c_str(), PROBE_STRING.c_str(),
PROBE, PROBE,
PROBE_STRING, PROBE_STRING,
PROBE_STRING_VIEW); PROBE_STRING_VIEW);
EXPECT_EQ(rv, u8"104hellohellohellohellohello world!"); EXPECT_EQ(rv, u8"hhellohellohellohellohello world!");
} }
} }