1
0
Files
YYCCommonplace/test/yycc/patch/format.cpp
yyc12345 e7a05b3488 refactor: rename testbench to test.
- rename testbench to test.
- add benchmark for future development.
2025-09-29 13:34:02 +08:00

36 lines
1.2 KiB
C++

#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) {
auto rv = FORMAT::format("{:c}{}{}{}{}{} world!",
PROBE[0],
PROBE_STRING.data(),
PROBE_STRING.c_str(),
PROBE,
PROBE_STRING,
PROBE_STRING_VIEW);
EXPECT_EQ(rv, "hhellohellohellohellohello world!");
}
TEST(PatchFormat, Utf8Format) {
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"hhellohellohellohellohello world!");
}
}