Sha256: 0854206674f04dadaf7adc144816efc347a7ef876384f2050cb42ebc01d09837

Contents?: true

Size: 1.15 KB

Versions: 13

Compression:

Stored size: 1.15 KB

Contents

require File.expand_path("../../../test_helper", __FILE__)

class COMAbstractEnumTest < Test::Unit::TestCase
  context "setting up the map" do
    setup do
      @enum = VirtualBox::COM::AbstractEnum
      @enum.reset!
    end

    should "set the map up and be able to access it" do
      @enum.map([:a, :b, :c])
      assert_equal :a, @enum[0]
      assert_equal :b, @enum[1]
      assert_equal :c, @enum[2]
      assert_equal [:a, :b, :c], @enum.map
    end

    should "do the reverse mapping of value to index" do
      @enum.map([:a, :b, :c])
      assert_equal 1, @enum.index(:b)
    end

    should "reset the map if another is given" do
      @enum.map([:a])
      @enum.map([:b])
      assert_equal :b, @enum[0]
    end

    should "allow iterating over the enum" do
      array = [:a, :b, :c]
      other_array = []
      @enum.map(array)
      @enum.each do |item|
        other_array << item
      end

      assert_equal array, other_array
    end

    should "include enumerable methods" do
      array = [:a, :b, :c]
      @enum.map(array)

      @enum.each_with_index do |object, index|
        assert_equal array[index], object
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
virtualbox-0.8.6 test/virtualbox/com/abstract_enum_test.rb
virtualbox-0.8.5 test/virtualbox/com/abstract_enum_test.rb
virtualbox-0.8.4 test/virtualbox/com/abstract_enum_test.rb
velir_virtualbox-0.8.4 test/virtualbox/com/abstract_enum_test.rb
virtualbox-0.8.3 test/virtualbox/com/abstract_enum_test.rb
virtualbox-0.8.2 test/virtualbox/com/abstract_enum_test.rb
virtualbox-0.8.1 test/virtualbox/com/abstract_enum_test.rb
virtualbox-0.8.0 test/virtualbox/com/abstract_enum_test.rb
virtualbox-0.7.9 test/virtualbox/com/abstract_enum_test.rb
virtualbox-0.7.8 test/virtualbox/com/abstract_enum_test.rb
virtualbox-0.7.7 test/virtualbox/com/abstract_enum_test.rb
virtualbox-0.7.6 test/virtualbox/com/abstract_enum_test.rb
bbrowning-virtualbox-0.7.6.dev test/virtualbox/com/abstract_enum_test.rb