feat(Text): add ASCII-explicit helpers and bounded split/replace/repeat/join (M-TEXT-02)

This commit is contained in:
faumaray committed 2026-11-24 03:14:41 +03:00
1 parent 68963fcd1d
commit 883bbdcf38
5 files changed
+468

No files matched your search

+20
View File
@@ -171,3 +171,23 @@ Void::Testing::Test str_to_double_valid()
Void::Testing::expect(to_double("3.14", v));
Void::Testing::expect(v > 3.13 && v < 3.15);
}
Void::Testing::Test str_ascii_helpers_preserve_high_bytes_and_nuls()
{
static_assert(trim_ascii(" \t\r\nabc\n ") == "abc");
static_assert(is_alpha_ascii("AbCd"));
static_assert(!is_alpha_ascii("\xC3\xA9"));
static_assert(is_digit_ascii("0123456789"));
static_assert(is_alnum_ascii("Az09"));
static_assert(iequals_ascii("HeLlO\xFF", "hElLo\xFF"));
static_assert(!iequals_ascii("abc", "abcd"));
const std::string mixed{" \xC3\xA9""Ab\xFF""Z\0x\n", 10};
Void::Testing::expect_eq(trim_left_ascii(mixed).size(), std::size_t{9});
Void::Testing::expect_eq(trim_right_ascii(mixed).size(), std::size_t{9});
Void::Testing::expect_eq(trim_ascii(mixed).size(), std::size_t{8});
const std::string lower = to_lower_ascii("A\x80\xFFZ");
Void::Testing::expect_eq(lower, std::string{"a\x80\xFFz"});
const std::string upper = to_upper_ascii("a\x80\xFFz");
Void::Testing::expect_eq(upper, std::string{"A\x80\xFFZ"});
}