summaryrefslogtreecommitdiff
path: root/test/win32ole/test_win32ole_variant_outarg.rb
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-11-02 15:41:02 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-11-02 15:41:02 +0000
commit1dead12e7f01a0d6e2093af4ad685e3c6e13e4af (patch)
tree79d1ca94715f25ab3c3c35ee09f1016a88da94d6 /test/win32ole/test_win32ole_variant_outarg.rb
parentf35fb72f44dda18394e2a675e3909b55591ac17e (diff)
* test/win32ole/test_win32ole_event.rb: rename test class.
* test/win32ole/test_win32ole_variant_outarg.rb: add in order to use ADO instead of Internet Explorer. remove test/win32ole/test_win32ole_variant_with_ie.rb. * test/win32ole/orig_data.csv: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/win32ole/test_win32ole_variant_outarg.rb')
-rw-r--r--test/win32ole/test_win32ole_variant_outarg.rb69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/win32ole/test_win32ole_variant_outarg.rb b/test/win32ole/test_win32ole_variant_outarg.rb
new file mode 100644
index 0000000000..1e4892f7f1
--- /dev/null
+++ b/test/win32ole/test_win32ole_variant_outarg.rb
@@ -0,0 +1,69 @@
+begin
+ require 'win32ole'
+rescue LoadError
+end
+require 'test/unit'
+require 'fileutils'
+
+def ado_csv_installed?
+ installed = false
+ if defined?(WIN32OLE)
+ db = nil
+ begin
+ db = WIN32OLE.new('ADODB.Connection')
+ db.connectionString = "Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=.;"
+ db.open
+ db.close
+ db = nil
+ installed = true
+ rescue
+ end
+ end
+ installed
+end
+
+if defined?(WIN32OLE_VARIANT)
+ dotest = ado_csv_installed?
+ if !dotest
+ STDERR.puts("\n#{__FILE__} skipped(ActiveX Data Object Library not found.)")
+ end
+ if dotest
+ class TestWIN32OLE_VARIANT_OUTARG < Test::Unit::TestCase
+ module ADO
+ end
+ CONNSTR="Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=.;"
+ def setup
+ FileUtils.cp(File.dirname(__FILE__) + '/orig_data.csv', './data.csv')
+ @db = WIN32OLE.new('ADODB.Connection')
+ if !defined?(ADO::AdStateOpen)
+ WIN32OLE.const_load(@db, ADO)
+ end
+ @db.connectionString = CONNSTR
+ @db.open
+ end
+
+ def test_variant_ref_and_argv
+ sql = "INSERT INTO data.csv VALUES (5, 'E')"
+ @db.execute(sql, -1)
+ c = WIN32OLE::ARGV[1]
+ assert_equal(1, WIN32OLE::ARGV[1])
+ obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_VARIANT|WIN32OLE::VARIANT::VT_BYREF)
+ assert_equal(nil, obj.value)
+ @db.execute(sql , obj)
+ assert_equal(1, obj.value)
+ obj = WIN32OLE_VARIANT.new(-100, WIN32OLE::VARIANT::VT_VARIANT|WIN32OLE::VARIANT::VT_BYREF)
+ assert_equal(-100, obj.value)
+ @db.execute(sql, obj)
+ assert_equal(1, obj.value)
+ end
+
+ def teardown
+ if @db && @db.state == ADO::AdStateOpen
+ @db.close
+ end
+ File.unlink("data.csv")
+ end
+
+ end
+ end
+end