Sha256: f13654dc3cc11c8a91d1f12b14d5cb8423ecd69699afca9d0246b6c96863e2e0
Contents?: true
Size: 1.99 KB
Versions: 1
Compression:
Stored size: 1.99 KB
Contents
require 'spec_helper' require 'ronin/code/asm/memory_operand' require 'ronin/code/asm/register' describe Ronin::Code::ASM::MemoryOperand do let(:register) { Ronin::Code::ASM::Register.new(:eax, 4) } describe "#initialize" do it { expect(subject.base).to be_nil } it { expect(subject.offset).to eq(0) } it { expect(subject.index).to be_nil } it { expect(subject.scale).to eq(1) } it "must only accept nil and a Register for base" do expect { described_class.new(Object.new) }.to raise_error(TypeError) end it "must only accept Integers for offset" do expect { described_class.new(register,2.0) }.to raise_error(TypeError) end it "must only accept nil and a Register for index" do expect { described_class.new(register,0,Object.new) }.to raise_error(TypeError) end it "must only accept Integers for offset" do expect { described_class.new(register,0,nil,2.0) }.to raise_error(TypeError) end end describe "#+" do let(:operand) { described_class.new(register,4,register,2) } subject { operand + 4 } it "must add to offset" do expect(subject.offset).to eq(8) end it "must not change base, index or scale" do expect(subject.base).to eq(operand.base) expect(subject.index).to eq(operand.index) expect(subject.scale).to eq(operand.scale) end end describe "#-" do let(:operand) { described_class.new(register,4,register,2) } subject { operand - 2 } it "must subtract from offset" do expect(subject.offset).to eq(2) end it "must not change base, index or scale" do expect(subject.base).to eq(operand.base) expect(subject.index).to eq(operand.index) expect(subject.scale).to eq(operand.scale) end end describe "#width" do subject { described_class.new(register,10) } it "must return the width of base" do expect(subject.width).to eq(register.width) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ronin-code-asm-1.0.0.beta1 | spec/memory_operand_spec.rb |