* ext/win32ole/win32ole.c: add WIN32OLE.locale=, WIN32OLE.locale,

WIN32OLE_VARIANT#vartype.

* test/win32ole/test_win32ole.rb: add test for WIN32OLE.locale=,
  WIN32OLE.locale.

* test/win32ole/test_win32ole_variant.rb: add test for 
  WIN32OLE_VARIANT#vartype.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
suke 2007-01-29 12:41:50 +00:00
parent 024c694c95
commit 883f34f777
4 changed files with 178 additions and 21 deletions

View file

@ -296,6 +296,38 @@ if defined?(WIN32OLE)
end
end
def test_s_locale
assert_equal(WIN32OLE::LOCALE_SYSTEM_DEFAULT, WIN32OLE.locale)
end
def test_s_locale_set
begin
WIN32OLE.locale = 1041
assert_equal(1041, WIN32OLE.locale)
WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT
assert_raise(WIN32OLERuntimeError) {
WIN32OLE.locale = 111
}
assert_equal(WIN32OLE::LOCALE_SYSTEM_DEFAULT, WIN32OLE.locale)
ensure
WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT
end
end
def test_s_locale_change
begin
WIN32OLE.locale = 0x0411
obj = WIN32OLE_VARIANT.new("\\100,000", WIN32OLE::VARIANT::VT_CY)
assert_equal("100000", obj.value)
WIN32OLE.locale = 1033
obj = WIN32OLE_VARIANT.new("$100,000", WIN32OLE::VARIANT::VT_CY)
assert_equal("100000", obj.value)
ensure
WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT
end
end
def test_const_CP_ACP
assert_equal(0, WIN32OLE::CP_ACP)
end
@ -323,6 +355,14 @@ if defined?(WIN32OLE)
def test_const_CP_UTF8
assert_equal(65001, WIN32OLE::CP_UTF8)
end
def test_const_LOCALE_SYSTEM_DEFAULT
assert_equal(0x0800, WIN32OLE::LOCALE_SYSTEM_DEFAULT);
end
def test_const_LOCALE_USER_DEFAULT
assert_equal(0x0400, WIN32OLE::LOCALE_USER_DEFAULT);
end
end
# test of subclass of WIN32OLE

View file

@ -81,8 +81,13 @@ if defined?(WIN32OLE_VARIANT)
end
def test_conversion_str2cy
obj = WIN32OLE_VARIANT.new("\\10,000", WIN32OLE::VARIANT::VT_CY)
assert_equal("10000", obj.value)
begin
WIN32OLE.locale = 0x0411 # set locale Japanese
obj = WIN32OLE_VARIANT.new("\\10,000", WIN32OLE::VARIANT::VT_CY)
assert_equal("10000", obj.value)
ensure
WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT
end
end
def test_create_vt_array
@ -105,6 +110,7 @@ if defined?(WIN32OLE_VARIANT)
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)
@ -126,6 +132,11 @@ if defined?(WIN32OLE_VARIANT)
assert_equal("Str", obj.value);
end
def test_vartype
obj = WIN32OLE_VARIANT.new("Str")
assert_equal(WIN32OLE::VARIANT::VT_BSTR, obj.vartype)
end
def test_c_nothing
assert_nil(WIN32OLE_VARIANT::Nothing.value)
end