Sha256: ecd1a01e28384971c43d037ffe8fc72b6da5ba55a34708b704720f521cfd318a

Contents?: true

Size: 581 Bytes

Versions: 9

Compression:

Stored size: 581 Bytes

Contents

require 'gir_ffi_test_helper'

describe GirFFI::FFIExt::Pointer do
  let(:klass) { Class.new { include GirFFI::FFIExt::Pointer } }
  describe "#to_object" do
    it "finds the wrapping class by gtype and wraps the pointer in it" do
      ptr = klass.new
      mock(ptr).null? { false }
      object_class = Class.new

      mock(GObject).type_from_instance_pointer(ptr) { 0xdeadbeef }
      mock(GirFFI::Builder).build_by_gtype(0xdeadbeef) { object_class }
      mock(object_class).direct_wrap(ptr) { "good-result" }

      ptr.to_object.must_equal "good-result"
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gir_ffi-0.7.7 test/gir_ffi/ffi_ext/pointer_test.rb
gir_ffi-0.7.6 test/gir_ffi/ffi_ext/pointer_test.rb
gir_ffi-0.7.5 test/gir_ffi/ffi_ext/pointer_test.rb
gir_ffi-0.7.4 test/gir_ffi/ffi_ext/pointer_test.rb
gir_ffi-0.7.3 test/gir_ffi/ffi_ext/pointer_test.rb
gir_ffi-0.7.2 test/gir_ffi/ffi_ext/pointer_test.rb
gir_ffi-0.7.1 test/gir_ffi/ffi_ext/pointer_test.rb
gir_ffi-0.7.0 test/gir_ffi/ffi_ext/pointer_test.rb
gir_ffi-0.6.7 test/gir_ffi/ffi_ext/pointer_test.rb