test/test_roo.rb in roo-0.2.5 vs test/test_roo.rb in roo-0.2.6

- old
+ new

@@ -27,11 +27,11 @@ assert_equal 27, Openoffice.letter_to_number('aa') end def test_sheets oo = Openoffice.new(File.join("test","numbers1.ods")) - assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4"], oo.sheets + assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets #-- if EXCEL if DateTime.now > Date.new(2007,6,30) oo = Excel.new(File.join("test","numbers1.xls")) assert_equal ["Tabelle1","Name of Sheet 2","Sheet3"], oo.sheets @@ -574,10 +574,31 @@ assert_equal 10, @goo.cell('d',1) assert_equal 10, @goo.cell('e',1) end end + def test_bug_italo_ve + if OPENOFFICE + oo = Openoffice.new(File.join("test","numbers1.ods")) + oo.default_sheet = "Sheet5" + assert_equal 1, oo.cell('A',1) + assert_equal 5, oo.cell('b',1) + assert_equal 5, oo.cell('c',1) + assert_equal 2, oo.cell('a',2) + assert_equal 3, oo.cell('a',3) + end + if EXCEL + oo = Excel.new(File.join("test","numbers1.xls")) + oo.default_sheet = 5 + assert_equal 1, oo.cell('A',1) + assert_equal 5, oo.cell('b',1) + assert_equal 5, oo.cell('c',1) + assert_equal 2, oo.cell('a',2) + assert_equal 3, oo.cell('a',3) + end + end + def DONT_test_large_file if OPENOFFICE count = 0 oo = Openoffice.new(File.join("test","Bibelbund.ods")) oo.default_sheet = oo.sheets.first @@ -593,7 +614,68 @@ end puts count.to_s+" cells with content" end end + + def test_italo_table + oo = Openoffice.new(File.join("test","simple_spreadsheet_from_italo.ods")) + p oo.sheets + oo.default_sheet = oo.sheets.first + + assert_equal '1', oo.cell('A',1) + assert_equal '1', oo.cell('B',1) + assert_equal '1', oo.cell('C',1) + + # assert_equal 1, oo.cell('A',2) + # assert_equal 2, oo.cell('B',2) + # assert_equal 1, oo.cell('C',2) + # are stored as strings, not numbers + + assert_equal 1, oo.cell('A',2).to_i + assert_equal 2, oo.cell('B',2).to_i + assert_equal 1, oo.cell('C',2).to_i + + assert_equal 1, oo.cell('A',3) + assert_equal 3, oo.cell('B',3) + assert_equal 1, oo.cell('C',3) + + assert_equal 'A', oo.cell('A',4) + assert_equal 'A', oo.cell('B',4) + assert_equal 'A', oo.cell('C',4) + + assert_equal '0.01', oo.cell('A',5) + assert_equal '0.01', oo.cell('B',5) + assert_equal '0.01', oo.cell('C',5) + + + # 1.0 + +# Cells values in row 1: + assert_equal "1:string", oo.cell(1, 1)+":"+oo.celltype(1, 1) + assert_equal "1:string",oo.cell(1, 2)+":"+oo.celltype(1, 2) + assert_equal "1:string",oo.cell(1, 3)+":"+oo.celltype(1, 3) + +# Cells values in row 2: + assert_equal "1:string",oo.cell(2, 1)+":"+oo.celltype(2, 1) + assert_equal "2:string",oo.cell(2, 2)+":"+oo.celltype(2, 2) + assert_equal "1:string",oo.cell(2, 3)+":"+oo.celltype(2, 3) + +# Cells values in row 3: + assert_equal "1.0:float",oo.cell(3, 1).to_s+":"+oo.celltype(3, 1) + assert_equal "3.0:float",oo.cell(3, 2).to_s+":"+oo.celltype(3, 2) + assert_equal "1.0:float",oo.cell(3, 3).to_s+":"+oo.celltype(3, 3) + +# Cells values in row 4: + assert_equal "A:string",oo.cell(4, 1)+":"+oo.celltype(4, 1) + assert_equal "A:string",oo.cell(4, 2)+":"+oo.celltype(4, 2) + assert_equal "A:string",oo.cell(4, 3)+":"+oo.celltype(4, 3) + +# Cells values in row 5: + assert_equal "0.01:percentage",oo.cell(5, 1)+":"+oo.celltype(5, 1) + assert_equal "0.01:percentage",oo.cell(5, 2)+":"+oo.celltype(5, 2) + assert_equal "0.01:percentage",oo.cell(5, 3)+":"+oo.celltype(5, 3) + + + end end # class