Sha256: 9eda1969a23915d18d26a17a53e8d6c206a14cda204b47db5921a6505c59dd10

Contents?: true

Size: 1.07 KB

Versions: 9

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true
require 'gir_ffi_test_helper'

describe GirFFI::InfoExt::IFieldInfo do
  let(:klass) do
    Class.new do
      include GirFFI::InfoExt::IFieldInfo
    end
  end
  let(:field_info) { klass.new }
  describe '#layout_specification' do
    it 'returns an array of name, typespec and offset' do
      expect(type = Object.new).to receive(:to_ffi_type).and_return :bar

      expect(field_info).to receive(:name).and_return 'foo'
      expect(field_info).to receive(:field_type).and_return type
      expect(field_info).to receive(:offset).and_return 0

      result = field_info.layout_specification

      assert_equal [:foo, :bar, 0], result
    end

    it 'keeps a complex typespec intact' do
      expect(type = Object.new).to receive(:to_ffi_type).and_return [:bar, 2]

      expect(field_info).to receive(:name).and_return 'foo'
      expect(field_info).to receive(:field_type).and_return type
      expect(field_info).to receive(:offset).and_return 0

      result = field_info.layout_specification

      assert_equal [:foo, [:bar, 2], 0], result
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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