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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
package en
import (
"testing"
"github.com/go-playground/locales/currency"
)
func TestCurrency(t *testing.T) {
tests := []struct {
num float64
v uint64
expected string
}{
{
num: 1123456.5643,
v: 2,
expected: "$1,123,456.56",
},
{
num: 1123456.5643,
v: 1,
expected: "$1,123,456.60",
},
{
num: 221123456.5643,
v: 3,
expected: "$221,123,456.564",
},
{
num: -221123456.5643,
v: 3,
expected: "-$221,123,456.564",
},
}
trans := New()
for _, tt := range tests {
s := string(trans.FmtCurrency(tt.num, tt.v, currency.USD))
if s != tt.expected {
t.Errorf("Expected '%s' Got '%s", tt.expected, s)
}
}
}
|