2025-08-22 21:28:29 +08:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <yycc.hpp>
|
2025-09-25 15:29:55 +08:00
|
|
|
#include <yycc/patch/stream.hpp>
|
2025-08-22 21:28:29 +08:00
|
|
|
#include <yycc/string/reinterpret.hpp>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
#define REINTERPRET ::yycc::string::reinterpret
|
|
|
|
using namespace std::literals::string_view_literals;
|
2025-09-25 15:29:55 +08:00
|
|
|
using namespace ::yycc::patch::stream;
|
2025-08-22 21:28:29 +08:00
|
|
|
|
2025-09-25 15:29:55 +08:00
|
|
|
namespace yycctest::patch::stream {
|
2025-08-22 21:28:29 +08:00
|
|
|
|
2025-09-25 15:29:55 +08:00
|
|
|
TEST(PatchStream, StringView) {
|
2025-08-22 21:28:29 +08:00
|
|
|
std::stringstream ss;
|
|
|
|
ss << u8"hello"sv;
|
|
|
|
EXPECT_EQ(REINTERPRET::as_utf8_view(ss.view()), u8"hello"sv);
|
|
|
|
}
|
|
|
|
|
2025-09-25 15:29:55 +08:00
|
|
|
TEST(PatchStream, CStrPtr) {
|
2025-08-22 21:28:29 +08:00
|
|
|
std::stringstream ss;
|
|
|
|
ss << u8"hello";
|
|
|
|
EXPECT_EQ(REINTERPRET::as_utf8_view(ss.view()), u8"hello");
|
|
|
|
}
|
|
|
|
|
2025-09-25 15:29:55 +08:00
|
|
|
TEST(PatchStream, Character) {
|
2025-08-22 21:28:29 +08:00
|
|
|
std::stringstream ss;
|
|
|
|
ss << u8'y';
|
|
|
|
EXPECT_EQ(REINTERPRET::as_utf8_view(ss.view()), u8"y");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|