summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-02-28 14:17:17 +0900
committerRandy Morgan <[email protected]>2012-02-28 14:17:17 +0900
commitf43f801b9e01249dfde0bc8453ecf5376898d3c2 (patch)
tree187a96fd310fbb6c07a3d60af7b22a3abeacf312 /test
parent57f4162adb1984cc19e41833c32b9dcbf211a4c9 (diff)
downloadcaxlsx-f43f801b9e01249dfde0bc8453ecf5376898d3c2.tar.gz
caxlsx-f43f801b9e01249dfde0bc8453ecf5376898d3c2.zip
patching time converter and specs as well as fixing warnings related to uninitialized row#height and worksheet#page_margins
Diffstat (limited to 'test')
-rw-r--r--test/workbook/worksheet/tc_date_time_converter.rb25
1 files changed, 12 insertions, 13 deletions
diff --git a/test/workbook/worksheet/tc_date_time_converter.rb b/test/workbook/worksheet/tc_date_time_converter.rb
index 78053a6d..529da917 100644
--- a/test/workbook/worksheet/tc_date_time_converter.rb
+++ b/test/workbook/worksheet/tc_date_time_converter.rb
@@ -4,7 +4,6 @@ require 'axlsx.rb'
class TestDateTimeConverter < Test::Unit::TestCase
def setup
- @converter = Axlsx::DateTimeConverter.new
@margin_of_error = 0.000_001
@extended_time_range = begin
Time.parse "1893-08-05"
@@ -25,7 +24,7 @@ class TestDateTimeConverter < Test::Unit::TestCase
"2006-02-01" => 38749.0,
"9999-12-31" => 2958465.0
}
- else
+ else
{ # examples taken inside the possible values
"1970-01-01" => 25569.0, # Unix epoch
"1970-01-02" => 25570.0,
@@ -34,7 +33,7 @@ class TestDateTimeConverter < Test::Unit::TestCase
}
end
tests.each do |date_string, expected|
- serial = @converter.date_to_serial Date.parse(date_string)
+ serial = Axlsx::DateTimeConverter::date_to_serial Date.parse(date_string)
assert_equal expected, serial
end
end
@@ -58,7 +57,7 @@ class TestDateTimeConverter < Test::Unit::TestCase
}
end
tests.each do |date_string, expected|
- serial = @converter.date_to_serial Date.parse(date_string)
+ serial = Axlsx::DateTimeConverter::date_to_serial Date.parse(date_string)
assert_equal expected, serial
end
end
@@ -67,8 +66,8 @@ class TestDateTimeConverter < Test::Unit::TestCase
Axlsx::Workbook.date1904 = false
tests = if @extended_time_range
{ # examples taken straight from the spec
- "1893-08-05T00:00:01Z" => -2337.999989,
- "1899-12-28T18:00:00Z" => -1.25,
+ "1893-08-05T00:00:01Z" => -2337.999989,
+ "1899-12-28T18:00:00Z" => -1.25,
"1910-02-03T10:05:54Z" => 3687.4207639,
"1900-01-01T12:00:00Z" => 2.5, # wrongly indicated as 1.5 in the spec!
"9999-12-31T23:59:59Z" => 2958465.9999884
@@ -82,7 +81,7 @@ class TestDateTimeConverter < Test::Unit::TestCase
}
end
tests.each do |time_string, expected|
- serial = @converter.time_to_serial Time.parse(time_string)
+ serial = Axlsx::DateTimeConverter::time_to_serial Time.parse(time_string)
assert_in_delta expected, serial, @margin_of_error
end
end
@@ -90,10 +89,10 @@ class TestDateTimeConverter < Test::Unit::TestCase
def test_time_to_serial_1904
Axlsx::Workbook.date1904 = true
# ruby 1.8.7 cannot parse dates prior to epoc. see http://ruby-doc.org/core-1.8.7/Time.html
-
+
tests = if @extended_time_range
{ # examples taken straight from the spec
- "1893-08-05T00:00:01Z" => -3799.999989,
+ "1893-08-05T00:00:01Z" => -3799.999989,
"1910-02-03T10:05:54Z" => 2225.4207639,
"1904-01-01T12:00:00Z" => 0.5000000,
"9999-12-31T23:59:59Z" => 2957003.9999884
@@ -106,8 +105,8 @@ class TestDateTimeConverter < Test::Unit::TestCase
"2038-01-19T03:14:07Z" => 48962.134803, # max signed timestamp in 32bit
}
end
- tests.each do |time_string, expected|
- serial = @converter.time_to_serial Time.parse(time_string)
+ tests.each do |time_string, expected|
+ serial = Axlsx::DateTimeConverter::time_to_serial Time.parse(time_string)
assert_in_delta expected, serial, @margin_of_error
end
end
@@ -120,9 +119,9 @@ class TestDateTimeConverter < Test::Unit::TestCase
Time.parse "2012-01-01 01:00:00 +0100"
end
assert_equal local, utc
- assert_equal @converter.time_to_serial(local), @converter.time_to_serial(utc)
+ assert_equal Axlsx::DateTimeConverter::time_to_serial(local), Axlsx::DateTimeConverter::time_to_serial(utc)
Axlsx::Workbook.date1904 = true
- assert_equal @converter.time_to_serial(local), @converter.time_to_serial(utc)
+ assert_equal Axlsx::DateTimeConverter::time_to_serial(local), Axlsx::DateTimeConverter::time_to_serial(utc)
end
end