Sha256: 668291486f15b486dbd9a3f119f04146aedfb85d3842ef3d262256821ebba3a2

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

require 'spec_helper'

require 'ronin/asm/immediate_operand'

describe ImmediateOperand do
  let(:value) { 0xff }

  describe "#initialize" do
    context "with a width" do
      let(:width) { 2 }

      subject { described_class.new(value,width) }

      it "should set the width" do
        subject.width.should == width
      end
    end

    describe "default width for" do
      context "0x100000000 .. 0xffffffffffffffff" do
        subject { described_class.new(0xffffffffffffffff).width }

        it { should == 8 }
      end

      context "-0x800000000 .. -0x7fffffffffffffff" do
        subject { described_class.new(-0x7fffffffffffffff).width }

        it { should == 8 }
      end

      context "0x10000 .. 0xffffffff" do
        subject { described_class.new(0xffffffff).width }

        it { should == 4 }
      end

      context "-0x80000 .. -0x7fffffff" do
        subject { described_class.new(-0x7fffffff).width }

        it { should == 4 }
      end

      context "0x100 .. 0xffff" do
        subject { described_class.new(0xffff).width }

        it { should == 2 }
      end

      context "-0x80 .. -0x7fff" do
        subject { described_class.new(-0x7fff).width }

        it { should == 2 }
      end

      context "0x0 .. 0xff" do
        subject { described_class.new(0xff).width }

        it { should == 1 }
      end

      context "0x0 .. -0x7f" do
        subject { described_class.new(-0x7f).width }

        it { should == 1 }
      end
    end
  end

  describe "#to_i" do
    subject { described_class.new(value) }

    it "should return the value" do
      subject.to_i.should == value
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ronin-asm-0.1.0 spec/immediate_operand_spec.rb