refactor(tui): use strconv.Atoi in parseIntClamp, drop spurious error return

This commit is contained in:
MDietermann
2026-04-13 22:00:49 +02:00
parent 394fb33d0c
commit e7aa75735d
2 changed files with 27 additions and 20 deletions

View File

@@ -45,16 +45,18 @@ func TestRenderPlanEmpty(t *testing.T) {
func TestParseIntClamp(t *testing.T) {
cases := map[string]int{
"": 1,
" ": 1,
"abc": 1,
"0": 1,
"-5": 1,
"3": 3,
"12": 12,
"": 1,
" ": 1,
"abc": 1,
"3abc": 1, // partial match is rejected (strconv.Atoi, not Sscanf)
"0": 1,
"-5": 1,
"3": 3,
"12": 12,
"99999999999999999999": 1, // overflow → fallback
}
for in, want := range cases {
got, _ := parseIntClamp(in, 1)
got := parseIntClamp(in, 1)
if got != want {
t.Errorf("parseIntClamp(%q) = %d, want %d", in, got, want)
}