Sha256: 94dd9588157afe39ffb314c0f4859ac224a9dec408b749b68834c06e7b05f57c

Contents?: true

Size: 893 Bytes

Versions: 79

Compression:

Stored size: 893 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
    expect(LibTest.ret_f128(0.1)).to 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")
    expect(LibTest.ret_f128(ld)).to be_within(tolerance).of(ld)
  end

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

Version data entries

79 entries across 77 versions & 14 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/long_double.rb
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/ffi-1.9.18/spec/ffi/long_double.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/long_double.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.5.0/gems/ffi-1.9.18/spec/ffi/long_double.rb
ffi-1.9.21-x86-mingw32 spec/ffi/long_double.rb
ffi-1.9.21-x64-mingw32 spec/ffi/long_double.rb
ffi-1.9.21 spec/ffi/long_double.rb
tdiary-5.0.7 vendor/bundle/gems/ffi-1.9.18/spec/ffi/long_double.rb
comiditaULL-0.1.1 vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/spec/ffi/long_double.rb
comidita_ull-0.1.1 vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/spec/ffi/long_double.rb
comidita_ull-0.1.0 vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/spec/ffi/long_double.rb
vagrant-unbundled-2.0.1.0 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/long_double.rb
cloudsmith-api-0.21.4 vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/spec/ffi/long_double.rb
tdiary-5.0.6 vendor/bundle/gems/ffi-1.9.18/spec/ffi/long_double.rb
vagrant-unbundled-2.0.0.1 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/long_double.rb
vagrant-unbundled-1.9.8.1 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/long_double.rb
vagrant-unbundled-1.9.7.1 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/long_double.rb
tdiary-5.0.5 vendor/bundle/gems/ffi-1.9.18/spec/ffi/long_double.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/ffi-1.9.18/spec/ffi/long_double.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/long_double.rb