1
0

feat: finish string strip (maybe)

This commit is contained in:
2025-09-28 16:13:06 +08:00
parent 190beeed58
commit da9fa682f7
3 changed files with 182 additions and 50 deletions

View File

@ -74,22 +74,22 @@ namespace yycctest::string::op {
TEST(StringOp, Strip) {
// Normal strip
{
auto rv = OP::to_strip(u8" \taaa\n", u8" \t\r\n");
auto rv = OP::strip(u8" \taaa\n", u8" \t\r\n");
EXPECT_EQ(rv, u8"aaa");
}
// Special strip
{
auto rv = OP::to_strip(u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>aaa<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
auto rv = OP::strip(u8"啊啊啊aaaあああ", u8"啊あ");
EXPECT_EQ(rv, u8"aaa");
}
{
auto rv = OP::to_strip(u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>aaa<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", u8"<EFBFBD><EFBFBD>");
EXPECT_EQ(rv, u8"aaa<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
auto rv = OP::strip(u8"啊啊啊aaaあああ", u8"");
EXPECT_EQ(rv, u8"aaaあああ");
}
{
auto rv = OP::to_strip(u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>aaa<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", u8"<EFBFBD><EFBFBD>");
EXPECT_EQ(rv, u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>aaa");
auto rv = OP::strip(u8"啊啊啊aaaあああ", u8"");
EXPECT_EQ(rv, u8"啊啊啊aaa");
}
}