-
Notifications
You must be signed in to change notification settings - Fork 0
/
value_formatter_test.go
53 lines (41 loc) · 1.37 KB
/
value_formatter_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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package chart
import (
"testing"
"time"
"github.com/userstyles-world/go-chart/v2/testutil"
)
func TestTimeValueFormatterWithFormat(t *testing.T) {
// replaced new assertions helper
d := time.Now()
di := TimeToFloat64(d)
s := formatTime(d, DefaultDateFormat)
si := formatTime(di, DefaultDateFormat)
testutil.AssertEqual(t, s, si)
sd := TimeValueFormatter(d)
sdi := TimeValueFormatter(di)
testutil.AssertEqual(t, s, sd)
testutil.AssertEqual(t, s, sdi)
}
func TestFloatValueFormatter(t *testing.T) {
// replaced new assertions helper
testutil.AssertEqual(t, "1234.00", FloatValueFormatter(1234.00))
}
func TestFloatValueFormatterWithFloat32Input(t *testing.T) {
// replaced new assertions helper
testutil.AssertEqual(t, "1234.00", FloatValueFormatter(float32(1234.00)))
}
func TestFloatValueFormatterWithIntegerInput(t *testing.T) {
// replaced new assertions helper
testutil.AssertEqual(t, "1234.00", FloatValueFormatter(1234))
}
func TestFloatValueFormatterWithInt64Input(t *testing.T) {
// replaced new assertions helper
testutil.AssertEqual(t, "1234.00", FloatValueFormatter(int64(1234)))
}
func TestFloatValueFormatterWithFormat(t *testing.T) {
// replaced new assertions helper
v := 123.456
sv := FloatValueFormatterWithFormat(v, "%.3f")
testutil.AssertEqual(t, "123.456", sv)
testutil.AssertEqual(t, "123.000", FloatValueFormatterWithFormat(123, "%.3f"))
}