summaryrefslogtreecommitdiff
path: root/test/win32ole/test_win32ole_typelib.rb
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-04-01 06:23:07 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-04-01 06:23:07 +0000
commit3ff87cc53f6705959db82c8a4270bbdd5b8eabbd (patch)
treee4f39a05c33bf2a4f332eac6591d5b7f78349cb8 /test/win32ole/test_win32ole_typelib.rb
parent53efc383503c42a5c19d947c53f6caad25ee9de8 (diff)
add WIN32OLE_TYPE#inspect, WIN32OLE_VARIABLE#inspect
add test/win32ole and remove some test script from ext/win32ole/tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/win32ole/test_win32ole_typelib.rb')
-rw-r--r--test/win32ole/test_win32ole_typelib.rb92
1 files changed, 92 insertions, 0 deletions
diff --git a/test/win32ole/test_win32ole_typelib.rb b/test/win32ole/test_win32ole_typelib.rb
new file mode 100644
index 0000000000..0ef805d959
--- /dev/null
+++ b/test/win32ole/test_win32ole_typelib.rb
@@ -0,0 +1,92 @@
+begin
+ require 'win32ole'
+rescue LoadError
+end
+
+require "test/unit"
+
+if defined?(WIN32OLE_TYPELIB)
+ class TestWIN32OLE_TYPELIB < Test::Unit::TestCase
+ def test_s_typelibs
+ tlibs = WIN32OLE_TYPELIB.typelibs
+ assert_instance_of(Array, tlibs)
+ assert(tlibs.size > 0)
+ tlib = tlibs.find {|tlib| tlib.name == "Microsoft Shell Controls And Automation"}
+ assert(tlib)
+ end
+
+ def test_initialize
+ assert_raise(ArgumentError) {
+ WIN32OLE_TYPELIB.new(1,2,3,4)
+ }
+ tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ assert_instance_of(WIN32OLE_TYPELIB, tlib)
+
+ tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation", 1.0)
+ assert_instance_of(WIN32OLE_TYPELIB, tlib)
+
+ tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation", 1, 0)
+ assert_instance_of(WIN32OLE_TYPELIB, tlib)
+ guid = tlib.guid
+
+ tlib_by_guid = WIN32OLE_TYPELIB.new(guid, 1, 0)
+ assert_instance_of(WIN32OLE_TYPELIB, tlib_by_guid)
+ assert_equal("Microsoft Shell Controls And Automation" , tlib_by_guid.name)
+
+ assert_raise(WIN32OLERuntimeError) {
+ WIN32OLE_TYPELIB.new("Non Exist Type Library")
+ }
+ end
+
+ def test_guid
+ tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ assert_equal("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}", tlib.guid)
+ end
+
+ def test_name
+ tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ assert_equal("Microsoft Shell Controls And Automation", tlib.name)
+ tlib = WIN32OLE_TYPELIB.new("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}")
+ assert_equal("Microsoft Shell Controls And Automation", tlib.name)
+ end
+
+ def test_version
+ tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ assert_equal(1.0, tlib.version)
+ end
+
+ def test_major_version
+ tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ assert_equal(1, tlib.major_version)
+ end
+
+ def test_minor_version
+ tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ assert_equal(0, tlib.minor_version)
+ end
+
+ def test_path
+ tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ assert_match(/shell32\.dll$/i, tlib.path)
+ end
+
+ def test_to_s
+ tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ assert_equal("Microsoft Shell Controls And Automation", tlib.to_s)
+ end
+
+ def test_ole_classes
+ tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ ole_classes = tlib.ole_classes
+ assert_instance_of(Array, ole_classes)
+ assert(ole_classes.size > 0)
+ assert_instance_of(WIN32OLE_TYPE, ole_classes[0])
+ end
+
+ def test_inspect
+ tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ assert_equal("#<WIN32OLE_TYPELIB:Microsoft Shell Controls And Automation>", tlib.inspect)
+ end
+
+ end
+end