* ext/win32ole/win32ole.c (d2time): fix the bug of VT_DATE

to String conversion when negative value.
	  
* test/win32ole/test_win32ole_variant.rb: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
suke 2008-07-04 14:19:01 +00:00
Родитель 7d166d26a5
Коммит 7a05bfaaab
3 изменённых файлов: 48 добавлений и 2 удалений

Просмотреть файл

@ -1,3 +1,10 @@
Fri Jul 4 23:12:53 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (d2time): fix the bug of VT_DATE
to String conversion when negative value.
* test/win32ole/test_win32ole_variant.rb: ditto.
Fri Jul 4 22:15:29 2008 Tanaka Akira <akr@fsij.org>
* lib/test/unit/testcase.rb: collect decendants of

Просмотреть файл

@ -24,6 +24,7 @@
#include <olectl.h>
#include <ole2.h>
#include <stdlib.h>
#include <math.h>
#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h>
#define va_init_list(a,b) va_start(a,b)
@ -117,7 +118,7 @@
#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
#define WIN32OLE_VERSION "1.1.8"
#define WIN32OLE_VERSION "1.1.9"
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
@ -763,7 +764,7 @@ d2time(double v, int *hh, int *mm, int *ss)
double d_hh, d_mm, d_ss;
int i_hh, i_mm, i_ss;
double d = v * 86400.0;
double d = fabs(v * 86400.0);
d_hh = d / 3600.0;
i_hh = (int)d_hh;

Просмотреть файл

@ -540,6 +540,44 @@ if defined?(WIN32OLE_VARIANT)
}
end
def test_conversion_vt_date
obj = WIN32OLE_VARIANT.new(-657434, WIN32OLE::VARIANT::VT_DATE)
assert_equal("0100/01/01 00:00:00", 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)
obj = WIN32OLE_VARIANT.new("1500/12/30 00:00:00", WIN32OLE::VARIANT::VT_DATE)
assert_equal("1500/12/30 00:00:00", 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)
obj = WIN32OLE_VARIANT.new("1899/12/29 23:59:59", WIN32OLE::VARIANT::VT_DATE)
assert_equal("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)
obj = WIN32OLE_VARIANT.new("1899/12/30 00:00:01", WIN32OLE::VARIANT::VT_DATE)
assert_equal("1899/12/30 00:00:01", obj.value)
obj = WIN32OLE_VARIANT.new(0, WIN32OLE::VARIANT::VT_DATE)
assert_equal("1899/12/30 00:00:00", 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)
obj = WIN32OLE_VARIANT.new("2008/12/30 00:00:00", WIN32OLE::VARIANT::VT_DATE)
assert_equal("2008/12/30 00:00:00", 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)
obj = WIN32OLE_VARIANT.new("9999/12/31 23:59:59", WIN32OLE::VARIANT::VT_DATE)
assert_equal("9999/12/31 23:59:59", obj.value)
end
def test_create_nil_dispatch
var = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_DISPATCH)
assert_nil(var.value)