Sha256: 89980ba53a69325dbb7f9f50c20aa942e45d7d3e12b2b5a1f4c92bd0c5967a02

Contents?: true

Size: 1.61 KB

Versions: 9

Compression:

Stored size: 1.61 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))

class TC_logical_roots < Test::Unit::TestCase
  def setup
    @a = GMP::Z.new(100)
    @b = GMP::Z.new( 27)
    @c = GMP::Z.new( 99)
  end
  
  def test_parity
    assert  @a.even?, "GMP::Z should even? correctly."
    assert !@b.even?, "GMP::Z should even? correctly."
    assert !@c.even?, "GMP::Z should even? correctly."
    assert !@a.odd?,  "GMP::Z should odd? correctly."
    assert  @b.odd?,  "GMP::Z should odd? correctly."
    assert  @c.odd?,  "GMP::Z should odd? correctly."
  end
  
  def test_square
    assert  @a.square?, "GMP::Z should square? correctly."
    assert !@b.square?, "GMP::Z should square? correctly."
    assert !@c.square?, "GMP::Z should square? correctly."
  end
  
  def test_power
    assert  @a.power?, "GMP::Z should power? correctly."
    assert  @b.power?, "GMP::Z should power? correctly."
    assert !@c.power?, "GMP::Z should power? correctly."
  end
  
  def sqrtrem
    assert_equal([10,  0], @a.sqrtrem, "GMP::Z should sqrtrem correctly.")
    assert_equal([ 5,  2], @b.sqrtrem, "GMP::Z should sqrtrem correctly.")
    assert_equal([ 9, 18], @c.sqrtrem, "GMP::Z should sqrtrem correctly.")
  end
  
  def sqrt
    assert_equal(10, @a.sqrt, "GMP::Z should sqrt correctly.")
    assert_equal( 5, @b.sqrt, "GMP::Z should sqrt correctly.")
    assert_equal( 9, @c.sqrt, "GMP::Z should sqrt correctly.")
  end
  
  def root
    assert_equal(4, @a.root(3), "GMP::Z should root correctly.")
    assert_equal(3, @b.root(3), "GMP::Z should root correctly.")
    assert_equal(4, @c.root(3), "GMP::Z should root correctly.")
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gmp-0.6.47 test/tc_logical_roots.rb
gmp-0.6.43 test/tc_logical_roots.rb
gmp-0.6.41 test/tc_logical_roots.rb
gmp-0.6.31 test/tc_logical_roots.rb
gmp-0.6.19 test/tc_logical_roots.rb
gmp-0.6.17 test/tc_logical_roots.rb
gmp-0.6.13 test/tc_logical_roots.rb
gmp-0.6.7 test/tc_logical_roots.rb
gmp-0.5.47 test/tc_logical_roots.rb