aboutsummaryrefslogtreecommitdiffstats
path: root/test/-ext-/bignum
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-03 03:50:15 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-03 03:50:15 +0000
commit0b2413b471e5a23c619078f75b191c38619b35df (patch)
tree191b9cd91cabad6d75834ec5a4b4f767fcebf3dd /test/-ext-/bignum
parent1df73dd9adb3c11af6a5a3dc5839b8f87e8070a0 (diff)
downloadruby-0b2413b471e5a23c619078f75b191c38619b35df.tar.gz
* bignum.c (rb_str2big_poweroftwo): New function.
(rb_str2big_normal): Ditto. (rb_str2big_karatsuba): Ditto. * internal.h (rb_str2big_poweroftwo): Declared. (rb_str2big_normal): Ditto. (rb_str2big_karatsuba): Ditto. * ext/-test-/bignum/str2big.c: New file. * test/-ext-/bignum/test_str2big.rb: New file. * ext/-test-/bignum/depend: Add the dependency for str2big.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/-ext-/bignum')
-rw-r--r--test/-ext-/bignum/test_str2big.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/-ext-/bignum/test_str2big.rb b/test/-ext-/bignum/test_str2big.rb
new file mode 100644
index 0000000000..ac55c78082
--- /dev/null
+++ b/test/-ext-/bignum/test_str2big.rb
@@ -0,0 +1,30 @@
+require 'test/unit'
+require "-test-/bignum"
+
+class TestBignum < Test::Unit::TestCase
+ class TestStr2big < Test::Unit::TestCase
+
+ SIZEOF_BDIGITS = Bignum::SIZEOF_BDIGITS
+ BITSPERDIG = Bignum::BITSPERDIG
+ BDIGMAX = (1 << BITSPERDIG) - 1
+
+ def test_str2big_poweroftwo
+ s = "1" + "0" * 1000
+ n = 16 ** 1000
+ assert_equal(n, s.str2big_poweroftwo(16, true))
+ end
+
+ def test_str2big_normal
+ s = "1" + "0" * 1000
+ n = 10 ** 1000
+ assert_equal(n, s.str2big_normal(10, true))
+ end
+
+ def test_str2big_karatsuba
+ s = "1" + "0" * 1000
+ n = 10 ** 1000
+ assert_equal(n, s.str2big_karatsuba(10, true))
+ end
+
+ end
+end