Sha256: a6281cfd24f41c127174eed141677fa4e3068b4acf57e8e185a635498a99068f
Contents?: true
Size: 980 Bytes
Versions: 7
Compression:
Stored size: 980 Bytes
Contents
require 'facets/to_hash.rb' require 'test/unit' class TestArrayConversion < Test::Unit::TestCase def test_to_h a = [[1,2],[3,4],[5,6]] assert_equal( { 1=>2, 3=>4, 5=>6 }, a.to_h ) end def test_to_h_arrayed a = [[:a,1,2],[:b,3,4],[:c,5,6]] assert_equal( { :a=>[1,2], :b=>[3,4], :c=>[5,6] }, a.to_h(true) ) end #def test_to_hash # a = [:a,:b,:c] # assert_equal( { 0=>:a, 1=>:b, 2=>:c }, a.to_hash ) #end end class TestEnumerableConversion < Test::Unit::TestCase def test_to_h a = [[1,:a],[2,:b],[3,:c]] assert_equal( { 1=>:a, 2=>:b, 3=>:c }, a.to_h ) end #def test_to_hash # a = [:a,:b,:c] # assert_equal( { 0=>:a, 1=>:b, 2=>:c }, a.to_hash ) #end end class TestHashConversion < Test::Unit::TestCase def test_to_h a = { :a => 1, :b => 2, :c => 3 } assert_equal( a, a.to_h ) end end class TestNilClassConversion < Test::Unit::TestCase def test_to_h assert_equal( {}, nil.to_h ) end end
Version data entries
7 entries across 7 versions & 1 rubygems