str: drop argument checks no caller can trip

sinit's nil and negative-length tests and stoutf's zero-size test only
had test callers; every real caller passes a buffer and its size. The
len > n check after fullrune succeeded could never fire.
This commit is contained in:
2026-08-16 18:36:40 +09:00
parent 723a271a9c
commit 0aef3506b6
2 changed files with 4 additions and 20 deletions

View File

@@ -76,7 +76,6 @@ str_utf8_capacity(struct ct *t)
int n;
char *want;
} cases[] = {
{ 0, 0, nil },
{ 1, 0, "" },
{ 2, 1, "a" },
{ 3, 1, "a" },
@@ -95,10 +94,6 @@ str_utf8_capacity(struct ct *t)
if(n != cases[i].n)
CT_ERRORF(t, "size %d: want length %d, got %d",
cases[i].size, cases[i].n, n);
if(cases[i].size == 0){
CT_EQ_INT(t, 'Z', buf[0]);
continue;
}
if(strcmp(cases[i].want, buf) != 0)
CT_ERRORF(t, "size %d: want \"%s\", got \"%s\"",
cases[i].size, cases[i].want, buf);
@@ -120,10 +115,6 @@ str_invalid_and_full_appends(struct ct *t)
Str s;
int i;
CT_CHECK(t, !sinit(&s, nil, 1));
CT_EQ_INT(t, 0, s.n);
CT_CHECK(t, !sinit(&s, "x", -1));
CT_EQ_INT(t, 0, s.n);
for(i = 0; i < Maxrunes; i++)
s.r[i] = 'a';
s.n = Maxrunes;