...
1 package eu
2
3 import "testing"
4
5 func TestPercent(t *testing.T) {
6
7 tests := []struct {
8 num float64
9 v uint64
10 expected string
11 }{
12 {
13 num: 23,
14 v: 0,
15 expected: "%\u00a023",
16 },
17 {
18 num: 23.45,
19 v: 2,
20 expected: "%\u00a023,45",
21 },
22 {
23 num: 1023.45,
24 v: 2,
25 expected: "%\u00a01.023,45",
26 },
27 {
28 num: -1023.45,
29 v: 2,
30 expected: "%\u00a0−1.023,45",
31 },
32 }
33
34 trans := New()
35
36 for _, tt := range tests {
37 s := string(trans.FmtPercent(tt.num, tt.v))
38 if s != tt.expected {
39 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
40 }
41 }
42 }
43
View as plain text