-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`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.
- Loading branch information
Mahmood Ali
committed
Jan 18, 2019
1 parent
41c3250
commit b1293a8
Showing
6 changed files
with
68 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
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)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters