diff options
Diffstat (limited to 'vendor/github.com/tdewolff/parse/strconv/price_test.go')
-rw-r--r-- | vendor/github.com/tdewolff/parse/strconv/price_test.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/vendor/github.com/tdewolff/parse/strconv/price_test.go b/vendor/github.com/tdewolff/parse/strconv/price_test.go new file mode 100644 index 0000000..3b3fccf --- /dev/null +++ b/vendor/github.com/tdewolff/parse/strconv/price_test.go @@ -0,0 +1,29 @@ +package strconv // import "github.com/tdewolff/parse/strconv" + +import ( + "testing" + + "github.com/tdewolff/test" +) + +func TestAppendPrice(t *testing.T) { + priceTests := []struct { + price int64 + dec bool + expected string + }{ + {0, false, "0"}, + {0, true, "0.00"}, + {100, true, "1.00"}, + {-100, true, "1.00"}, + {100000, false, "1,000"}, + {100000, true, "1,000.00"}, + {123456789012, true, "1,234,567,890.12"}, + {9223372036854775807, true, "92,233,720,368,547,758.07"}, + {-9223372036854775808, true, "92,233,720,368,547,758.08"}, + } + for _, tt := range priceTests { + price := AppendPrice([]byte{}, tt.price, tt.dec, ',', '.') + test.String(t, string(price), tt.expected, "for", tt.price) + } +} |