From d2b1274f7bf6058e484158cfd78b4ba7212f91b2 Mon Sep 17 00:00:00 2001 From: Jurriaan Pruis Date: Mon, 2 Apr 2012 13:48:35 +0200 Subject: Updated tests for nil cells --- test/workbook/worksheet/tc_cell.rb | 4 +++- test/workbook/worksheet/tc_row.rb | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb index 4db0c7be..44cbf20a 100644 --- a/test/workbook/worksheet/tc_cell.rb +++ b/test/workbook/worksheet/tc_cell.rb @@ -94,7 +94,9 @@ class TestCell < Test::Unit::TestCase @c.type = :float assert_equal(@c.send(:cast_value, "1.0"), 1.0) @c.type = :string - assert_equal(@c.send(:cast_value, nil), "") + assert_equal(@c.send(:cast_value, nil), nil) + @c.type = :float + assert_equal(@c.send(:cast_value, nil), nil) @c.type = :boolean assert_equal(@c.send(:cast_value, true), 1) assert_equal(@c.send(:cast_value, false), 0) diff --git a/test/workbook/worksheet/tc_row.rb b/test/workbook/worksheet/tc_row.rb index d1507aa1..a953566e 100644 --- a/test/workbook/worksheet/tc_row.rb +++ b/test/workbook/worksheet/tc_row.rb @@ -27,6 +27,19 @@ class TestRow < Test::Unit::TestCase r.cells.each { |c| assert_equal(c.style,1) } end + def test_nil_cells + row = @ws.add_row([nil,1,2,nil,4,5,nil]) + r_s_xml = Nokogiri::XML(row.to_xml_string(0, '')) + assert_equal(r_s_xml.xpath(".//row/c").size, 4) + end + + def test_nil_cell_r + row = @ws.add_row([nil,1,2,nil,4,5,nil]) + r_s_xml = Nokogiri::XML(row.to_xml_string(0, '')) + assert_equal(r_s_xml.xpath(".//row/c").first['r'], 'B1') + assert_equal(r_s_xml.xpath(".//row/c").last['r'], 'F1') + end + def test_index assert_equal(@row.index, @row.worksheet.rows.index(@row)) end -- cgit v1.2.3