From d6be8a11acb259f0de151be77ceb92dabbc84ba6 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Sun, 28 Sep 2025 22:31:08 +0800 Subject: [PATCH] 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. --- testbench/yycc/patch/format.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testbench/yycc/patch/format.cpp b/testbench/yycc/patch/format.cpp index b33b667..a1f1f1d 100644 --- a/testbench/yycc/patch/format.cpp +++ b/testbench/yycc/patch/format.cpp @@ -11,25 +11,25 @@ namespace yycctest::patch::format { static constexpr std::u8string_view PROBE_STRING_VIEW(PROBE); TEST(PatchFormat, OrdinaryFormat) { - auto rv = FORMAT::format("{}{}{}{}{}{} world!", + auto rv = FORMAT::format("{:c}{}{}{}{}{} world!", PROBE[0], PROBE_STRING.data(), PROBE_STRING.c_str(), PROBE, PROBE_STRING, PROBE_STRING_VIEW); - EXPECT_EQ(rv, "104hellohellohellohellohello world!"); + EXPECT_EQ(rv, "hhellohellohellohellohello world!"); } TEST(PatchFormat, Utf8Format) { - auto rv = FORMAT::format(u8"{}{}{}{}{}{} world!", + auto rv = FORMAT::format(u8"{:c}{}{}{}{}{} world!", PROBE[0], PROBE_STRING.data(), PROBE_STRING.c_str(), PROBE, PROBE_STRING, PROBE_STRING_VIEW); - EXPECT_EQ(rv, u8"104hellohellohellohellohello world!"); + EXPECT_EQ(rv, u8"hhellohellohellohellohello world!"); } }