test/test_roo.rb in roo-0.2.4 vs test/test_roo.rb in roo-0.2.5
- old
+ new
@@ -1,14 +1,14 @@
require File.dirname(__FILE__) + '/test_helper.rb'
class TestRoo < Test::Unit::TestCase
- OPENOFFICE = true # toggle Openoffice-Spreadsheet Test on/off
- EXCEL = true # do Excel Tests?
- GOOGLE = false # toggle Google-Spreadsheet Test on/off
+ OPENOFFICE = true # do Openoffice-Spreadsheet Tests?
+ EXCEL = true # do Excel Tests?
+ GOOGLE = false # do Google-Spreadsheet Tests?
- OPENOFFICEWRITE = false # Tests fuer schreibenden Zugriff auf OO-Dokumente
+ OPENOFFICEWRITE = false # experimental: write access with OO-Dokuments
def setup
if GOOGLE
@goo = Google.new(ENV['GOOGLE_MAIL'],
ENV['GOOGLE_PASSWORD'],
@@ -242,22 +242,36 @@
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)
+ assert_equal "einundvierzig", oo.cell('a',16)
+ assert_equal "zweiundvierzig", oo.cell('b',16)
+ assert_equal "dreiundvierzig", oo.cell('c',16)
+ assert_equal "vierundvierzig", oo.cell('d',16)
+ assert_equal "fuenfundvierzig", oo.cell('e',16)
+ assert_equal ["einundvierzig", "zweiundvierzig", "dreiundvierzig", "vierundvierzig", "fuenfundvierzig"], oo.row(16)
if EXCEL
- if DateTime.now > Date.new(2007,6,17)
- #-- Excel
- oo = Excel.new(File.join("test","numbers1.xls"))
- oo.default_sheet = 1 # 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
+ #-- Excel
+ oo = Excel.new(File.join("test","numbers1.xls"))
+ oo.default_sheet = 1 # 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,42,43,44,45], oo.row(12)
+ assert_equal "einundvierzig", oo.cell('a',16)
+ assert_equal "zweiundvierzig", oo.cell('b',16)
+ assert_equal "dreiundvierzig", oo.cell('c',16)
+ assert_equal "vierundvierzig", oo.cell('d',16)
+ assert_equal "fuenfundvierzig", oo.cell('e',16)
+ assert_equal ["einundvierzig",
+ "zweiundvierzig",
+ "dreiundvierzig",
+ "vierundvierzig",
+ "fuenfundvierzig"], oo.row(16)
end
if DateTime.now > Date.new(2007,6,17)
#-- GOOGLE
if GOOGLE
oo = Google.new(File.join("test","numbers1.xls"))
@@ -266,10 +280,21 @@
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)
+ assert_equal "einundvierzig", oo.cell('a',16)
+ assert_equal "zweiundvierzig", oo.cell('b',16)
+ assert_equal "dreiundvierzig", oo.cell('c',16)
+ assert_equal "vierundvierzig", oo.cell('d',16)
+ assert_equal "fuenfundvierzig", oo.cell('e',16)
+ assert_equal "xxxfuenfundvierzig", oo.cell('e',16)
+ assert_equal ["einundvierzig",
+ "zweiundvierzig",
+ "dreiundvierzig",
+ "vierundvierzig",
+ "fuenfundvierzig"], oo.row(16)
end
end
end
def test_last_row
@@ -522,17 +547,53 @@
end
end
def test_bug_contiguous_cells
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
- oo.default_sheet = "Sheet4"
- assert_equal Date.new(2007,06,16), oo.cell('a',1)
- assert_equal 10, oo.cell('b',1)
- assert_equal 10, oo.cell('c',1)
- assert_equal 10, oo.cell('d',1)
- assert_equal 10, oo.cell('e',1)
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo.default_sheet = "Sheet4"
+ assert_equal Date.new(2007,06,16), oo.cell('a',1)
+ assert_equal 10, oo.cell('b',1)
+ assert_equal 10, oo.cell('c',1)
+ assert_equal 10, oo.cell('d',1)
+ assert_equal 10, oo.cell('e',1)
+ end
+ if EXCEL
+ oo = Excel.new(File.join("test","numbers1.xls"))
+ oo.default_sheet = 4
+ assert_equal Date.new(2007,06,16), oo.cell('a',1)
+ assert_equal 10, oo.cell('b',1)
+ assert_equal 10, oo.cell('c',1)
+ assert_equal 10, oo.cell('d',1)
+ assert_equal 10, oo.cell('e',1)
+ end
+ if GOOGLE
+ @goo.default_sheet = "Sheet4"
+ assert_equal Date.new(2007,06,16), @goo.cell('a',1)
+ assert_equal 10, @goo.cell('b',1)
+ assert_equal 10, @goo.cell('c',1)
+ assert_equal 10, @goo.cell('d',1)
+ assert_equal 10, @goo.cell('e',1)
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
+ oo.first_row.upto(oo.last_row) do |row|
+ oo.first_column.upto(oo.last_column) do |col|
+ unless oo.empty?(row,col)
+ count += 1
+ a = oo.cell(row,col)
+# puts a
+# b = gets
+ end
+ end
+ end
+ puts count.to_s+" cells with content"
end
- end # class
+ end
+
+end # class