summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-06 22:50:05 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-06 22:50:05 +0000
commit90e410088e44ff0239ffd8c990f085d74a1a2b5c (patch)
tree1cf8b274c54fd6ef83fcf10a01cad44110848ade /test
parent105461551ff0abc6531486cabba413e62dd2e622 (diff)
downloadruby-90e410088e44ff0239ffd8c990f085d74a1a2b5c.tar.gz
ruby-90e410088e44ff0239ffd8c990f085d74a1a2b5c.tar.xz
ruby-90e410088e44ff0239ffd8c990f085d74a1a2b5c.zip
* ext/dl/cptr.c (rb_dlptr_s_malloc, rb_dlptr_initialize): adding
documentation * test/dl/test_cptr.rb (**): testing that malloc works when passed free functions git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/dl/test_cptr.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/dl/test_cptr.rb b/test/dl/test_cptr.rb
index 979c5f50b..2b40a16fb 100644
--- a/test/dl/test_cptr.rb
+++ b/test/dl/test_cptr.rb
@@ -3,6 +3,22 @@ require_relative '../ruby/envutil'
module DL
class TestCPtr < TestBase
+ def test_malloc_free_func_int
+ free = CFunc.new(@libc['free'], TYPE_VOID, 'free')
+
+ ptr = CPtr.malloc(10, free.to_i)
+ assert_equal 10, ptr.size
+ assert_equal free.to_i, ptr.free.to_i
+ end
+
+ def test_malloc_free_func
+ free = CFunc.new(@libc['free'], TYPE_VOID, 'free')
+
+ ptr = CPtr.malloc(10, free)
+ assert_equal 10, ptr.size
+ assert_equal free.to_i, ptr.free.to_i
+ end
+
def test_to_str
str = "hello world"
ptr = CPtr[str]