test/test_roo.rb in roo-1.9.2 vs test/test_roo.rb in roo-1.9.3
- old
+ new
@@ -70,12 +70,13 @@
"only_one_sheet" => "o10837434939102457526.762705759906130135",
#'time-test' => 'r2XfDBJMrLPjmuLrPQQrEYw',
'time-test' => 'ptu6bbahNZpYBMhk01UfXSg',
#'datetime' => "r2kQpXWr6xOSUpw9MyXavYg",
'datetime' => "ptu6bbahNZpYQEtZwzL_dZQ",
- 'whitespace' => "rZyQaoFebVGeHKzjG6e9gRQ"
- }[spreadsheetname]
+ 'whitespace' => "rZyQaoFebVGeHKzjG6e9gRQ",
+ 'matrix' => '0AkCuGANLc3jFdHY3cWtYUkM4bVdadjZ5VGpfTzFEUEE',
+ }[spreadsheetname]
# 'numbers1' => "o10837434939102457526.4784396906364855777",
# 'borders' => "o10837434939102457526.664868920231926255",
# 'simple_spreadsheet' => "ptu6bbahNZpYe-L1vEBmgGA",
# 'testnichtvorhandenBibelbund.ods' => "invalidkeyforanyspreadsheet", # !!! intentionally false key
# "only_one_sheet" => "o10837434939102457526.762705759906130135",
@@ -136,14 +137,14 @@
class TestRoo < Test::Unit::TestCase
OPENOFFICE = true # do Openoffice-Spreadsheet Tests?
EXCEL = true # do Excel Tests?
- GOOGLE = false # do Google-Spreadsheet Tests?
+ GOOGLE = true # do Google-Spreadsheet Tests?
EXCELX = true # do Excel-X Tests? (.xlsx-files)
- ONLINE = false
+ ONLINE = true
LONG_RUN = true
GLOBAL_TIMEOUT = 48.minutes #*60 # 2*12*60 # seconds
def setup
#if DISPLAY_LOG
@@ -1262,18 +1263,20 @@
# }
end
end
def test_write_google
+ after Date.new(2010,3,10) do
# write.me: http://spreadsheets.google.com/ccc?key=ptu6bbahNZpY0N0RrxQbWdw&hl=en_GB
with_each_spreadsheet(:name=>'write.me', :format=>:google) do |oo|
oo.default_sheet = oo.sheets.first
oo.set_value(1,1,"hello from the tests")
assert_equal "hello from the tests", oo.cell(1,1)
oo.set_value(1,1, 1.0)
assert_equal 1.0, oo.cell(1,1)
end
+ end
end
def test_bug_set_value_with_more_than_one_sheet_google
# write.me: http://spreadsheets.google.com/ccc?key=ptu6bbahNZpY0N0RrxQbWdw&hl=en_GB
with_each_spreadsheet(:name=>'write.me', :format=>:google) do |oo|
@@ -1409,11 +1412,11 @@
assert_equal [], a
end
end
def test_no_remaining_tmp_files_google
- after Date.new(2009,11,1) do
+ after Date.new(2010,4,1) do
# Exception ist irgendwie anders, nochmal ansehen TODO:
if GOOGLE
assert_nothing_raised() {
oo = Google.new(key_of("no_spreadsheet_file.txt"))
}
@@ -1803,11 +1806,11 @@
end
# Need to extend to other formats
def test_row_whitespace
# auf dieses Dokument habe ich keinen Zugriff TODO:
- after Date.new(2009,11,1) do
+ after Date.new(2010,4,1) do
with_each_spreadsheet(:name=>'whitespace') do |oo|
oo.default_sheet = "Sheet1"
assert_equal [nil, nil, nil, nil, nil, nil], oo.row(1)
assert_equal [nil, nil, nil, nil, nil, nil], oo.row(2)
assert_equal ["Date", "Start time", "End time", "Pause", "Sum", "Comment"], oo.row(3)
@@ -1821,11 +1824,11 @@
end
end
end
def test_col_whitespace
- after Date.new(2009,11,20) do
+ after Date.new(2010,2,20) do
#TODO:
# kein Zugriff auf Dokument whitespace
with_each_spreadsheet(:name=>'whitespace') do |oo|
oo.default_sheet = "Sheet1"
assert_equal ["Date", Date.new(2007,5,7), nil, Date.new(2007,5,7)], oo.column(1)
@@ -1871,11 +1874,11 @@
}
end # each
end
def test_cell_methods
- after Date.new(2010,1,30) do
+ after Date.new(2010,3,30) do
with_each_spreadsheet(:name=>'numbers1') do |oo|
assert_equal 10, oo.a4 # cell(4,'A')
assert_equal 11, oo.b4 # cell(4,'B')
assert_equal 12, oo.c4 # cell(4,'C')
assert_equal 13, oo.d4 # cell(4,'D')
@@ -1916,11 +1919,11 @@
end # LONG_RUN
end
end
def test_labeled_cells
- after Date.new(2010,1,25) do
+ after Date.new(2010,3,25) do
# TODO: more spreadsheet types
with_each_spreadsheet(:name=>'named_cells', :format=>:openoffice) do |oo|
oo.default_sheet = oo.sheets.first
begin
row,col = oo.label('anton')
@@ -1959,28 +1962,61 @@
end
def test_bug_excel_last_row_255
after Date.new(2010,2,20) do
- oo = Excel.new(File.join('test','ScienceStaff.xls'))
- oo.default_sheet = oo.sheets.first
- assert_equal "COMSCI", oo.cell(255,1)
- assert_equal "lala", oo.cell(256,1)
- assert_equal 1537, oo.last_row
- end
+ oo = Excel.new(File.join('test','ScienceStaff.xls'))
+ oo.default_sheet = oo.sheets.first
+ assert_equal "COMSCI", oo.cell(255,1)
+ assert_equal "lala", oo.cell(256,1)
+ assert_equal 1537, oo.last_row
+ end
end
def test_bug_excel_last_row_255_modified
oo = Excel.new(File.join('test','ScienceStaff_modified.xls'))
oo.default_sheet = oo.sheets.first
assert_equal 1537, oo.last_row
end
-require 'matrix'
- def test_matrix
- with_each_spreadsheet(:name => 'matrix', :format => [:openoffice, :excel, :google]) do |oo|
- oo.default_sheet = oo.sheets.first
- assert_equal Matrix[ [1.0, 2.0, 3.0],
- [4.0, 5.0, 6.0],
- [7.0, 8.0, 9.0] ], oo.to_matrix
+
+ require 'matrix'
+ def test_matrix
+ with_each_spreadsheet(:name => 'matrix', :format => [:openoffice, :excel, :google]) do |oo|
+ oo.default_sheet = oo.sheets.first
+ assert_equal Matrix[
+ [1.0, 2.0, 3.0],
+ [4.0, 5.0, 6.0],
+ [7.0, 8.0, 9.0] ], oo.to_matrix
+ end
+ end
+
+ def test_matrix_selected_range
+ with_each_spreadsheet(:name => 'matrix', :format=>[:excel,:openoffice,:google]) do |oo|
+ oo.default_sheet = 'Sheet2'
+ assert_equal Matrix[
+ [1.0, 2.0, 3.0],
+ [4.0, 5.0, 6.0],
+ [7.0, 8.0, 9.0] ], oo.to_matrix(3,4,5,6)
+ end
+ end
+
+ def test_matrix_all_nil
+ with_each_spreadsheet(:name => 'matrix', :format=>[:excel,:openoffice,:google]) do |oo|
+ oo.default_sheet = 'Sheet2'
+ assert_equal Matrix[
+ [nil, nil, nil],
+ [nil, nil, nil],
+ [nil, nil, nil] ], oo.to_matrix(10,10,12,12)
+ end
+ end
+
+ def test_matrix_values_and_nil
+ with_each_spreadsheet(:name => 'matrix', :format=>[:excel,:openoffice,:google]) do |oo|
+ oo.default_sheet = 'Sheet3'
+ assert_equal Matrix[
+ [1.0, nil, 3.0],
+ [4.0, 5.0, 6.0],
+ [7.0, 8.0, nil] ], oo.to_matrix(1,1,3,3)
end
end
-end # class
+
+ end # class