-
Notifications
You must be signed in to change notification settings - Fork 1
/
series_test.go
58 lines (49 loc) · 1.05 KB
/
series_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
package charts
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewSeriesListDataFromValues(t *testing.T) {
assert.Equal(t, SeriesList{
{
Type: ChartTypeBar,
Data: []SeriesData{
{
Value: 1.0,
},
},
},
}, NewSeriesListDataFromValues([][]float64{
{
1,
},
}, ChartTypeBar))
}
func TestSeriesLists(t *testing.T) {
seriesList := NewSeriesListDataFromValues([][]float64{
{1, 2},
{10},
}, ChartTypeBar)
assert.Equal(t, 2, len(seriesList.Filter(ChartTypeBar)))
assert.Equal(t, 0, len(seriesList.Filter(ChartTypeLine)))
min, max := seriesList.GetMinMax(0)
assert.Equal(t, float64(10), max)
assert.Equal(t, float64(1), min)
assert.Equal(t, seriesSummary{
MaxIndex: 1,
MaxValue: 2,
MinIndex: 0,
MinValue: 1,
AverageValue: 1.5,
}, seriesList[0].Summary())
}
func TestFormatter(t *testing.T) {
assert.Equal(t, "a: 12%", NewPieLabelFormatter([]string{
"a",
"b",
}, "")(0, 10, 0.12))
assert.Equal(t, "10", NewValueLabelFormatter([]string{
"a",
"b",
}, "")(0, 10, 0.12))
}