Skip to content

Commit

Permalink
Add spec for Pointer#write_array_of_type
Browse files Browse the repository at this point in the history
  • Loading branch information
ytaka committed Oct 20, 2018
1 parent 65b53d2 commit ec46ced
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion spec/ffi/pointer_spec.rb
Expand Up @@ -94,7 +94,26 @@ def to_ptr
expect(array[j].address).to eq(address)
end
end


it "#write_array_of_type for uint8" do
values = [10, 227, 32]
memory = FFI::MemoryPointer.new FFI::TYPE_UINT8, values.size
memory.write_array_of_type(FFI::TYPE_UINT8, :put_uint8, values)
array = memory.read_array_of_type(FFI::TYPE_UINT8, :read_uint8, values.size)
values.each_with_index do |val, j|
expect(array[j]).to eq(val)
end
end

it "#write_array_of_type for uint32" do
values = [10, 227, 32]
memory = FFI::MemoryPointer.new FFI::TYPE_UINT32, values.size
memory.write_array_of_type(FFI::TYPE_UINT32, :put_uint32, values)
array = memory.read_array_of_type(FFI::TYPE_UINT32, :read_uint32, values.size)
values.each_with_index do |val, j|
expect(array[j]).to eq(val)
end
end
end

describe 'NULL' do
Expand Down

0 comments on commit ec46ced

Please sign in to comment.