1
0
Files
YYCCommonplace/testbench/yycc/patch/stream.cpp
yyc12345 c8d763bdcf 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.
2025-09-25 15:29:55 +08:00

32 lines
811 B
C++

#include <gtest/gtest.h>
#include <yycc.hpp>
#include <yycc/patch/stream.hpp>
#include <yycc/string/reinterpret.hpp>
#include <sstream>
#define REINTERPRET ::yycc::string::reinterpret
using namespace std::literals::string_view_literals;
using namespace ::yycc::patch::stream;
namespace yycctest::patch::stream {
TEST(PatchStream, StringView) {
std::stringstream ss;
ss << u8"hello"sv;
EXPECT_EQ(REINTERPRET::as_utf8_view(ss.view()), u8"hello"sv);
}
TEST(PatchStream, CStrPtr) {
std::stringstream ss;
ss << u8"hello";
EXPECT_EQ(REINTERPRET::as_utf8_view(ss.view()), u8"hello");
}
TEST(PatchStream, Character) {
std::stringstream ss;
ss << u8'y';
EXPECT_EQ(REINTERPRET::as_utf8_view(ss.view()), u8"y");
}
}