summaryrefslogtreecommitdiff
path: root/test/win32ole
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-21 07:27:08 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-21 07:27:08 +0000
commit904abb1d9b05a7a3f01fbf72fd53b77c2afbd5af (patch)
tree741c2d06ac4af7bcc061819beb2949e82ae95575 /test/win32ole
parent4ec8dc6d61986fa8d778ebe43876d15674038c74 (diff)
* ext/win32ole/win32ole.c (vtdate2rbtime): VT_DATE variant object
is converted to Time object now. * test/win32ole/test_win32ole_variant.rb (test_s_new_with_nil, test_conversion_time2date, test_conversion_str2date, test_conversion_vt_date, test_set_value): ditto. * ext/win32ole/win32ole.c (rbtime2vtdate): refactoring. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/win32ole')
-rw-r--r--test/win32ole/test_win32ole_variant.rb49
1 files changed, 30 insertions, 19 deletions
diff --git a/test/win32ole/test_win32ole_variant.rb b/test/win32ole/test_win32ole_variant.rb
index d753fb4..aa65040 100644
--- a/test/win32ole/test_win32ole_variant.rb
+++ b/test/win32ole/test_win32ole_variant.rb
@@ -67,7 +67,7 @@ if defined?(WIN32OLE_VARIANT)
assert_equal(WIN32OLE::VARIANT::VT_CY, obj.vartype)
obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_DATE)
- assert_equal("1899/12/30 00:00:00", obj.value)
+ assert_equal(Time.new(1899,12,30), obj.value)
assert_equal(WIN32OLE::VARIANT::VT_DATE, obj.vartype)
obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_BSTR)
@@ -146,7 +146,7 @@ if defined?(WIN32OLE_VARIANT)
assert_equal(WIN32OLE::VARIANT::VT_CY, obj.vartype)
obj = WIN32OLE_VARIANT.new("2001-06-15 12:17:34", WIN32OLE::VARIANT::VT_DATE)
- assert_equal("2001/06/15 12:17:34", obj.value)
+ assert_equal(Time.new(2001,06,15,12,17,34), obj.value)
assert_equal(WIN32OLE::VARIANT::VT_DATE, obj.vartype)
obj = WIN32OLE_VARIANT.new("foo", WIN32OLE::VARIANT::VT_BSTR)
@@ -216,7 +216,7 @@ if defined?(WIN32OLE_VARIANT)
assert_equal(WIN32OLE::VARIANT::VT_CY|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
obj = WIN32OLE_VARIANT.new("2001-06-15 12:17:34", WIN32OLE::VARIANT::VT_DATE|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal("2001/06/15 12:17:34", obj.value)
+ assert_equal(Time.new(2001,06,15,12,17,34), obj.value)
assert_equal(WIN32OLE::VARIANT::VT_DATE|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
obj = WIN32OLE_VARIANT.new("foo", WIN32OLE::VARIANT::VT_BSTR|WIN32OLE::VARIANT::VT_BYREF)
@@ -373,15 +373,26 @@ if defined?(WIN32OLE_VARIANT)
def test_conversion_str2date
obj = WIN32OLE_VARIANT.new("2004-12-24 12:24:45", WIN32OLE::VARIANT::VT_DATE)
- assert_equal("2004/12/24 12:24:45", obj.value)
+ assert_equal(Time.new(2004,12,24,12,24,45), obj.value)
end
def test_conversion_time2date
dt = Time.mktime(2004, 12, 24, 12, 24, 45)
obj = WIN32OLE_VARIANT.new(dt, WIN32OLE::VARIANT::VT_DATE)
- assert_equal("2004/12/24 12:24:45", obj.value)
+ assert_equal(dt, obj.value)
end
+ # this test failed because of VariantTimeToSystemTime
+ # and SystemTimeToVariantTime API ignores wMilliseconds
+ # member of SYSTEMTIME struct.
+ #
+ # def test_conversion_time_nsec2date
+ # dt = Time.new(2004, 12,24, 12, 24, 45)
+ # dt += 0.1
+ # obj = WIN32OLE_VARIANT.new(dt, WIN32OLE::VARIANT::VT_DATE)
+ # assert_equal(dt, obj.value)
+ # end
+
def test_conversion_str2cy
begin
begin
@@ -554,40 +565,40 @@ if defined?(WIN32OLE_VARIANT)
def test_conversion_vt_date
obj = WIN32OLE_VARIANT.new(-657434, WIN32OLE::VARIANT::VT_DATE)
- assert_equal("0100/01/01 00:00:00", obj.value)
+ assert_equal(Time.new(100,1,1), obj.value)
obj = WIN32OLE_VARIANT.new("1500/12/29 23:59:59", WIN32OLE::VARIANT::VT_DATE)
- assert_equal("1500/12/29 23:59:59", obj.value)
+ assert_equal(Time.new(1500,12,29,23,59,59), obj.value)
obj = WIN32OLE_VARIANT.new("1500/12/30 00:00:00", WIN32OLE::VARIANT::VT_DATE)
- assert_equal("1500/12/30 00:00:00", obj.value)
+ assert_equal(Time.new(1500,12,30), obj.value)
obj = WIN32OLE_VARIANT.new("1500/12/30 00:00:01", WIN32OLE::VARIANT::VT_DATE)
- assert_equal("1500/12/30 00:00:01", obj.value)
+ assert_equal(Time.new(1500,12,30,0,0,1), obj.value)
obj = WIN32OLE_VARIANT.new("1899/12/29 23:59:59", WIN32OLE::VARIANT::VT_DATE)
- assert_equal("1899/12/29 23:59:59", obj.value)
+ assert_equal(Time.new(1899,12,29,23,59,59), obj.value)
obj = WIN32OLE_VARIANT.new("1899/12/30 00:00:00", WIN32OLE::VARIANT::VT_DATE)
- assert_equal("1899/12/30 00:00:00", obj.value)
+ assert_equal(Time.new(1899,12,30), obj.value)
obj = WIN32OLE_VARIANT.new("1899/12/30 00:00:01", WIN32OLE::VARIANT::VT_DATE)
- assert_equal("1899/12/30 00:00:01", obj.value)
+ assert_equal(Time.new(1899,12,30,0,0,1), obj.value)
obj = WIN32OLE_VARIANT.new(0, WIN32OLE::VARIANT::VT_DATE)
- assert_equal("1899/12/30 00:00:00", obj.value)
+ assert_equal(Time.new(1899,12,30), obj.value)
obj = WIN32OLE_VARIANT.new("2008/12/29 23:59:59", WIN32OLE::VARIANT::VT_DATE)
- assert_equal("2008/12/29 23:59:59", obj.value)
+ assert_equal(Time.new(2008,12,29,23,59,59), obj.value)
obj = WIN32OLE_VARIANT.new("2008/12/30 00:00:00", WIN32OLE::VARIANT::VT_DATE)
- assert_equal("2008/12/30 00:00:00", obj.value)
+ assert_equal(Time.new(2008,12,30,0,0,0), obj.value)
obj = WIN32OLE_VARIANT.new("2008/12/30 00:00:01", WIN32OLE::VARIANT::VT_DATE)
- assert_equal("2008/12/30 00:00:01", obj.value)
+ assert_equal(Time.new(2008,12,30,0,0,1), obj.value)
obj = WIN32OLE_VARIANT.new("9999/12/31 23:59:59", WIN32OLE::VARIANT::VT_DATE)
- assert_equal("9999/12/31 23:59:59", obj.value)
+ assert_equal(Time.new(9999,12,31,23,59,59), obj.value)
end
def test_create_nil_dispatch
@@ -626,11 +637,11 @@ if defined?(WIN32OLE_VARIANT)
assert_raise(WIN32OLERuntimeError) {
obj.value = "hogehoge"
}
- assert_equal("2007/01/01 00:00:00", obj.value)
+ assert_equal(Time.new(2007,1,1), obj.value)
obj2 = WIN32OLE_VARIANT.new("2006/01/01", WIN32OLE::VARIANT::VT_DATE)
obj.value = obj2
- assert_equal("2006/01/01 00:00:00", obj.value)
+ assert_equal(Time.new(2006,01,01), obj.value)
end
def test_c_nothing