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

Function TestSafeFloatValue

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

Source from the content-addressed store, hash-verified

231}
232
233func TestSafeFloatValue(t *testing.T) {
234 tests := []struct {
235 name string
236 input interface{}
237 expected float64
238 }{
239 {
240 name: "float64 input",
241 input: 123.45,
242 expected: 123.45,
243 },
244 {
245 name: "integer input",
246 input: 123,
247 expected: 123.0,
248 },
249 {
250 name: "string number",
251 input: "123.45",
252 expected: 123.45,
253 },
254 {
255 name: "string integer",
256 input: "123",
257 expected: 123.0,
258 },
259 {
260 name: "invalid string",
261 input: "not-a-number",
262 expected: 0.0,
263 },
264 {
265 name: "nil input",
266 input: nil,
267 expected: 0.0,
268 },
269 {
270 name: "boolean input",
271 input: true,
272 expected: 0.0,
273 },
274 {
275 name: "nan string",
276 input: "NaN",
277 expected: 0.0,
278 },
279 {
280 name: "infinity string",
281 input: "+Inf",
282 expected: 0.0,
283 },
284 {
285 name: "nan float",
286 input: math.NaN(),
287 expected: 0.0,
288 },
289 {
290 name: "infinity float",

Callers

nothing calls this directly

Calls 2

SafeFloatValueFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected