forked from wcharczuk/go-chart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtick_test.go
60 lines (46 loc) · 1.3 KB
/
tick_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
54
55
56
57
58
59
60
package chart
import (
"testing"
"github.com/wcharczuk/go-chart/v2/testutil"
)
func TestGenerateContinuousTicks(t *testing.T) {
// replaced new assertions helper
f, err := GetDefaultFont()
testutil.AssertNil(t, err)
r, err := PNG(1024, 1024)
testutil.AssertNil(t, err)
r.SetFont(f)
ra := &ContinuousRange{
Min: 0.0,
Max: 10.0,
Domain: 256,
}
vf := FloatValueFormatter
ticks := GenerateContinuousTicks(r, ra, false, Style{}, vf)
testutil.AssertNotEmpty(t, ticks)
testutil.AssertLen(t, ticks, 11)
testutil.AssertEqual(t, 0.0, ticks[0].Value)
testutil.AssertEqual(t, 10, ticks[len(ticks)-1].Value)
}
func TestGenerateContinuousTicksDescending(t *testing.T) {
// replaced new assertions helper
f, err := GetDefaultFont()
testutil.AssertNil(t, err)
r, err := PNG(1024, 1024)
testutil.AssertNil(t, err)
r.SetFont(f)
ra := &ContinuousRange{
Min: 0.0,
Max: 10.0,
Domain: 256,
Descending: true,
}
vf := FloatValueFormatter
ticks := GenerateContinuousTicks(r, ra, false, Style{}, vf)
testutil.AssertNotEmpty(t, ticks)
testutil.AssertLen(t, ticks, 11)
testutil.AssertEqual(t, 10.0, ticks[0].Value)
testutil.AssertEqual(t, 9.0, ticks[1].Value)
testutil.AssertEqual(t, 1.0, ticks[len(ticks)-2].Value)
testutil.AssertEqual(t, 0.0, ticks[len(ticks)-1].Value)
}