Sha256: 4406ca17f670eeb87de20044b622c51ec87baa98eb65af9b9a40b51073c5bc37

Contents?: true

Size: 868 Bytes

Versions: 1

Compression:

Stored size: 868 Bytes

Contents

# encoding: US-ASCII

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
        expect(subject.pack('E')).to eq(packed)
      end
    end

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

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