Add variants of DString.insert_at to match .append (#1510)

This commit is contained in:
chri-k
2024-10-02 11:22:59 +03:00
committed by GitHub
parent 607a625641
commit 2233f24c8f
3 changed files with 124 additions and 3 deletions

View File

@@ -184,6 +184,23 @@ fn void test_insert_at()
str.insert_at(5, " shiny");
s = str.str_view();
assert(s == "hello shiny world", "got '%s'; want 'hello shiny world'", s);
str.insert_at(0, '[');
s = str.str_view();
assert(s == "[hello shiny world", "got '%s'; want '[hello shiny world'", s);
str.insert_at(18, ']');
s = str.str_view();
assert(s == "[hello shiny world]", "got '%s'; want 'hello shiny world]'", s);
str.insert_at(0, 'ꫩ');
s = str.str_view();
assert(s == "ꫩ[hello shiny world]", "got '%s'; want 'ꫩ[hello shiny world]'", s);
// ꫩ is 3 bytes long
str.insert_utf32_at(4, {'寃', 't', 'e', 'x', 't', '¥'});
s = str.str_view();
assert(s == "ꫩ[寃text¥hello shiny world]", "got '%s'; want 'ꫩ[寃text¥hello shiny world]'", s);
}
fn void test_insert_at_overlaps()