Sha256: ec740b29dea6d26330272364fb66aa6dc65bdacd8e72cb0b7e312087fc7407c1

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

require './test_helper'

class TC_Z_Exponentiation < Test::Unit::TestCase
  def setup
    @a = GMP::Z.new(100)
    @b = GMP::Z.new(16)
    @c = @a**5
  end
  
  def test_exponentiation
    assert_equal(@a**5, GMP::Z(10000000000),                          "GMP::Z should **(Fixnum) correctly")
    assert_equal(GMP::Z("100000000000000000000000000000000"), @a**@b, "GMP::Z should **(GMP::Z) correctly")
    assert_equal(GMP::Z(65536), 2**@b,                                "Fixnum should **(GMP::Z) correctly")
  end
  
  def test_powmod
    assert_equal(GMP::Z(16), @a.powmod(2,256),  "(a : GMP::Z).powmod((b : Fixnum), (c : Fixnum)) should work correctly")
    assert_equal(GMP::Z(76), @b.powmod(10,@a),  "(a : GMP::Z).powmod((b : Fixnum), (c : GMP::Z)) should work correctly")
    assert_equal(GMP::Z(0), @a.powmod(@b,256),  "(a : GMP::Z).powmod((b : GMP::Z), (c : Fixnum)) should work correctly")
    assert_equal(GMP::Z(0), @a.powmod(@b,@c), "(a : GMP::Z).powmod((b : GMP::Z), (c : GMP::Z)) should work correctly")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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