Sha256: e90d9f82a74bd1f12c6f01d2feaaaaea04cbe34ac529b35d131c0467ddd0a953
Contents?: true
Size: 1002 Bytes
Versions: 2
Compression:
Stored size: 1002 Bytes
Contents
# frozen_string_literal: true require 'gir_ffi_test_helper' describe GirFFI::AllocationHelper do describe '.free_after' do before do allow(GirFFI::LibC).to receive(:free) end it 'frees the passed-in pointer' do ptr = double('pointer', null?: false) GirFFI::AllocationHelper.free_after(ptr) {} expect(GirFFI::LibC).to have_received(:free).with(ptr) end it 'does not free a passed-in null pointer' do ptr = double('pointer', null?: true) GirFFI::AllocationHelper.free_after(ptr) {} expect(GirFFI::LibC).not_to have_received(:free) end it 'yields ptr to the block' do ptr = double('pointer', null?: false) foo = nil GirFFI::AllocationHelper.free_after(ptr) { |it| foo = it } foo.must_equal ptr end it 'returns the result of the block' do ptr = double('pointer', null?: false) result = GirFFI::AllocationHelper.free_after(ptr) { 'bar' } result.must_equal 'bar' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gir_ffi-0.11.1 | test/gir_ffi/allocation_helper_test.rb |
gir_ffi-0.11.0 | test/gir_ffi/allocation_helper_test.rb |