Sha256: 85a4fb545c9e504493877ba81c8d3847d98e4406223539d2d8073a23d7358751

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require 'evoasm/test'
require 'evoasm/x64/cpu_state'
require 'evoasm/buffer'

module Evoasm
  module X64
    class ParametersTest < Minitest::Test
      def setup
        @parameters = Parameters.new
        @basic_parameters = Parameters.new basic: true
      end

      def test_basic
        refute @parameters.basic?
        assert @basic_parameters.basic?
      end

      def test_register_parameter
        @parameters[:reg0] = :a
        assert_equal :a, @parameters[:reg0]

        @basic_parameters[:reg0] = :a
        assert_equal :a, @basic_parameters[:reg0]
      end

      def test_boolean_parameter
        @parameters[:force_long_vex?] = true
        assert_equal true, @parameters[:force_long_vex?]
      end

      def test_int_parameter
        @parameters[:disp] = 10
        assert_equal 10, @parameters[:disp]

        assert_raises ArgumentError do
          @parameters[:disp] = 10000000000000
        end
      end

      def test_scale_parameter
        @parameters[:scale] = 4
        assert_equal 4, @parameters[:scale]

        assert_raises ArgumentError do
          @parameters[:scale] = 5
        end
      end

      def test_addr_size_parameter
        @parameters[:addr_size] = 32
        assert_equal 32, @parameters[:addr_size]

        assert_raises ArgumentError do
          @parameters[:addr_size] = 2
        end
      end

      def test_invalid_parameter
        assert_raises do
          @parameters[:foo] = 42
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
evoasm-0.1.0.pre2 test/unit/evoasm/x64/parameters_test.rb