feat: add utf8 format
- move utf8 stream and format patch from string to patch namespace. - add ordinay format alias and utf8 format in our format patch. - add char8_t and char inter-cast in string reinterpret namespace. - fix bug of utf8 formatter. - add test for utf8 format.
This commit is contained in:
35
testbench/yycc/patch/format.cpp
Normal file
35
testbench/yycc/patch/format.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#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("{}{}{}{}{}{} world!",
|
||||
PROBE[0],
|
||||
PROBE_STRING.data(),
|
||||
PROBE_STRING.c_str(),
|
||||
PROBE,
|
||||
PROBE_STRING,
|
||||
PROBE_STRING_VIEW);
|
||||
EXPECT_EQ(rv, "104hellohellohellohellohello world!");
|
||||
}
|
||||
|
||||
TEST(PatchFormat, Utf8Format) {
|
||||
auto rv = FORMAT::format(u8"{}{}{}{}{}{} world!",
|
||||
PROBE[0],
|
||||
PROBE_STRING.data(),
|
||||
PROBE_STRING.c_str(),
|
||||
PROBE,
|
||||
PROBE_STRING,
|
||||
PROBE_STRING_VIEW);
|
||||
EXPECT_EQ(rv, u8"104hellohellohellohellohello world!");
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user