Skip to content

Commit

Permalink
Replace RenderFloat with FormatFloat
Browse files Browse the repository at this point in the history
I suppose it was previously named RenderFloat
  • Loading branch information
Jille authored and dustin committed Oct 9, 2023
1 parent 52939b8 commit 7ed3649
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions number.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var (
// * decimal separator
// * decimal precision
//
// Usage: s := RenderFloat(format, n)
// Usage: s := FormatFloat(format, n)
// The format parameter tells how to render the number n.
//
// See examples: http://play.golang.org/p/LXc1Ddm1lJ
Expand Down Expand Up @@ -111,7 +111,7 @@ func FormatFloat(format string, n float64) string {
// +0000
if formatIndx[0] == 0 {
if format[formatIndx[0]] != '+' {
panic("RenderFloat(): invalid positive sign directive")
panic("FormatFloat(): invalid positive sign directive")
}
positiveStr = "+"
formatIndx = formatIndx[1:]
Expand All @@ -125,7 +125,7 @@ func FormatFloat(format string, n float64) string {
// 000,000.00
if len(formatIndx) == 2 {
if (formatIndx[1] - formatIndx[0]) != 4 {
panic("RenderFloat(): thousands separator directive must be followed by 3 digit-specifiers")
panic("FormatFloat(): thousands separator directive must be followed by 3 digit-specifiers")
}
thousandStr = string(format[formatIndx[0]])
formatIndx = formatIndx[1:]
Expand Down
4 changes: 2 additions & 2 deletions number_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func TestFormatFloat(t *testing.T) {
}
// Test the things that could panic
panictests := []TestStruct{
{"RenderFloat(): invalid positive sign directive", "-", 12345.6789, "12,345.68"},
{"RenderFloat(): thousands separator directive must be followed by 3 digit-specifiers", "0.01", 12345.6789, "12,345.68"},
{"FormatFloat(): invalid positive sign directive", "-", 12345.6789, "12,345.68"},
{"FormatFloat(): thousands separator directive must be followed by 3 digit-specifiers", "0.01", 12345.6789, "12,345.68"},
}
for _, test := range panictests {
didPanic := false
Expand Down

0 comments on commit 7ed3649

Please sign in to comment.