Sha256: 1530b44f54ed0e7f4a4a07fdae5f485b8c931fdf80fef9d6dfb6dc6676bc6b63

Contents?: true

Size: 840 Bytes

Versions: 1

Compression:

Stored size: 840 Bytes

Contents

require 'spec_helper'
require 'ronin/formatting/extensions/binary/float'

describe Float do
  subject { 0.42 }

  it "should provide Float#pack" do
    should respond_to(:pack)
  end

  describe "#pack" do
    let(:packed) { "\xE1z\x14\xAEG\xE1\xDA?" }

    context "when only given a String" do
      it "should unpack Strings using String#unpack template Strings" do
        subject.pack('E').should == packed
      end
    end

    context "when given a Binary::Template Float type" do
      it "should unpack Strings using Binary::Template" do
        subject.pack(:double_le).should == packed
      end
    end

    context "when given non-Float Binary::Template types" do
      it "should raise an ArgumentError" do
        lambda {
          subject.pack(:int)
        }.should raise_error(ArgumentError)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ronin-support-0.5.1 spec/formatting/binary/float_spec.rb