MCPcopy Index your code
hub / github.com/codehamr/codehamr / TestFromHeadersRejectsNaNAndInf

Function TestFromHeadersRejectsNaNAndInf

internal/cloud/cloud_test.go:88–100  ·  view source on GitHub ↗

TestFromHeadersRejectsNaNAndInf: ParseFloat accepts NaN/±Inf without error and the [0,1] clamp is a no-op against NaN, so they'd render as int(NaN*100+0.5) → MinInt64. Both must collapse to the missing-header zero.

(t *testing.T)

Source from the content-addressed store, hash-verified

86// error and the [0,1] clamp is a no-op against NaN, so they'd render as
87// int(NaN*100+0.5) → MinInt64. Both must collapse to the missing-header zero.
88func TestFromHeadersRejectsNaNAndInf(t *testing.T) {
89 cases := []string{"NaN", "+Inf", "-Inf", "Infinity"}
90 for _, raw := range cases {
91 t.Run(raw, func(t *testing.T) {
92 h := http.Header{}
93 h.Set("X-Budget-Remaining", raw)
94 got := FromHeaders(h)
95 if got.Set {
96 t.Fatalf("X-Budget-Remaining=%q must be treated as missing, got %+v", raw, got)
97 }
98 })
99 }
100}
101
102func TestStatusSuffix(t *testing.T) {
103 if got := (BudgetStatus{}).StatusSuffix(); got != "" {

Callers

nothing calls this directly

Calls 1

FromHeadersFunction · 0.85

Tested by

no test coverage detected