diff options
| author | Arkadiy Butermanov <[email protected]> | 2016-11-03 18:27:00 +0300 |
|---|---|---|
| committer | Arkadiy Butermanov <[email protected]> | 2016-11-03 18:27:00 +0300 |
| commit | c06ac853c57cf1aca2dd258915dd12003d9f9859 (patch) | |
| tree | 5492f171d67c4a5aad10b988befeca6a498e4b56 /test/workbook/worksheet/tc_cell.rb | |
| parent | a0dc908f9df76f8c31a3238b1829eea2fd10c666 (diff) | |
| download | caxlsx-c06ac853c57cf1aca2dd258915dd12003d9f9859.tar.gz caxlsx-c06ac853c57cf1aca2dd258915dd12003d9f9859.zip | |
Add tests
Diffstat (limited to 'test/workbook/worksheet/tc_cell.rb')
| -rw-r--r-- | test/workbook/worksheet/tc_cell.rb | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb index 5ae2a51f..428e55a5 100644 --- a/test/workbook/worksheet/tc_cell.rb +++ b/test/workbook/worksheet/tc_cell.rb @@ -238,7 +238,7 @@ class TestCell < Test::Unit::TestCase @c.merge @row.cells.last assert_equal(@c.row.worksheet.send(:merged_cells).last, "A1:C1") end - + def test_reverse_merge_with_cell @c.row.add_cell 2 @c.row.add_cell 3 @@ -284,7 +284,7 @@ class TestCell < Test::Unit::TestCase c_xml = Nokogiri::XML(@c.to_xml_string(1,1)) assert_equal(c_xml.xpath("/c[@s=1]").size, 1) end - + def test_to_xml_string_with_run # Actually quite a number of similar run styles # but the processing should be the same @@ -319,6 +319,21 @@ class TestCell < Test::Unit::TestCase assert(doc.xpath("//f[@ref='A1']")) end + def test_to_xml_string_text_formula + p = Axlsx::Package.new + ws = p.workbook.add_worksheet do |sheet| + sheet.add_row ["=1+1", "-1+1"], type: :text + end + doc = Nokogiri::XML(ws.to_xml_string) + doc.remove_namespaces! + + assert(doc.xpath("//f[text()='1+1']").empty?) + assert(doc.xpath("//t[text()='=1+1']").any?) + + assert(doc.xpath("//f[text()='1+1']").empty?) + assert(doc.xpath("//t[text()='-1+1']").any?) + end + def test_font_size_with_custom_style_and_no_sz @c.style = @c.row.worksheet.workbook.styles.add_style :bg_color => 'FF00FF' sz = @c.send(:font_size) @@ -335,17 +350,17 @@ class TestCell < Test::Unit::TestCase sz = @c.send(:font_size) assert_equal(sz, 52) end - + def test_cell_with_sz @c.sz = 25 assert_equal(25, @c.send(:font_size)) end - + def test_to_xml # TODO This could use some much more stringent testing related to the xml content generated! @ws.add_row [Time.now, Date.today, true, 1, 1.0, "text", "=sum(A1:A2)", "2013-01-13T13:31:25.123"] @ws.rows.last.cells[5].u = true - + schema = Nokogiri::XML::Schema(File.open(Axlsx::SML_XSD)) doc = Nokogiri::XML(@ws.to_xml_string) errors = [] |
