-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlimits_test.go
More file actions
38 lines (35 loc) · 1.14 KB
/
limits_test.go
File metadata and controls
38 lines (35 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package mcp
import "testing"
func TestCapResultsHonorsCap(t *testing.T) {
if got := CapResults(1000, 500); got != 500 {
t.Fatalf("CapResults(1000, 500) = %d, want 500", got)
}
if got := CapResults(10, 500); got != 10 {
t.Fatalf("CapResults(10, 500) = %d, want 10", got)
}
if got := CapResults(-5, 500); got != 1 {
t.Fatalf("CapResults(-5, 500) = %d, want 1 (clamp floor)", got)
}
if got := CapResults(0, 500); got != 1 {
t.Fatalf("CapResults(0, 500) = %d, want 1 (clamp floor)", got)
}
// Fallback when hardCap is unset.
if got := CapResults(9999, 0); got != DefaultMaxResults {
t.Fatalf("CapResults(9999, 0) = %d, want default %d", got, DefaultMaxResults)
}
}
func TestCapDepthHonorsCap(t *testing.T) {
if got := CapDepth(999, 10); got != 10 {
t.Fatalf("CapDepth(999, 10) = %d, want 10", got)
}
if got := CapDepth(0, 10); got != 1 {
t.Fatalf("CapDepth(0, 10) = %d, want 1 (clamp floor)", got)
}
if got := CapDepth(3, 10); got != 3 {
t.Fatalf("CapDepth(3, 10) = %d, want 3", got)
}
// Fallback default.
if got := CapDepth(50, 0); got != DefaultMaxDepth {
t.Fatalf("CapDepth(50, 0) = %d, want default %d", got, DefaultMaxDepth)
}
}