Sha256: d3903586399c42066847a0097e4e20e03773655837da69a4a7a96b1ce58af715
Contents?: true
Size: 895 Bytes
Versions: 3
Compression:
Stored size: 895 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 'ffi' 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ffi-1.9.5-x64-mingw32 | spec/ffi/long_double.rb |
ffi-1.9.5-x86-mingw32 | spec/ffi/long_double.rb |
ffi-1.9.5 | spec/ffi/long_double.rb |