-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathaccounting15_test.go
25 lines (19 loc) · 957 Bytes
/
accounting15_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// +build go1.5
package accounting
import (
"math/big"
"testing"
)
func TestFormatMoneyBigFloat(t *testing.T) {
accounting := Accounting{Symbol: "$", Precision: 2}
AssertEqual(t, accounting.FormatMoneyBigFloat(big.NewFloat(123456789.213123)), "$123,456,789.21")
accounting = Accounting{Symbol: "€", Precision: 2, Thousand: ".", Decimal: ","}
AssertEqual(t, accounting.FormatMoneyBigFloat(big.NewFloat(4999.99)), "€4.999,99")
accounting = Accounting{Symbol: "£ ", Precision: 0}
AssertEqual(t, accounting.FormatMoneyBigFloat(big.NewFloat(500000.0)), "£ 500,000")
accounting = Accounting{Symbol: "GBP", Precision: 0,
Format: "%s %v", FormatNegative: "%s (%v)", FormatZero: "%s --"}
AssertEqual(t, accounting.FormatMoneyBigFloat(big.NewFloat(1000000.0)), "GBP 1,000,000")
AssertEqual(t, accounting.FormatMoneyBigFloat(big.NewFloat(-5000.0)), "GBP (5,000)")
AssertEqual(t, accounting.FormatMoneyBigFloat(big.NewFloat(0.0)), "GBP --")
}