From e852838cee777cfc9c6e3f8f16142d4809422179 Mon Sep 17 00:00:00 2001 From: kou Date: Fri, 21 Dec 2012 14:12:57 +0000 Subject: * ext/fiddle/lib/fiddle/struct.rb (Fiddle::CStructEntity#set_ctypes): CPtr -> Pointer. * test/fiddle/test_c_struct_entry.rb (Fiddle::TestCStructEntity#test_aref_pointer_array): Added the test for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/fiddle/test_c_struct_entry.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/fiddle/test_c_struct_entry.rb') diff --git a/test/fiddle/test_c_struct_entry.rb b/test/fiddle/test_c_struct_entry.rb index 43cf28e493..3a5faefabc 100644 --- a/test/fiddle/test_c_struct_entry.rb +++ b/test/fiddle/test_c_struct_entry.rb @@ -50,5 +50,16 @@ module Fiddle assert_equal 1, union['long'] assert_equal 2, union['int'] end + + def test_aref_pointer_array + team = CStructEntity.malloc([[TYPE_VOIDP, 2]]) + team.assign_names(["names"]) + alice = Fiddle::Pointer.malloc(6) + alice[0, 6] = "Alice\0" + bob = Fiddle::Pointer.malloc(4) + bob[0, 4] = "Bob\0" + team["names"] = [alice, bob] + assert_equal(["Alice", "Bob"], team["names"].map(&:to_s)) + end end end -- cgit v1.2.3