Sha256: fc6486cee646459434a72868eb212a4100029aff75e12b93522de25066a5e379

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 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_close(Math::PI, 0.000001) }
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_close(Math::PI, 0.000001) }
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_close(Math::PI, 0.0000000000000001) }
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_close(Math::PI, 0.0000000000000001) }
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bindata-1.4.3 spec/float_spec.rb
bindata-1.4.2 spec/float_spec.rb
bindata-1.4.1 spec/float_spec.rb
bindata-1.4.0 spec/float_spec.rb
bindata-1.3.1 spec/float_spec.rb