summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-30 23:20:29 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-30 23:20:29 +0000
commitf1cb6ea08f8fc897d914fc7c2c23701471657e4f (patch)
tree6e29502811c45344ef835ace340dd23e5d99a82c /test
parente88c8880b13462be0e3f109bb61daa306d9ed1f9 (diff)
* ext/dl/lib/dl/struct.rb (DL::CUnionEntity::size): Fixed ::size to
return the size of the union. * test/dl/test_c_union_entity.rb: Test for DL::CUnionEntity::size Reviewed by Aaron Patterson git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/dl/test_c_union_entity.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/dl/test_c_union_entity.rb b/test/dl/test_c_union_entity.rb
new file mode 100644
index 0000000000..8c72a664eb
--- /dev/null
+++ b/test/dl/test_c_union_entity.rb
@@ -0,0 +1,18 @@
+require_relative 'test_base'
+
+require 'dl/cparser'
+
+class DL::TestCUnionEntity < DL::TestBase
+ def test_class_size
+ size = DL::CUnionEntity.size([DL::TYPE_DOUBLE, DL::TYPE_CHAR])
+
+ assert_equal DL::SIZEOF_DOUBLE, size
+ end
+
+ def test_class_size_with_count
+ size = DL::CUnionEntity.size([[DL::TYPE_DOUBLE, 2], [DL::TYPE_CHAR, 20]])
+
+ assert_equal DL::SIZEOF_CHAR * 20, size
+ end
+end
+