fix: harden small core containers

This commit is contained in:
2026-08-12 15:54:16 +09:00
parent cec62cc40f
commit 103f2ec448
11 changed files with 136 additions and 18 deletions

View File

@@ -82,3 +82,21 @@ str_utf8_capacity(struct ct *t)
CT_EQ_STR(t, "😀", buf);
CT_EQ_INT(t, 'Z', buf[5]);
}
void
str_invalid_and_full_appends(struct ct *t)
{
Str s;
int i;
sinit(&s, nil, 1);
CT_EQ_INT(t, 0, s.n);
sinit(&s, "x", -1);
CT_EQ_INT(t, 0, s.n);
for(i = 0; i < Maxrunes; i++)
s.r[i] = 'a';
s.n = Maxrunes;
sputr(&s, 'z');
CT_EQ_INT(t, Maxrunes, s.n);
CT_EQ_INT(t, 'a', s.r[Maxrunes-1]);
}