MCPcopy
hub / github.com/stretchr/testify / toFloat

Function toFloat

assert/assertions.go:1406–1442  ·  view source on GitHub ↗
(x interface{})

Source from the content-addressed store, hash-verified

1404}
1405
1406func toFloat(x interface{}) (float64, bool) {
1407 var xf float64
1408 xok := true
1409
1410 switch xn := x.(type) {
1411 case uint:
1412 xf = float64(xn)
1413 case uint8:
1414 xf = float64(xn)
1415 case uint16:
1416 xf = float64(xn)
1417 case uint32:
1418 xf = float64(xn)
1419 case uint64:
1420 xf = float64(xn)
1421 case int:
1422 xf = float64(xn)
1423 case int8:
1424 xf = float64(xn)
1425 case int16:
1426 xf = float64(xn)
1427 case int32:
1428 xf = float64(xn)
1429 case int64:
1430 xf = float64(xn)
1431 case float32:
1432 xf = float64(xn)
1433 case float64:
1434 xf = xn
1435 case time.Duration:
1436 xf = float64(xn)
1437 default:
1438 xok = false
1439 }
1440
1441 return xf, xok
1442}
1443
1444// InDelta asserts that the two numerals are within delta of each other.
1445//

Callers 2

InDeltaFunction · 0.85
calcRelativeErrorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected