Sha256: 2935f94791d8d6aca43de318f37586063108975e4b6a5ec441c54e9d56406b5b

Contents?: true

Size: 881 Bytes

Versions: 39

Compression:

Stored size: 881 Bytes

Contents

#
# This file is part of ruby-ffi.
# For licensing, see LICENSE.SPECS
#

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

describe ":long_double arguments and return values" do
  module LibTest
    extend FFI::Library
    ffi_lib TestLibrary::PATH
    attach_function :add_f128, [ :long_double, :long_double ], :long_double
    attach_function :ret_f128, [ :long_double ], :long_double
  end

  it "returns first parameter" do
    LibTest.ret_f128(0.1).should be_within(0.01).of(0.1)
  end

  it "returns first parameter with high precision" do
    ld =        BigDecimal.new("1.234567890123456789")
    tolerance = BigDecimal.new("0.0000000000000000001")
    LibTest.ret_f128(ld).should be_within(tolerance).of(ld)
  end

  it "add two long double numbers" do
    LibTest.add_f128(0.1, 0.2).should be_within(0.01).of(0.3)
  end
end

Version data entries

39 entries across 37 versions & 8 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/ffi-1.9.3/spec/ffi/long_double.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/ffi-1.9.3/spec/ffi/long_double.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/ffi-1.9.3/spec/ffi/long_double.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/ffi-1.9.3/spec/ffi/long_double.rb
ffi-1.9.3-x64-mingw32 spec/ffi/long_double.rb
ffi-1.9.3-x86-mingw32 spec/ffi/long_double.rb
ffi-1.9.3 spec/ffi/long_double.rb
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/ffi-1.9.0/spec/ffi/long_double.rb
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/ffi-1.8.1/spec/ffi/long_double.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/ffi-1.9.0/spec/ffi/long_double.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/ffi-1.8.1/spec/ffi/long_double.rb
ffi-1.9.0-x86-mingw32 spec/ffi/long_double.rb
ffi-1.9.0 spec/ffi/long_double.rb
vagrant-shell-0.2.6 vendor/bundle/gems/ffi-1.8.1/spec/ffi/long_double.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/ffi-1.8.1/spec/ffi/long_double.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/ffi-1.8.1/spec/ffi/long_double.rb
vagrant-shell-0.2.5 vendor/bundle/gems/ffi-1.8.1/spec/ffi/long_double.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/ffi-1.3.1/spec/ffi/long_double.rb
ffi-1.8.1-x86-mingw32 spec/ffi/long_double.rb
ffi-1.8.1 spec/ffi/long_double.rb