-
Notifications
You must be signed in to change notification settings - Fork 27
/
chart_type_test.go
59 lines (54 loc) · 1.28 KB
/
chart_type_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
package main
import (
"testing"
"github.com/marianogappa/chart/format"
)
func TestResolveChartType(t *testing.T) {
tests := []struct {
name string
t chartType
lf string
expectedT chartType
}{
{
name: "default case",
t: undefinedChartType,
lf: "sf",
expectedT: pie,
},
{
name: "pie selected; inference ignored",
t: pie,
lf: "sf",
expectedT: pie,
},
{
name: "bar selected; inference ignored",
t: bar,
lf: "sf",
expectedT: bar,
},
{
name: "more than one column of floats, with strings",
t: undefinedChartType,
lf: "sff",
expectedT: line,
},
{
name: "more than one column of floats, without strings",
t: undefinedChartType,
lf: "ff",
expectedT: scatter,
},
}
for _, ts := range tests {
lf, _ := format.NewLineFormat(ts.lf, ' ', "") // ignoring errors as we're not testing the format package here
result, err := resolveChartType(ts.t, lf, 123)
if err != nil { // TODO test cases where there's an error
t.Errorf("%v: there was an error resolving the chart type", ts.name)
}
if result != ts.expectedT {
t.Errorf("%v: %v was not equal to %v", ts.name, result, ts.expectedT)
}
}
}