/vendor/gems/facets-2.4.5/test/core/hash/test_keys.rb
Ruby | 24 lines | 18 code | 6 blank | 0 comment | 0 complexity | fc24c2f9dab707763e8c525ad98e6147 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, IPL-1.0, AGPL-1.0, LGPL-3.0
- require 'facets/hash/keys'
- require 'test/unit'
- class TC_Hash_Keys < Test::Unit::TestCase
- def test_each_with_key
- h1 = { :a=>1, :b=>2 }
- h2 = {}
- h1.each_with_key { |v,k| h2[v] = k }
- assert_equal( {1=>:a, 2=>:b}, h2 )
- end
- def test_has_keys?
- assert( { :a=>1,:b=>2,:c=>3 }.has_keys?(:a,:b) )
- assert( ! { :a=>1,:b=>2,:c=>3 }.has_keys?(:a,:b,:d) )
- end
- def test_has_only_keys?
- assert( { :a=>1,:b=>2,:c=>3 }.has_only_keys?(:a,:b,:c) )
- assert( ! { :a=>1,:b=>2,:c=>3 }.has_only_keys?(:a,:b) )
- end
- end