PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/test/-ext-/bignum/test_big2str.rb

http://github.com/ruby/ruby
Ruby | 30 lines | 23 code | 6 blank | 1 comment | 0 complexity | 0f223cf5fec470d1a93cedd78185ceb2 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, AGPL-3.0
  1. # frozen_string_literal: false
  2. require 'test/unit'
  3. require "-test-/bignum"
  4. class Test_Bignum < Test::Unit::TestCase
  5. class TestBig2str < Test::Unit::TestCase
  6. SIZEOF_BDIGIT = Integer::SIZEOF_BDIGIT
  7. BITSPERDIG = Integer::BITSPERDIG
  8. BDIGMAX = (1 << BITSPERDIG) - 1
  9. def test_big2str_generic
  10. x = 10**1000
  11. assert_equal("1" + "0" * 1000, x.big2str_generic(10))
  12. end
  13. def test_big2str_poweroftwo
  14. e = BITSPERDIG*2
  15. x = 0b10**e
  16. assert_equal("1" + "0" * e, x.big2str_poweroftwo(2))
  17. end
  18. def test_big2str_gmp
  19. x = 10**1000
  20. assert_equal("1" + "0" * 1000, x.big2str_gmp(10))
  21. rescue NotImplementedError
  22. end
  23. end
  24. end