summaryrefslogtreecommitdiff
path: root/test/dl
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-31 22:07:09 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-31 22:07:09 +0000
commitfe962cde158562e0d41b61ea48267cf0413f190c (patch)
treefa18528c4fde8113be78f74ad8d40a7947a9a754 /test/dl
parent4f69926f75cd90822408c915c2b4ec637c749dd1 (diff)
* ext/dl/lib/dl/struct.rb (DL::CStructEntity#set_ctypes): Refactored
#set_ctypes using newer ruby features to simplify its implementation. * test/dl/test_c_struct_entry.rb (class DL): Test to verify refactoring. Reviewed by Aaron Patterson. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/dl')
-rw-r--r--test/dl/test_c_struct_entry.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/dl/test_c_struct_entry.rb b/test/dl/test_c_struct_entry.rb
index b83cde8..aa49a99 100644
--- a/test/dl/test_c_struct_entry.rb
+++ b/test/dl/test_c_struct_entry.rb
@@ -37,5 +37,17 @@ class DL::TestCStructEntity < DL::TestBase
assert_equal expected, size
end
+
+ def test_set_ctypes
+ union = DL::CStructEntity.malloc [DL::TYPE_INT, DL::TYPE_LONG]
+ union.assign_names %w[int long]
+
+ # this test is roundabout because the stored ctypes are not accessible
+ union['long'] = 1
+ union['int'] = 2
+
+ assert_equal 1, union['long']
+ assert_equal 2, union['int']
+ end
end