summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/drawing/tc_bar_3D_chart.rb37
-rw-r--r--test/drawing/tc_bar_chart.rb25
2 files changed, 39 insertions, 23 deletions
diff --git a/test/drawing/tc_bar_3D_chart.rb b/test/drawing/tc_bar_3D_chart.rb
index 0cae7af6..b7a1eca4 100644
--- a/test/drawing/tc_bar_3D_chart.rb
+++ b/test/drawing/tc_bar_3D_chart.rb
@@ -32,18 +32,19 @@ class TestBar3DChart < Test::Unit::TestCase
assert(@chart.grouping == :standard)
end
+ def test_gap_width
+ assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = -1 }
+ assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = 501 }
+ assert_nothing_raised("allow valid gapWidth") { @chart.gap_width = 200 }
+ assert_equal(@chart.gap_width, 200, 'gap width is incorrect')
+ end
- def test_gapWidth
- assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = 200 }
- assert_nothing_raised("allow valid gapWidth") { @chart.gap_width = "200%" }
- assert(@chart.gap_width == "200%")
- end
-
- def test_gapDepth
- assert_raise(ArgumentError, "require valid gap_depth") { @chart.gap_depth = 200 }
- assert_nothing_raised("allow valid gap_depth") { @chart.gap_depth = "200%" }
- assert(@chart.gap_depth == "200%")
- end
+ def test_gap_depth
+ assert_raise(ArgumentError, "require valid gap_depth") { @chart.gap_depth = -1 }
+ assert_raise(ArgumentError, "require valid gap_depth") { @chart.gap_depth = 501 }
+ assert_nothing_raised("allow valid gap_depth") { @chart.gap_depth = 200 }
+ assert_equal(@chart.gap_depth, 200, 'gap depth is incorrect')
+ end
def test_shape
assert_raise(ArgumentError, "require valid shape") { @chart.shape = :star }
@@ -68,4 +69,18 @@ class TestBar3DChart < Test::Unit::TestCase
val_axis_position = str.index(@chart.axes[:val_axis].id.to_s)
assert(cat_axis_position < val_axis_position, "cat_axis must occur earlier than val_axis in the XML")
end
+
+ def test_to_xml_string_has_gap_depth
+ gap_depth_value = rand(0..500)
+ @chart.gap_depth = gap_depth_value
+ doc = Nokogiri::XML(@chart.to_xml_string)
+ assert_equal(doc.xpath("//c:bar3DChart/c:gapDepth").first.attribute('val').value, gap_depth_value.to_s)
+ end
+
+ def test_to_xml_string_has_gap_width
+ gap_width_value = rand(0..500)
+ @chart.gap_width = gap_width_value
+ doc = Nokogiri::XML(@chart.to_xml_string)
+ assert_equal(doc.xpath("//c:bar3DChart/c:gapWidth").first.attribute('val').value, gap_width_value.to_s)
+ end
end
diff --git a/test/drawing/tc_bar_chart.rb b/test/drawing/tc_bar_chart.rb
index d064e5be..c8bdc8d0 100644
--- a/test/drawing/tc_bar_chart.rb
+++ b/test/drawing/tc_bar_chart.rb
@@ -32,18 +32,12 @@ class TestBarChart < Test::Unit::TestCase
assert(@chart.grouping == :standard)
end
-
- def test_gapWidth
- assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = 200 }
- assert_nothing_raised("allow valid gapWidth") { @chart.gap_width = "200%" }
- assert(@chart.gap_width == "200%")
- end
-
- def test_gapDepth
- assert_raise(ArgumentError, "require valid gap_depth") { @chart.gap_depth = 200 }
- assert_nothing_raised("allow valid gap_depth") { @chart.gap_depth = "200%" }
- assert(@chart.gap_depth == "200%")
- end
+ def test_gap_width
+ assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = -1 }
+ assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = 501 }
+ assert_nothing_raised("allow valid gap width") { @chart.gap_width = 200 }
+ assert_equal(@chart.gap_width, 200, 'gap width is incorrect')
+ end
def test_overlap
assert_raise(ArgumentError, "require valid overlap") { @chart.overlap = -101 }
@@ -76,6 +70,13 @@ class TestBarChart < Test::Unit::TestCase
assert(cat_axis_position < val_axis_position, "cat_axis must occur earlier than val_axis in the XML")
end
+ def test_to_xml_string_has_gap_width
+ gap_width_value = rand(0..500)
+ @chart.gap_width = gap_width_value
+ doc = Nokogiri::XML(@chart.to_xml_string)
+ assert_equal(doc.xpath("//c:barChart/c:gapWidth").first.attribute('val').value, gap_width_value.to_s)
+ end
+
def test_to_xml_string_has_overlap
overlap_value = rand(-100..100)
@chart.overlap = overlap_value