3 require File.dirname(__FILE__) + "/gruff_test_case"
5 class TestGruffNet < GruffTestCase
9 [:Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]],
10 [:Charles, [80, 54, 67, 54, 68, 70, 90, 95]],
11 [:Julie, [22, 29, 35, 38, 36, 40, 46, 57]],
12 [:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
13 [:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
14 ["Arthur", [5, 10, 13, 11, 6, 16, 22, 32]],
29 def test_net_small_values
31 [:small, [0.1, 0.14356, 0.0, 0.5674839, 0.456]],
32 [:small2, [0.2, 0.3, 0.1, 0.05, 0.9]]
36 g.title = "Small Values Net Graph Test"
37 @datasets.each do |data|
38 g.data(data[0], data[1])
40 g.write("test/output/net_small.png")
42 g = Gruff::Net.new(400)
43 g.title = "Small Values Net Graph Test 400px"
44 @datasets.each do |data|
45 g.data(data[0], data[1])
47 g.write("test/output/net_small_small.png")
50 def test_net_starts_with_zero
52 [:first0, [0, 5, 10, 8, 18]],
53 [:normal, [1, 2, 3, 4, 5]]
57 g.title = "Small Values Net Graph Test"
58 @datasets.each do |data|
59 g.data(data[0], data[1])
61 g.write("test/output/net_small_zero.png")
63 g = Gruff::Net.new(400)
64 g.title = "Small Values Net Graph Test 400px"
65 @datasets.each do |data|
66 g.data(data[0], data[1])
68 g.write("test/output/net_small_small_zero.png")
72 def test_net_large_values
74 [:large, [100_005, 35_000, 28_000, 27_000]],
75 [:large2, [35_000, 28_000, 27_000, 100_005]],
76 [:large3, [28_000, 27_000, 100_005, 35_000]],
77 [:large4, [1_238, 39_092, 27_938, 48_876]]
81 g.title = "Very Large Values Net Graph Test"
82 @datasets.each do |data|
83 g.data(data[0], data[1])
86 g.write("test/output/net_large.png")
89 def test_many_datapoints
91 g.title = "Many Multi-Net Graph Test"
98 g.data('many points', (0..50).collect {|i| rand(100) })
101 g.write("test/output/net_many.png")
105 def test_similar_high_end_values
107 g.title = "Similar High End Values Test"
108 g.data('similar points', %w(29.43 29.459 29.498 29.53 29.548 29.589 29.619 29.66 29.689 29.849 29.878 29.74 29.769 29.79 29.808 29.828).collect {|i| i.to_f} )
111 g.write("test/output/net_similar_high_end_values.png")
114 def test_many_nets_graph_small
115 g = Gruff::Net.new(400)
116 g.title = "Many Values Net Test 400px"
125 %w{jimmy jane philip arthur julie bert}.each do |student_name|
126 g.data(student_name, (0..50).collect { |i| rand 100 })
130 g.write("test/output/net_many_nets_small.png")
133 def test_dots_graph_tiny
134 g = Gruff::Net.new(300)
135 g.title = "Dots Test 300px"
144 %w{jimmy jane philip arthur julie bert}.each do |student_name|
145 g.data(student_name, (0..50).collect { |i| rand 100 })
149 g.write("test/output/net_dots_tiny.png")
153 g = Gruff::Net.new(400)
156 g.write("test/output/net_no_data.png")
158 g = Gruff::Net.new(400)
159 g.title = "No Data Title"
160 g.no_data_message = 'There is no data'
161 g.write("test/output/net_no_data_msg.png")
166 g = Gruff::Net.new(400)
167 g.title = "All Zeros"
169 g.data(:gus, [0,0,0,0])
172 g.write("test/output/net_no_data_other.png")
176 g = Gruff::Net.new(400)
177 g.labels = @sample_labels
178 @datasets.each do |data|
179 g.data(data[0], data[1])
182 g.write("test/output/net_no_title.png")
185 def test_no_net_markers
186 g = setup_basic_graph(400)
187 g.title = "No Net Markers"
188 g.hide_line_markers = true
189 g.write("test/output/net_no_net_markers.png")
193 g = setup_basic_graph(400)
194 g.title = "No Legend"
196 g.write("test/output/net_no_legend.png")
199 def test_nothing_but_the_graph
200 g = setup_basic_graph(400)
201 g.title = "THIS TITLE SHOULD NOT DISPLAY!!!"
202 g.hide_line_markers = true
205 g.write("test/output/net_nothing_but_the_graph.png")
209 g = setup_basic_graph('800x400')
210 g.title = "Wide Graph"
211 g.write("test/output/net_wide_graph.png")
213 g = setup_basic_graph('400x200')
214 g.title = "Wide Graph Small"
215 g.write("test/output/net_wide_graph_small.png")
220 def setup_basic_graph(size=800)
221 g = Gruff::Net.new(size)
222 g.title = "My Graph Title"
223 g.labels = @sample_labels
224 @datasets.each do |data|
225 g.data(data[0], data[1])