aboutsummaryrefslogtreecommitdiff
path: root/cmds/negcap_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmds/negcap_test.go')
-rw-r--r--cmds/negcap_test.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/cmds/negcap_test.go b/cmds/negcap_test.go
new file mode 100644
index 0000000..5076163
--- /dev/null
+++ b/cmds/negcap_test.go
@@ -0,0 +1,25 @@
+// 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)
+ }
+ })
+ }
+}