// The shared per-feed negative ceiling: uncapped at pct 0, floored so a // young pool isn't strangled, and clamped to the target itself. package cmds import "testing" func TestFeedNegCap(t *testing.T) { for _, tc := range []struct { name string pct, ratio, pos, want int }{ {"uncapped at 0", 0, 20, 500, 0}, {"normal: 5% of 10000-target", 5, 20, 500, 500}, {"floor wins for young pools", 5, 20, 10, 50}, // target 200, 5% = 10 → floor 50 {"clamped to the target", 90, 20, 3, 54}, // target 60, 90% = 54 {"floor can exceed a tiny target", 5, 20, 1, 20}, // target 20 → clamp to 20 } { t.Run(tc.name, func(t *testing.T) { if got := feedNegCap(tc.pct, tc.ratio, tc.pos); got != tc.want { t.Errorf("feedNegCap(%d, %d, %d) = %d, want %d", tc.pct, tc.ratio, tc.pos, got, tc.want) } }) } }