forked from joliv/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spark_test.go
48 lines (41 loc) · 1.04 KB
/
spark_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
package spark
import (
"testing"
)
func TestLine(t *testing.T) {
in := []float64{1, 2, 3, 4, 5, 6, 7, 8}
out := "▁▂▃▄▅▆▇█"
if x := Line(in); x != out {
t.Errorf("Line(%v) = %v, want %v", in, x, out)
}
in = []float64{1, 0, 0, 1}
out = "█▁▁█"
if x := Line(in); x != out {
t.Errorf("Line(%v) = %v, want %v", in, x, out)
}
in = []float64{67, 71, 77, 85, 95, 104, 106, 105, 100, 89, 76, 66}
out = "▁▂▃▄▆███▇▅▃▁"
if x := Line(in); x != out {
t.Errorf("Line(%v) = %v, want %v", in, x, out)
}
}
// If all values are the same they should be treated as "minimal value"
func TestSameValues(t *testing.T) {
in := []float64{1}
out := "▁"
if x := Line(in); x != out {
t.Errorf("Line(%v) = %v, want %v", in, x, out)
}
in = []float64{1, 1, 1, 1}
out = "▁▁▁▁"
if x := Line(in); x != out {
t.Errorf("Line(%v) = %v, want %v", in, x, out)
}
}
func TestLineEmpty(t *testing.T) {
in := []float64{}
out := ""
if x := Line(in); x != out {
t.Errorf("Line(%v) = %v, want %v", in, x, out)
}
}