Sha256: d9136ea8d366e99ae9414393313fa60cea0912a68ecc36433fad1405dc7b3936

Contents?: true

Size: 869 Bytes

Versions: 9

Compression:

Stored size: 869 Bytes

Contents

# frozen_string_literal: true
require 'gir_ffi_test_helper'

GirFFI.setup :Regress

describe GirFFI::ObjectBase do
  let(:derived_class) { Class.new GirFFI::ObjectBase }

  describe '.wrap' do
    it 'delegates conversion to the wrapped pointer' do
      expect(ptr = Object.new).to receive(:to_object).and_return 'good-result'
      derived_class.wrap(ptr).must_equal 'good-result'
    end
  end

  describe '.to_ffi_type' do
    it 'returns itself' do
      derived_class.to_ffi_type.must_equal derived_class
    end
  end

  describe '.object_class' do
    it 'returns an object of the class struct type' do
      Regress::TestObj.object_class.must_be_instance_of Regress::TestObjClass
    end

    it 'caches its result' do
      first = Regress::TestObj.object_class
      second = Regress::TestObj.object_class
      second.must_be :eql?, first
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gir_ffi-0.11.1 test/gir_ffi/object_base_test.rb
gir_ffi-0.11.0 test/gir_ffi/object_base_test.rb
gir_ffi-0.10.2 test/gir_ffi/object_base_test.rb
gir_ffi-0.10.1 test/gir_ffi/object_base_test.rb
gir_ffi-0.10.0 test/gir_ffi/object_base_test.rb
gir_ffi-0.10.0.pre1 test/gir_ffi/object_base_test.rb
gir_ffi-0.9.5 test/gir_ffi/object_base_test.rb
gir_ffi-0.9.4 test/gir_ffi/object_base_test.rb
gir_ffi-0.9.3 test/gir_ffi/object_base_test.rb