Sha256: fc203cd18d9cea4d4e6a9eebdc08daac97c187674879e2202a730abe7bcedbd5

Contents?: true

Size: 1.68 KB

Versions: 5

Compression:

Stored size: 1.68 KB

Contents

require 'spec_helper'
require 'ronin/arch'

describe Arch do
  it "should require a name, endian and address_length attributes" do
    arch = Arch.new
    arch.should_not be_valid
    
    arch.name = 'future'
    arch.should_not be_valid
   
    arch.endian = 'little'
    arch.should_not be_valid

    arch.address_length = 4
    arch.should be_valid
  end

  it "should require a unique name" do
    first_arch = Arch.create(:name => 'cats',
                              :endian => 'little',
                              :address_length => 4)
    first_arch.should be_valid

    second_arch = Arch.new(:name => 'cats',
                            :endian => 'big',
                            :address_length => 4)
    second_arch.should_not be_valid
  end

  it "should require either 'little' or 'big' for the endian attribute" do
    arch = Arch.new(:name => 'test',
                     :endian => 'lol',
                     :address_length => 4)
    arch.should_not be_valid

    arch.endian = 'little'
    arch.should be_valid

    arch.endian = 'big'
    arch.should be_valid
  end

  it "should require a numeric valid for the address_length attribute" do
    arch = Arch.new(:name => 'test2',
                     :endian => 'big',
                     :address_length => 'x')
    arch.should_not be_valid

    arch.address_length = '4'
    arch.should be_valid

    arch.address_length = 4
    arch.should be_valid
  end

  it "should provide built-in archs" do
    Arch.i386.should_not be_nil
  end

  it "should implicitly splat the endian and address length" do
    endian, address_length = Arch.i386

    endian.should == Arch.i386.endian
    address_length.should == Arch.i386.address_length
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ronin-1.0.0 spec/arch_spec.rb
ronin-1.0.0.rc3 spec/arch_spec.rb
ronin-1.0.0.rc2 spec/arch_spec.rb
ronin-1.0.0.rc1 spec/arch_spec.rb
ronin-1.0.0.pre4 spec/arch_spec.rb