PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/gems/facets-2.4.5/test/core/hash/test_keys.rb

https://bitbucket.org/mediashelf/fedora-migrator
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
  1. require 'facets/hash/keys'
  2. require 'test/unit'
  3. class TC_Hash_Keys < Test::Unit::TestCase
  4. def test_each_with_key
  5. h1 = { :a=>1, :b=>2 }
  6. h2 = {}
  7. h1.each_with_key { |v,k| h2[v] = k }
  8. assert_equal( {1=>:a, 2=>:b}, h2 )
  9. end
  10. def test_has_keys?
  11. assert( { :a=>1,:b=>2,:c=>3 }.has_keys?(:a,:b) )
  12. assert( ! { :a=>1,:b=>2,:c=>3 }.has_keys?(:a,:b,:d) )
  13. end
  14. def test_has_only_keys?
  15. assert( { :a=>1,:b=>2,:c=>3 }.has_only_keys?(:a,:b,:c) )
  16. assert( ! { :a=>1,:b=>2,:c=>3 }.has_only_keys?(:a,:b) )
  17. end
  18. end