Sha256: db6ef72bd4e2c29cef2490a1a20994114c9b74080c7e0cfbc565a9dc1c725e1b

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

#!/usr/bin/env ruby

require File.expand_path(File.join(File.dirname(__FILE__), "spec_common"))
require 'bindata/float'

describe "A FloatLe" do
  subject { BinData::FloatLe.new(Math::PI) }

  its(:num_bytes)               { should == 4 }
  its(:to_binary_s)             { should == [Math::PI].pack('e') }
  its(:value_read_from_written) { should be_within(0.000001).of(Math::PI) }
end

describe "A FloatBe" do
  subject { BinData::FloatBe.new(Math::PI) }

  its(:num_bytes)               { should == 4 }
  its(:to_binary_s)             { should == [Math::PI].pack('g') }
  its(:value_read_from_written) { should be_within(0.000001).of(Math::PI) }
end

describe "A DoubleLe" do
  subject { BinData::DoubleLe.new(Math::PI) }

  its(:num_bytes)               { should == 8 }
  its(:to_binary_s)             { should == [Math::PI].pack('E') }
  its(:value_read_from_written) { should be_within(0.0000000000000001).of(Math::PI) }
end


describe "A DoubleBe" do
  subject { BinData::DoubleBe.new(Math::PI) }

  its(:num_bytes)               { should == 8 }
  its(:to_binary_s)             { should == [Math::PI].pack('G') }
  its(:value_read_from_written) { should be_within(0.0000000000000001).of(Math::PI) }
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
jbangert-bindata-1.5.0 spec/float_spec.rb
bindata-1.5.1 spec/float_spec.rb
bindata-1.5.0 spec/float_spec.rb
bindata-1.4.5 spec/float_spec.rb
bindata-1.4.4 spec/float_spec.rb