Debian Codegraph @

xaxis_test.go

raw symbols SCIP
1 package chart
2
3 import (
4 "testing"
5
6 "github.com/wcharczuk/go-chart/v2/testutil"
7 )
8
9 func TestXAxisGetTicks(t *testing.T) {
10 // replaced new assertions helper
11
12 r, err := PNG(1024, 1024)
13 testutil.AssertNil(t, err)
14
15 f, err := GetDefaultFont()
16 testutil.AssertNil(t, err)
17
18 xa := XAxis{}
19 xr := &ContinuousRange{Min: 10, Max: 100, Domain: 1024}
20 styleDefaults := Style{
21 Font: f,
22 FontSize: 10.0,
23 }
24 vf := FloatValueFormatter
25 ticks := xa.GetTicks(r, xr, styleDefaults, vf)
26 testutil.AssertLen(t, ticks, 16)
27 }
28
29 func TestXAxisGetTicksWithUserDefaults(t *testing.T) {
30 // replaced new assertions helper
31
32 r, err := PNG(1024, 1024)
33 testutil.AssertNil(t, err)
34
35 f, err := GetDefaultFont()
36 testutil.AssertNil(t, err)
37
38 xa := XAxis{
39 Ticks: []Tick{{Value: 1.0, Label: "1.0"}},
40 }
41 xr := &ContinuousRange{Min: 10, Max: 100, Domain: 1024}
42 styleDefaults := Style{
43 Font: f,
44 FontSize: 10.0,
45 }
46 vf := FloatValueFormatter
47 ticks := xa.GetTicks(r, xr, styleDefaults, vf)
48 testutil.AssertLen(t, ticks, 1)
49 }
50
51 func TestXAxisMeasure(t *testing.T) {
52 // replaced new assertions helper
53
54 f, err := GetDefaultFont()
55 testutil.AssertNil(t, err)
56 style := Style{
57 Font: f,
58 FontSize: 10.0,
59 }
60 r, err := PNG(100, 100)
61 testutil.AssertNil(t, err)
62 ticks := []Tick{{Value: 1.0, Label: "1.0"}, {Value: 2.0, Label: "2.0"}, {Value: 3.0, Label: "3.0"}}
63 xa := XAxis{}
64 xab := xa.Measure(r, NewBox(0, 0, 100, 100), &ContinuousRange{Min: 1.0, Max: 3.0, Domain: 100}, style, ticks)
65 testutil.AssertEqual(t, 122, xab.Width())
66 testutil.AssertEqual(t, 21, xab.Height())
67 }