PageRenderTime 41ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/test/mri/-ext-/bignum/test_str2big.rb

http://github.com/jruby/jruby
Ruby | 38 lines | 30 code | 7 blank | 1 comment | 0 complexity | 40c135fbca823fca077f52ee88b3b10d MD5 | raw file
Possible License(s): GPL-3.0, BSD-3-Clause, GPL-2.0, JSON, LGPL-2.1
  1. # frozen_string_literal: false
  2. require 'test/unit'
  3. require "-test-/bignum"
  4. class TestBignum < Test::Unit::TestCase
  5. class TestStr2big < Test::Unit::TestCase
  6. SIZEOF_BDIGIT = Bignum::SIZEOF_BDIGIT
  7. BITSPERDIG = Bignum::BITSPERDIG
  8. BDIGMAX = (1 << BITSPERDIG) - 1
  9. def test_str2big_poweroftwo
  10. s = "1" + "0" * 1000
  11. n = 16 ** 1000
  12. assert_equal(n, s.str2big_poweroftwo(16, true))
  13. end
  14. def test_str2big_normal
  15. s = "1" + "0" * 1000
  16. n = 10 ** 1000
  17. assert_equal(n, s.str2big_normal(10, true))
  18. end
  19. def test_str2big_karatsuba
  20. s = "1" + "0" * 1000
  21. n = 10 ** 1000
  22. assert_equal(n, s.str2big_karatsuba(10, true))
  23. end
  24. def test_str2big_gmp
  25. s = "1" + "0" * 1000
  26. n = 10 ** 1000
  27. assert_equal(n, s.str2big_gmp(10, true))
  28. rescue NotImplementedError
  29. end
  30. end
  31. end