Sha256: 70d55b3eb3002180db7775a777096c8a3bf9fe5b2f7614a0784de40fe4cd3fdf

Contents?: true

Size: 986 Bytes

Versions: 10

Compression:

Stored size: 986 Bytes

Contents

require 'gir_ffi_test_helper'

describe GirFFI::InfoExt::IFieldInfo do
  describe "#layout_specification" do
    it "returns an array of name, typespec and offset" do
      testclass = Class.new do
        include GirFFI::InfoExt::IFieldInfo
      end

      mock(type = Object.new).layout_specification_type { :bar }

      field = testclass.new
      mock(field).name { "foo" }
      mock(field).field_type { type }
      mock(field).offset { 0 }

      result = field.layout_specification

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

    it "keeps a complex typespec intact" do
      testclass = Class.new do
        include GirFFI::InfoExt::IFieldInfo
      end

      mock(type = Object.new).layout_specification_type { [:bar, 2] }

      field = testclass.new
      mock(field).name { "foo" }
      mock(field).field_type { type }
      mock(field).offset { 0 }

      result = field.layout_specification

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gir_ffi-0.6.3 test/gir_ffi/info_ext/i_field_info_test.rb
gir_ffi-0.6.2 test/gir_ffi/info_ext/i_field_info_test.rb
gir_ffi-0.6.1 test/gir_ffi/info_ext/i_field_info_test.rb
gir_ffi-0.6.0 test/gir_ffi/info_ext/i_field_info_test.rb
gir_ffi-0.5.2 test/gir_ffi/info_ext/i_field_info_test.rb
gir_ffi-0.5.1 test/gir_ffi/info_ext/i_field_info_test.rb
gir_ffi-0.5.0 test/gir_ffi/info_ext/i_field_info_test.rb
gir_ffi-0.4.3 test/gir_ffi/info_ext/i_field_info_test.rb
gir_ffi-0.4.2 test/gir_ffi/info_ext/i_field_info_test.rb
gir_ffi-0.4.1 test/gir_ffi/info_ext/i_field_info_test.rb