2025-09-25 15:29:55 +08:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <yycc.hpp>
|
|
|
|
#include <yycc/patch/format.hpp>
|
|
|
|
|
|
|
|
#define FORMAT ::yycc::patch::format
|
|
|
|
|
|
|
|
namespace yycctest::patch::format {
|
|
|
|
|
|
|
|
static constexpr char8_t PROBE[] = u8"hello";
|
|
|
|
static std::u8string PROBE_STRING(PROBE);
|
|
|
|
static constexpr std::u8string_view PROBE_STRING_VIEW(PROBE);
|
|
|
|
|
|
|
|
TEST(PatchFormat, OrdinaryFormat) {
|
2025-09-28 22:31:08 +08:00
|
|
|
auto rv = FORMAT::format("{:c}{}{}{}{}{} world!",
|
2025-09-25 15:29:55 +08:00
|
|
|
PROBE[0],
|
|
|
|
PROBE_STRING.data(),
|
|
|
|
PROBE_STRING.c_str(),
|
|
|
|
PROBE,
|
|
|
|
PROBE_STRING,
|
|
|
|
PROBE_STRING_VIEW);
|
2025-09-28 22:31:08 +08:00
|
|
|
EXPECT_EQ(rv, "hhellohellohellohellohello world!");
|
2025-09-25 15:29:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(PatchFormat, Utf8Format) {
|
2025-09-28 22:31:08 +08:00
|
|
|
auto rv = FORMAT::format(u8"{:c}{}{}{}{}{} world!",
|
2025-09-25 15:29:55 +08:00
|
|
|
PROBE[0],
|
|
|
|
PROBE_STRING.data(),
|
|
|
|
PROBE_STRING.c_str(),
|
|
|
|
PROBE,
|
|
|
|
PROBE_STRING,
|
|
|
|
PROBE_STRING_VIEW);
|
2025-09-28 22:31:08 +08:00
|
|
|
EXPECT_EQ(rv, u8"hhellohellohellohellohello world!");
|
2025-09-25 15:29:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|