ole_param_ole_type should return "unknown type" string when ITypeInfo::GetFuncDesc failed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
suke 2006-04-30 23:37:54 +00:00
Родитель 5c1ae872f4
Коммит 9154b19bae
6 изменённых файлов: 152 добавлений и 138 удалений

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

@ -1,3 +1,8 @@
Mon May 1 08:32:10 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_param_ole_type): should return
"unknown type" string when ITypeInfo::GetFuncDesc failed.
Sat Apr 29 22:43:37 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_asn1.c (ossl_asn1_decode0): should initialize

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

@ -1,32 +0,0 @@
# You need RubyUnit and MS Excel and MSI to run this test script
require 'rubyunit'
require 'win32ole'
class TestWin32OLE_VARIANT < RUNIT::TestCase
include WIN32OLE::VARIANT
def test_variant
assert_equal(2, VT_I2)
assert_equal(3, VT_I4)
assert_equal(4, VT_R4)
assert_equal(5, VT_R8)
assert_equal(6, VT_CY)
assert_equal(7, VT_DATE)
assert_equal(8, VT_BSTR)
assert_equal(9, VT_DISPATCH)
assert_equal(10, VT_ERROR)
assert_equal(11, VT_BOOL)
assert_equal(12, VT_VARIANT)
assert_equal(13, VT_UNKNOWN)
assert_equal(16, VT_I1)
assert_equal(17, VT_UI1)
assert_equal(18, VT_UI2)
assert_equal(19, VT_UI4)
assert_equal(22, VT_INT)
assert_equal(23, VT_UINT)
assert_equal(0x2000, VT_ARRAY)
assert_equal(0x4000, VT_BYREF)
end
end

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

@ -2,7 +2,6 @@ require 'test/unit'
require 'win32ole'
puts "Now Test Win32OLE version #{WIN32OLE::VERSION}"
require "testWIN32OLE"
require "testVARIANT"
require "testOLEEVENT"
require "testNIL2VTEMPTY"
require "testINVOKEVERB"

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

