Sha256: e6adb980380738e2727a47edb3bb9bbe79a9e5fb0b2f8eec2fafdf03dacdedd7

Contents?: true

Size: 875 Bytes

Versions: 2

Compression:

Stored size: 875 Bytes

Contents

require './test_helper'

class TC_Hashes < Test::Unit::TestCase
  def setup
  end
  
  def test_z_hashes
    h = {}
    h[GMP::Z(131)] = [GMP::Z(41), GMP::Z(43), GMP::Z(47)]
    assert(h[GMP::Z(131)] != nil, "Newly created GMP::Zs should hash equally if they are equal.")
    assert(h[GMP::Z(59)].nil?,    "Newly created GMP::Zs should hash differently if they are different.")
    10.times do
      assert(GMP::Z(73).hash == GMP::Z(73).hash)
    end
    
    100.times do |i|
      assert(GMP::Z(101).hash != GMP::Z(i).hash)
    end
    
    # GMP::Z(5) and "5" might (I think, 'do') hash the same, but should not be equal
    assert(! GMP::Z(101).eql?("101"))
    
    h["127"] = "String"
    h[GMP::Z(127)] = "GMP::Z"
    assert(h["127"] != "GMP::Z")
    assert(h[GMP::Z(127)] != "String")
    assert(h[GMP::Z(127)] == "GMP::Z")
    assert(h["127"] == "String")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gmp-0.5.41 test/tc_hashes.rb
gmp-0.5.41-x86-mingw32 test/tc_hashes.rb