Sha256: f029b1bf48fe4426a0354933f248c654d733bb0e9cf1472a4d68f651a0fef067

Contents?: true

Size: 1.26 KB

Versions: 21

Compression:

Stored size: 1.26 KB

Contents

#!/usr/bin/env ruby

require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))

module FloatTest
  def test_num_bytes
    @obj.num_bytes.must_equal 4
  end

  def test_writing_then_reading
    @obj.value_read_from_written.must_be_close_to Math::PI, 0.000001
  end
end

module DoubleTest
  def test_num_bytes
    @obj.num_bytes.must_equal 8
  end

  def test_writing_then_reading
    @obj.value_read_from_written.must_be_close_to Math::PI, 0.0000000000000001
  end
end

describe "A FloatLe" do
  include FloatTest

  before do
    @obj = BinData::FloatLe.new(Math::PI)
  end

  it "#to_binary_s" do
    @obj.to_binary_s.must_equal_binary [Math::PI].pack('e')
  end
end

describe "A FloatBe" do
  include FloatTest

  before do
    @obj = BinData::FloatBe.new(Math::PI)
  end

  it "#to_binary_s" do
    @obj.to_binary_s.must_equal_binary [Math::PI].pack('g')
  end
end

describe "A DoubleLe" do
  include DoubleTest

  before do
    @obj = BinData::DoubleLe.new(Math::PI)
  end

  it "#to_binary_s" do
    @obj.to_binary_s.must_equal_binary [Math::PI].pack('E')
  end
end


describe "A DoubleBe" do
  include DoubleTest

  before do
    @obj = BinData::DoubleBe.new(Math::PI)
  end

  it "#to_binary_s" do
    @obj.to_binary_s.must_equal_binary [Math::PI].pack('G')
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
bindata-2.4.13 test/float_test.rb
bindata-2.4.12 test/float_test.rb
bindata-2.4.11 test/float_test.rb
bindata-2.4.10 test/float_test.rb
bindata-2.4.9 test/float_test.rb
bindata-2.4.8 test/float_test.rb
bindata-2.4.7 test/float_test.rb
bindata-2.4.6 test/float_test.rb
bindata-2.4.5 test/float_test.rb
bindata-2.4.4 test/float_test.rb
bindata-2.4.3 test/float_test.rb
bindata-2.4.2 test/float_test.rb
bindata-2.4.1 test/float_test.rb
bindata-2.4.0 test/float_test.rb
bindata-2.3.5 test/float_test.rb
bindata-2.3.4 test/float_test.rb
bindata-2.3.3 test/float_test.rb
bindata-2.3.2 test/float_test.rb
bindata-2.3.1 test/float_test.rb
bindata-2.3.0 test/float_test.rb