MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / TestGetFloatFiltersNonFiniteValues

Function TestGetFloatFiltersNonFiniteValues

pkg/api/utils_test.go:304–343  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

302}
303
304func TestGetFloatFiltersNonFiniteValues(t *testing.T) {
305 tests := []struct {
306 name string
307 input interface{}
308 expected float64
309 }{
310 {
311 name: "finite float64",
312 input: 42.5,
313 expected: 42.5,
314 },
315 {
316 name: "nan float64",
317 input: math.NaN(),
318 expected: 0.0,
319 },
320 {
321 name: "infinity float64",
322 input: math.Inf(1),
323 expected: 0.0,
324 },
325 {
326 name: "nan string",
327 input: "NaN",
328 expected: 0.0,
329 },
330 {
331 name: "infinity string",
332 input: "Inf",
333 expected: 0.0,
334 },
335 }
336
337 for _, tt := range tests {
338 t.Run(tt.name, func(t *testing.T) {
339 data := map[string]interface{}{"cpu": tt.input}
340 assert.Equal(t, tt.expected, getFloat(data, "cpu"))
341 })
342 }
343}
344
345func TestSafeBoolValue(t *testing.T) {
346 tests := []struct {

Callers

nothing calls this directly

Calls 2

getFloatFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected