summaryrefslogtreecommitdiff
path: root/test/win32ole
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-16 12:06:23 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-16 12:06:23 +0000
commit6d7ddc3b297bfe6ca9f091c0097722b0422cc7e2 (patch)
treef19da6b9f2e7d56d1dae72113612168301bb2e45 /test/win32ole
parent1c75d58165fef446d507ce6f05e50eeaa66772f7 (diff)
* test/win32ole/test_win32ole.rb (test_s_codepage_changed,
test_s_locale_set, test_s_locale_change): skip test if Japanese locale is not installed. [ruby-core:23806] * test/win32ole/test_win32ole_variant.rb (test_conversion_str2cy): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/win32ole')
-rw-r--r--test/win32ole/test_win32ole.rb53
-rw-r--r--test/win32ole/test_win32ole_variant.rb12
2 files changed, 48 insertions, 17 deletions
diff --git a/test/win32ole/test_win32ole.rb b/test/win32ole/test_win32ole.rb
index 18da3be..8c8528f 100644
--- a/test/win32ole/test_win32ole.rb
+++ b/test/win32ole/test_win32ole.rb
@@ -344,8 +344,11 @@ if defined?(WIN32OLE)
WIN32OLE.codepage = cp
file = fso.opentextfile(fname, 2, true)
- file.write [0x3042].pack("U*").force_encoding("UTF-8")
- file.close
+ begin
+ file.write [0x3042].pack("U*").force_encoding("UTF-8")
+ ensure
+ file.close
+ end
str = ""
open(fname, "r:ascii-8bit") {|ifs|
str = ifs.read
@@ -360,8 +363,11 @@ if defined?(WIN32OLE)
if (WIN32OLE.codepage == 20932)
WIN32OLE.codepage = cp
file = fso.opentextfile(fname, 2, true)
- file.write [164, 162].pack("c*").force_encoding("EUC-JP")
- file.close
+ begin
+ file.write [164, 162].pack("c*").force_encoding("EUC-JP")
+ ensure
+ file.close
+ end
open(fname, "r:ascii-8bit") {|ifs|
str = ifs.read
}
@@ -398,7 +404,12 @@ if defined?(WIN32OLE)
def test_s_locale_set
begin
- WIN32OLE.locale = 1041
+ begin
+ WIN32OLE.locale = 1041
+ rescue WIN32OLERuntimeError
+ STDERR.puts("\n#{__FILE__}:#{__LINE__}:#{self.class.name}.test_s_locale_set is skipped(Japanese locale is not installed)")
+ return
+ end
assert_equal(1041, WIN32OLE.locale)
WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT
assert_raise(WIN32OLERuntimeError) {
@@ -412,16 +423,30 @@ if defined?(WIN32OLE)
def test_s_locale_change
begin
- WIN32OLE.locale = 0x0411
- obj = WIN32OLE_VARIANT.new("\\100,000", WIN32OLE::VARIANT::VT_CY)
- assert_equal("100000", obj.value)
- assert_raise(WIN32OLERuntimeError) {
- obj = WIN32OLE_VARIANT.new("$100.000", WIN32OLE::VARIANT::VT_CY)
- }
+ begin
+ WIN32OLE.locale = 0x0411
+ rescue WIN32OLERuntimeError
+ end
+ if WIN32OLE.locale == 0x0411
+ obj = WIN32OLE_VARIANT.new("\\100,000", WIN32OLE::VARIANT::VT_CY)
+ assert_equal("100000", obj.value)
+ assert_raise(WIN32OLERuntimeError) {
+ obj = WIN32OLE_VARIANT.new("$100.000", WIN32OLE::VARIANT::VT_CY)
+ }
+ else
+ STDERR.puts("\n#{__FILE__}:#{__LINE__}:#{self.class.name}.test_s_locale_change is skipped(Japanese locale is not installed)")
+ end
- WIN32OLE.locale = 1033
- obj = WIN32OLE_VARIANT.new("$100,000", WIN32OLE::VARIANT::VT_CY)
- assert_equal("100000", obj.value)
+ begin
+ WIN32OLE.locale = 1033
+ rescue WIN32OLERuntimeError
+ end
+ if WIN32OLE.locale == 1033
+ obj = WIN32OLE_VARIANT.new("$100,000", WIN32OLE::VARIANT::VT_CY)
+ assert_equal("100000", obj.value)
+ else
+ STDERR.puts("\n#{__FILE__}:#{__LINE__}:#{self.class.name}.test_s_locale_change is skipped(US English locale is not installed)")
+ end
ensure
WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT
end
diff --git a/test/win32ole/test_win32ole_variant.rb b/test/win32ole/test_win32ole_variant.rb
index 7bf6caa..d753fb4 100644
--- a/test/win32ole/test_win32ole_variant.rb
+++ b/test/win32ole/test_win32ole_variant.rb
@@ -384,9 +384,15 @@ if defined?(WIN32OLE_VARIANT)
def test_conversion_str2cy
begin
- WIN32OLE.locale = 0x0411 # set locale Japanese
- obj = WIN32OLE_VARIANT.new("\\10,000", WIN32OLE::VARIANT::VT_CY)
- assert_equal("10000", obj.value)
+ begin
+ WIN32OLE.locale = 0x0411 # set locale Japanese
+ rescue WIN32OLERuntimeError
+ STDERR.puts("\n#{__FILE__}:#{__LINE__}:#{self.class.name}.test_conversion_str2cy is skipped(Japanese locale is not installed)")
+ end
+ if WIN32OLE.locale == 0x0411
+ obj = WIN32OLE_VARIANT.new("\\10,000", WIN32OLE::VARIANT::VT_CY)
+ assert_equal("10000", obj.value)
+ end
ensure
WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT
end