-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSparkyTest.groovy
85 lines (67 loc) · 2.43 KB
/
SparkyTest.groovy
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import groovy.util.GroovyShellTestCase
class SparkyTest extends GroovyShellTestCase {
def out = new ByteArrayOutputStream()
void setUp() {
super.setUp()
System.setOut new PrintStream(out)
}
void tearDown() {
super.tearDown()
}
def binding(variables) {
withBinding(variables) {
shell.evaluate(new File('sparky'))
}
}
void "test it shows help with help argv"() {
binding args: ['help']
assert out.toString().trim().contains('USAGE')
}
void "test it graphs argv data"() {
binding args: ['1,5,22,13,5']
assert '▁▂█▅▂' == out.toString().trim()
}
void "test it charts pipe comma data"() {
System.setIn new ByteArrayInputStream('0,30,55,80,33,150'.getBytes("UTF-8"))
binding args: []
assert '▁▂▃▄▂█' == out.toString().trim()
}
void "test it charts pipe spaced data"() {
System.setIn new ByteArrayInputStream('0 30 55 80 33 150'.getBytes("UTF-8"))
binding args: []
assert '▁▂▃▄▂█' == out.toString().trim()
}
void "test it charts pipe newline data"() {
System.setIn new ByteArrayInputStream('0\n30\n55\n80\n33\n150'.getBytes("UTF-8"))
binding args: []
assert '▁▂▃▄▂█' == out.toString().trim()
}
void "test it charts spaced data"() {
binding args: ['0', '30', '55', '80', '33', '150']
assert '▁▂▃▄▂█' == out.toString().trim()
}
void "test it charts way spaced data"() {
binding args: ['0', '30', ' 55', '80', '33', ' 150']
assert '▁▂▃▄▂█' == out.toString().trim()
}
void "test it handles decimals"() {
binding args: "5.5,20".tokenize(',')
assert '▁▇' == out.toString().trim()
}
void "test it charts 100 lt 300"() {
binding args: "1,2,3,4,100,5,10,20,50,300".tokenize(',')
assert '▁▁▁▁▃▁▁▁▂█' == out.toString().trim()
}
void "test it charts 50 lt 100"() {
binding args: "1,50,100".tokenize(',')
assert '▁▄█' == out.toString().trim()
}
void "test it charts 4 lt 8"() {
binding args: "2,4,8".tokenize(',')
assert '▁▃█' == out.toString().trim()
}
void "test it no tier 0"() {
binding args: "1,2,3,4,5".tokenize(',')
assert '▁▂▄▆█' == out.toString().trim()
}
}