@ -79,7 +79,7 @@
#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
#define WIN32OLE_VERSION "0.7.5"
#define WIN32OLE_VERSION "0.7.6"
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
@ -5910,7 +5910,7 @@ ole_param_ole_type(ITypeInfo *pTypeInfo, UINT method_index, UINT index)
{
FUNCDESC *pFuncDesc;
HRESULT hr;
VALUE type = rb_str_new2("UNKNOWN");
VALUE type = rb_str_new2("unknown type");
hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
if (FAILED(hr))
return type;

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

@ -1,104 +1,110 @@
require 'test/unit'
require 'win32ole'
class TestWIN32OLE_VARIANT < Test::Unit::TestCase
def test_new
obj = WIN32OLE_VARIANT.new('foo')
assert_instance_of(WIN32OLE_VARIANT, obj)
end
def test_new_no_argument
ex = nil
begin
obj = WIN32OLE_VARIANT.new
rescue ArgumentError
ex = $!
end
assert_instance_of(ArgumentError, ex)
assert_equal("wrong number of arguments (0 for 1..3)", ex.message);
end
def test_new_one_argument
ex = nil
begin
obj = WIN32OLE_VARIANT.new('foo')
rescue
ex = $!
end
assert_equal(nil, ex);
end
def test_value
obj = WIN32OLE_VARIANT.new('foo')
assert_equal('foo', obj.value)
end
def test_new_2_argument
ex = nil
obj = nil
begin
obj = WIN32OLE_VARIANT.new('foo', WIN32OLE::VARIANT::VT_BSTR|WIN32OLE::VARIANT::VT_BYREF)
rescue
ex = $!
end
assert_equal('foo', obj.value);
end
def test_new_2_argument2
ex = nil
obj = nil
begin
obj = WIN32OLE_VARIANT.new('foo', WIN32OLE::VARIANT::VT_BSTR)
rescue
ex = $!
end
assert_equal('foo', obj.value);
end
def test_conversion_num2str
obj = WIN32OLE_VARIANT.new(124, WIN32OLE::VARIANT::VT_BSTR)
assert_equal("124", obj.value);
end
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)
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)
end
def test_conversion_str2cy
obj = WIN32OLE_VARIANT.new("\\10,000", WIN32OLE::VARIANT::VT_CY)
assert_equal("10000", obj.value)
end
def test_create_vt_array
obj = WIN32OLE_VARIANT.new([1.2, 2.3], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_R8)
assert_equal([1.2, 2.3], obj.value)
end
def test_create_vt_array_str2ui1array
obj = WIN32OLE_VARIANT.new("ABC", WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1)
assert_equal("ABC", obj.value)
obj = WIN32OLE_VARIANT.new([65, 0].pack("C*"), WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1)
assert_equal([65, 0].pack("C*"), obj.value)
end
def test_create_vt_array_int
obj = WIN32OLE_VARIANT.new([65, 0], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1)
assert_equal([65, 0].pack("C*"), obj.value)
obj = WIN32OLE_VARIANT.new([65, 0])
assert_equal([65, 0], obj.value)
obj = WIN32OLE_VARIANT.new([65, 0], WIN32OLE::VARIANT::VT_I2|WIN32OLE::VARIANT::VT_ARRAY)
assert_equal([65, 0], obj.value)
end
begin
require 'win32ole'
rescue LoadError
end
require "test/unit"
if defined?(WIN32OLE_VARIANT)
class TestWIN32OLE_VARIANT < Test::Unit::TestCase
def test_new
obj = WIN32OLE_VARIANT.new('foo')
assert_instance_of(WIN32OLE_VARIANT, obj)
end
def test_new_no_argument
ex = nil
begin
obj = WIN32OLE_VARIANT.new
rescue ArgumentError
ex = $!
end
assert_instance_of(ArgumentError, ex)
assert_equal("wrong number of arguments (0 for 1..3)", ex.message);
end
def test_new_one_argument
ex = nil
begin
obj = WIN32OLE_VARIANT.new('foo')
rescue
ex = $!
end
assert_equal(nil, ex);
end
def test_value
obj = WIN32OLE_VARIANT.new('foo')
assert_equal('foo', obj.value)
end
def test_new_2_argument
ex = nil
obj = nil
begin
obj = WIN32OLE_VARIANT.new('foo', WIN32OLE::VARIANT::VT_BSTR|WIN32OLE::VARIANT::VT_BYREF)
rescue
ex = $!
end
assert_equal('foo', obj.value);
end
def test_new_2_argument2
ex = nil
obj = nil
begin
obj = WIN32OLE_VARIANT.new('foo', WIN32OLE::VARIANT::VT_BSTR)
rescue
ex = $!
end
assert_equal('foo', obj.value);
end
def test_conversion_num2str
obj = WIN32OLE_VARIANT.new(124, WIN32OLE::VARIANT::VT_BSTR)
assert_equal("124", obj.value);
end
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)
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)
end
def test_conversion_str2cy
obj = WIN32OLE_VARIANT.new("\\10,000", WIN32OLE::VARIANT::VT_CY)
assert_equal("10000", obj.value)
end
def test_create_vt_array
obj = WIN32OLE_VARIANT.new([1.2, 2.3], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_R8)
assert_equal([1.2, 2.3], obj.value)
end
def test_create_vt_array_str2ui1array
obj = WIN32OLE_VARIANT.new("ABC", WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1)
assert_equal("ABC", obj.value)
obj = WIN32OLE_VARIANT.new([65, 0].pack("C*"), WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1)
assert_equal([65, 0].pack("C*"), obj.value)
end
def test_create_vt_array_int
obj = WIN32OLE_VARIANT.new([65, 0], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1)
assert_equal([65, 0].pack("C*"), obj.value)
obj = WIN32OLE_VARIANT.new([65, 0])
assert_equal([65, 0], obj.value)
obj = WIN32OLE_VARIANT.new([65, 0], WIN32OLE::VARIANT::VT_I2|WIN32OLE::VARIANT::VT_ARRAY)
assert_equal([65, 0], obj.value)
end
end
end

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

@ -0,0 +1,36 @@
# You need RubyUnit and MS Excel and MSI to run this test script
begin
require 'win32ole'
rescue LoadError
end
require "test/unit"
if defined?(WIN32OLE::VARIANT)
class TestWin32OLE_VARIANT < Test::Unit::TestCase
include WIN32OLE::VARIANT
def test_variant
assert_equal(2, VT_I2)
assert_equal(3, VT_I4)
assert_equal(4, VT_R4)
assert_equal(5, VT_R8)
assert_equal(6, VT_CY)
assert_equal(7, VT_DATE)
assert_equal(8, VT_BSTR)
assert_equal(9, VT_DISPATCH)
assert_equal(10, VT_ERROR)
assert_equal(11, VT_BOOL)
assert_equal(12, VT_VARIANT)
assert_equal(13, VT_UNKNOWN)
assert_equal(16, VT_I1)
assert_equal(17, VT_UI1)
assert_equal(18, VT_UI2)
assert_equal(19, VT_UI4)
assert_equal(22, VT_INT)
assert_equal(23, VT_UINT)
assert_equal(0x2000, VT_ARRAY)
assert_equal(0x4000, VT_BYREF)
end
end
end