Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace RenderFloat with FormatFloat #118

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: https://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
Loading