require File.dirname(__FILE__) + '/test_helper.rb' class TestRoo < Test::Unit::TestCase def test_sheets oo = Openoffice.new("test/numbers1.ods") assert_equal ["Tabelle1","Sheet2","Sheet3"], oo.sheets end def test_cell oo = Openoffice.new("test/numbers1.ods") oo.default_sheet = oo.sheets.first assert_equal 1, oo.cell(1,1) assert_equal 2, oo.cell(1,2) assert_equal 3, oo.cell(1,3) assert_equal 4, oo.cell(1,4) assert_equal 5, oo.cell(2,1) assert_equal 6, oo.cell(2,2) assert_equal 7, oo.cell(2,3) assert_equal 8, oo.cell(2,4) assert_equal 9, oo.cell(2,5) assert_equal "test", oo.cell(2,6) assert_equal "string", oo.celltype(2,6) assert_equal 11, oo.cell(2,7) assert_equal 10, oo.cell(4,1) assert_equal 11, oo.cell(4,2) assert_equal 12, oo.cell(4,3) assert_equal 13, oo.cell(4,4) assert_equal 14, oo.cell(4,5) assert_equal 10, oo.cell(4,'A') assert_equal 11, oo.cell(4,'B') assert_equal 12, oo.cell(4,'C') assert_equal 13, oo.cell(4,'D') assert_equal 14, oo.cell(4,'E') assert_equal "date", oo.celltype(5,1) assert_equal "1961-11-21", oo.cell(5,1) end def test_cell_address oo = Openoffice.new("test/numbers1.ods") oo.default_sheet = oo.sheets.first assert_equal "tata", oo.cell(6,1) assert_equal "tata", oo.cell(6,'A') assert_equal "tata", oo.cell('A',6) assert_equal "tata", oo.cell(6,'a') assert_equal "tata", oo.cell('a',6) assert_equal "thisisc8", oo.cell(8,3) assert_equal "thisisc8", oo.cell(8,'C') assert_equal "thisisc8", oo.cell('C',8) assert_equal "thisisc8", oo.cell(8,'c') assert_equal "thisisc8", oo.cell('c',8) assert_equal "thisisd9", oo.cell('d',9) assert_equal "thisisa11", oo.cell('a',11) end # Version of the (XML) office document # please note that "1.0" is returned even if it was created with OpenOffice V. 2.0 def test_officeversion oo = Openoffice.new("test/numbers1.ods") assert_equal "1.0", oo.officeversion end def test_rows oo = Openoffice.new("test/numbers1.ods") oo.default_sheet = oo.sheets.first assert_equal 41, oo.cell('a',12) assert_equal 42, oo.cell('b',12) assert_equal 43, oo.cell('c',12) assert_equal 44, oo.cell('d',12) assert_equal 45, oo.cell('e',12) assert_equal [41.0,42.0,43.0,44.0,45.0], oo.row(12) end def test_last_row oo = Openoffice.new("test/numbers1.ods") oo.default_sheet = oo.sheets.first assert_equal 18, oo.last_row end def test_last_column oo = Openoffice.new("test/numbers1.ods") oo.default_sheet = oo.sheets.first assert_equal 7, oo.last_column end def test_last_column_as_letter oo = Openoffice.new("test/numbers1.ods") oo.default_sheet = oo.sheets.first assert_equal 'G', oo.last_column_as_letter end def test_first_row oo = Openoffice.new("test/numbers1.ods") oo.default_sheet = oo.sheets.first assert_equal 1, oo.first_row end def test_first_column oo = Openoffice.new("test/numbers1.ods") oo.default_sheet = oo.sheets.first assert_equal 1, oo.first_column end def test_first_column_as_letter oo = Openoffice.new("test/numbers1.ods") oo.default_sheet = oo.sheets.first assert_equal 'A', oo.first_column_as_letter end end