open-nomad/api/utils_test.go
Mahmood Ali 7897dec9d9 api: move formatFloat function
`helpers.FormatFloat` function is only used in `api`.  Moving it and
marking it as private.  We can re-export it if we find value later.
2019-01-18 15:31:31 -05:00

40 lines
454 B
Go

package api
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestFormatRoundedFloat(t *testing.T) {
cases := []struct {
input float64
expected string
}{
{
1323,
"1323",
},
{
10.321,
"10.321",
},
{
100000.31324324,
"100000.313",
},
{
100000.3,
"100000.3",
},
{
0.7654321,
"0.765",
},
}
for _, c := range cases {
require.Equal(t, c.expected, formatFloat(c.input, 3))
}
}