utils/numbers_test.go

21 lines
478 B
Go

package utils
import "testing"
func TestRoundFloat(t *testing.T) {
data := map[float64]float64{
-13.37004711: -13.37,
0.0000000000000000: 0.0,
2.71828182845904523536: 2.72,
3.141592653589793238462643383279502884197169399375105820974944: 3.14,
10.0: 10.0,
}
for d, expectedResult := range data {
result := RoundFloat(d, 2)
if result != expectedResult {
t.Errorf("\ngot: %.2f\nwanted: %.2f\nfor: %f", result, expectedResult, d)
}
}
}