MCPcopy
hub / github.com/pelletier/go-toml / TestUnmarshal_Floats

Function TestUnmarshal_Floats

unmarshaler_test.go:323–458  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

321}
322
323func TestUnmarshal_Floats(t *testing.T) {
324 examples := []struct {
325 desc string
326 input string
327 expected float64
328 testFn func(t *testing.T, v float64)
329 err bool
330 }{
331 {
332 desc: "float pi",
333 input: `3.1415`,
334 expected: 3.1415,
335 },
336 {
337 desc: "float negative",
338 input: `-0.01`,
339 expected: -0.01,
340 },
341 {
342 desc: "float signed exponent",
343 input: `5e+22`,
344 expected: 5e+22,
345 },
346 {
347 desc: "float exponent lowercase",
348 input: `1e06`,
349 expected: 1e06,
350 },
351 {
352 desc: "float exponent uppercase",
353 input: `-2E-2`,
354 expected: -2e-2,
355 },
356 {
357 desc: "float exponent zero",
358 input: `0e0`,
359 expected: 0.0,
360 },
361 {
362 desc: "float upper exponent zero",
363 input: `0E0`,
364 expected: 0.0,
365 },
366 {
367 desc: "float zero without decimals",
368 input: `0`,
369 expected: 0.0,
370 },
371 {
372 desc: "float fractional with exponent",
373 input: `6.626e-34`,
374 expected: 6.626e-34,
375 },
376 {
377 desc: "float underscores",
378 input: `224_617.445_991_228`,
379 expected: 224_617.445_991_228,
380 },

Callers

nothing calls this directly

Calls 4

TrueFunction · 0.92
ErrorFunction · 0.92
NoErrorFunction · 0.92
EqualFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…