Sha256: 3a535cb351e4fc53096e715be80f85801c907a03e19f9e8033f5c770a8192126

Contents?: true

Size: 714 Bytes

Versions: 184

Compression:

Stored size: 714 Bytes

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))

class Timeval < FFI::Struct
  layout :tv_sec, :ulong, 0, :tv_usec, :ulong, 4  
end

module LibC
  extend FFI::Library
  ffi_lib FFI::Library::LIBC

  attach_function :gettimeofday, [:pointer, :pointer], :int
end

describe FFI::Library, "#attach_function" do
  it "correctly returns a value for gettimeofday" do
    t = Timeval.new
    time = LibC.gettimeofday(t.pointer, nil)
    time.should be_kind_of(Integer)
  end
  
  it "correctly populates a struct for gettimeofday" do
    t = Timeval.new
    time = LibC.gettimeofday(t.pointer, nil)
    t[:tv_sec].should be_kind_of(Numeric)
    t[:tv_usec].should be_kind_of(Numeric)
  end
end

Version data entries

184 entries across 180 versions & 16 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/ffi-1.9.3/spec/ffi/rbx/attach_function_spec.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/ffi-1.9.3/spec/ffi/rbx/attach_function_spec.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/ffi-1.9.3/spec/ffi/rbx/attach_function_spec.rb
classiccms-0.7.5 vendor/bundle/gems/ffi-1.0.11/spec/ffi/rbx/attach_function_spec.rb
classiccms-0.7.4 vendor/bundle/gems/ffi-1.0.11/spec/ffi/rbx/attach_function_spec.rb
classiccms-0.7.3 vendor/bundle/gems/ffi-1.0.11/spec/ffi/rbx/attach_function_spec.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/ffi-1.9.3/spec/ffi/rbx/attach_function_spec.rb
ffi-1.9.3-x64-mingw32 spec/ffi/rbx/attach_function_spec.rb
ffi-1.9.3-x86-mingw32 spec/ffi/rbx/attach_function_spec.rb
ffi-1.9.3 spec/ffi/rbx/attach_function_spec.rb
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/ffi-1.9.0/spec/ffi/rbx/attach_function_spec.rb
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/ffi-1.8.1/spec/ffi/rbx/attach_function_spec.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/ffi-1.9.0/spec/ffi/rbx/attach_function_spec.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/ffi-1.8.1/spec/ffi/rbx/attach_function_spec.rb
classiccms-0.7.2 vendor/bundle/gems/ffi-1.0.11/spec/ffi/rbx/attach_function_spec.rb
classiccms-0.7.1 vendor/bundle/gems/ffi-1.0.11/spec/ffi/rbx/attach_function_spec.rb
ffi-1.9.0-x86-mingw32 spec/ffi/rbx/attach_function_spec.rb
ffi-1.9.0 spec/ffi/rbx/attach_function_spec.rb
classiccms-0.7.0 vendor/bundle/gems/ffi-1.0.11/spec/ffi/rbx/attach_function_spec.rb
vagrant-shell-0.2.6 vendor/bundle/gems/ffi-1.8.1/spec/ffi/rbx/attach_function_spec.rb