Skip to content

Commit b3a6c29

Browse files
add test for auto-converting integer to pointer
1 parent 7f44331 commit b3a6c29

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

test/fiddle/test_function.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ def test_call
9898
assert_in_delta 1.0, func.call(90 * Math::PI / 180), 0.0001
9999
end
100100

101+
def test_integer_pointer_conversion
102+
func = Function.new(@libc['memcpy'], [TYPE_VOIDP, TYPE_VOIDP, TYPE_SIZE_T], TYPE_VOIDP)
103+
str = 'hello'
104+
dst = Pointer.malloc(str.bytesize, Fiddle::RUBY_FREE)
105+
func.call(dst.to_i, str, dst.size)
106+
assert_equal str, dst.to_str
107+
end
108+
101109
def test_argument_count
102110
closure_class = Class.new(Closure) do
103111
def call one

0 commit comments

Comments
 (0)