summaryrefslogtreecommitdiff
path: root/test/-ext-/bignum
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-09 05:53:00 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-09 05:53:00 +0000
commit837392b45260785a8ccc13aceba5be90e067a974 (patch)
tree047e5d63437c4e2f439dd991d1c76ae8da98520d /test/-ext-/bignum
parentf6757f080c9201de6fbd1d25b663c37341ef2305 (diff)
* bignum.c (rb_integer_pack): numwords_allocated argument removed.
* internal.h (rb_integer_pack): Follow the above change. * hash.c (rb_hash): Ditto. * time.c (v2w_bignum): Ditto. * pack.c (pack_pack): Ditto. * random.c (int_pair_to_real_inclusive): Ditto. (rand_init): Ditto. (random_load): Ditto. (limited_big_rand): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/-ext-/bignum')
-rw-r--r--test/-ext-/bignum/test_pack.rb44
1 files changed, 22 insertions, 22 deletions
diff --git a/test/-ext-/bignum/test_pack.rb b/test/-ext-/bignum/test_pack.rb
index 17d364c2c9b..8b4f60d24d8 100644
--- a/test/-ext-/bignum/test_pack.rb
+++ b/test/-ext-/bignum/test_pack.rb
@@ -15,26 +15,26 @@ class TestBignum < Test::Unit::TestCase
BIG_ENDIAN = Integer::INTEGER_PACK_BIG_ENDIAN
def test_pack_zero
- assert_equal([0, "", 0], 0.test_pack(nil, 1, 0, BIG_ENDIAN))
+ assert_equal([0, "", 0], 0.test_pack("", 1, 0, BIG_ENDIAN))
end
def test_pack_argument_check
- assert_raise(ArgumentError) { 0.test_pack(nil, 1, 0, MSBYTE_FIRST) }
- assert_raise(ArgumentError) { 0.test_pack(nil, 1, 0, MSWORD_FIRST) }
- assert_raise(ArgumentError) { 0.test_pack(nil, 0, 0, BIG_ENDIAN) }
- assert_raise(ArgumentError) { 0.test_pack(nil, 1, 8, BIG_ENDIAN) }
+ assert_raise(ArgumentError) { 0.test_pack("", 1, 0, MSBYTE_FIRST) }
+ assert_raise(ArgumentError) { 0.test_pack("", 1, 0, MSWORD_FIRST) }
+ assert_raise(ArgumentError) { 0.test_pack("", 0, 0, BIG_ENDIAN) }
+ assert_raise(ArgumentError) { 0.test_pack("", 1, 8, BIG_ENDIAN) }
# assume sizeof(ssize_t) == sizeof(intptr_t)
- assert_raise(ArgumentError) { 0.test_pack(nil, 1 << ([""].pack("p").length * 8 - 1), 0, BIG_ENDIAN) }
+ assert_raise(ArgumentError) { 0.test_pack("", 1 << ([""].pack("p").length * 8 - 1), 0, BIG_ENDIAN) }
end
def test_pack_wordsize
- assert_equal([1, "\x01", 1], 1.test_pack(nil, 1, 0, BIG_ENDIAN))
- assert_equal([1, "\x00\x01", 1], 1.test_pack(nil, 2, 0, BIG_ENDIAN))
- assert_equal([1, "\x00\x00\x01", 1], 1.test_pack(nil, 3, 0, BIG_ENDIAN))
- assert_equal([1, "\x01", 1], 1.test_pack(nil, 1, 0, LITTLE_ENDIAN))
- assert_equal([1, "\x01\x00", 1], 1.test_pack(nil, 2, 0, LITTLE_ENDIAN))
- assert_equal([1, "\x01\x00\x00", 1], 1.test_pack(nil, 3, 0, LITTLE_ENDIAN))
+ assert_equal([1, "\x01", 1], 1.test_pack("x", 1, 0, BIG_ENDIAN))
+ assert_equal([1, "\x00\x01", 1], 1.test_pack("xx", 2, 0, BIG_ENDIAN))
+ assert_equal([1, "\x00\x00\x01", 1], 1.test_pack("xxx", 3, 0, BIG_ENDIAN))
+ assert_equal([1, "\x01", 1], 1.test_pack("x", 1, 0, LITTLE_ENDIAN))
+ assert_equal([1, "\x01\x00", 1], 1.test_pack("xx", 2, 0, LITTLE_ENDIAN))
+ assert_equal([1, "\x01\x00\x00", 1], 1.test_pack("xxx", 3, 0, LITTLE_ENDIAN))
end
def test_pack_fixed_buffer
@@ -51,25 +51,25 @@ class TestBignum < Test::Unit::TestCase
end
def test_pack_wordorder_and_endian
- assert_equal([1, "\x12\x34\x56\x78", 2], 0x12345678.test_pack(nil, 2, 0, MSWORD_FIRST|MSBYTE_FIRST))
- assert_equal([1, "\x34\x12\x78\x56", 2], 0x12345678.test_pack(nil, 2, 0, MSWORD_FIRST|LSBYTE_FIRST))
- assert_equal([1, "\x56\x78\x12\x34", 2], 0x12345678.test_pack(nil, 2, 0, LSWORD_FIRST|MSBYTE_FIRST))
- assert_equal([1, "\x78\x56\x34\x12", 2], 0x12345678.test_pack(nil, 2, 0, LSWORD_FIRST|LSBYTE_FIRST))
+ assert_equal([1, "\x12\x34\x56\x78", 2], 0x12345678.test_pack("xxxx", 2, 0, MSWORD_FIRST|MSBYTE_FIRST))
+ assert_equal([1, "\x34\x12\x78\x56", 2], 0x12345678.test_pack("xxxx", 2, 0, MSWORD_FIRST|LSBYTE_FIRST))
+ assert_equal([1, "\x56\x78\x12\x34", 2], 0x12345678.test_pack("xxxx", 2, 0, LSWORD_FIRST|MSBYTE_FIRST))
+ assert_equal([1, "\x78\x56\x34\x12", 2], 0x12345678.test_pack("xxxx", 2, 0, LSWORD_FIRST|LSBYTE_FIRST))
end
def test_pack_native_endian
- assert_equal([1, [0x1234].pack("S!"), 1], 0x1234.test_pack(nil, 2, 0, MSWORD_FIRST|NATIVE_BYTE_ORDER))
+ assert_equal([1, [0x1234].pack("S!"), 1], 0x1234.test_pack("xx", 2, 0, MSWORD_FIRST|NATIVE_BYTE_ORDER))
end
def test_pack_nail
- assert_equal([1, "\x01\x00\x00\x00\x01\x01", 6], 0b100011.test_pack(nil, 1, 7, BIG_ENDIAN))
- assert_equal([1, "\x01\x02\x03\x04\x05\x06\x07\x08", 8], 0x12345678.test_pack(nil, 1, 4, BIG_ENDIAN))
- assert_equal([1, "\x00\x12\x00\x34\x00\x56\x00\x78", 4], 0x12345678.test_pack(nil, 2, 8, BIG_ENDIAN))
+ assert_equal([1, "\x01\x00\x00\x00\x01\x01", 6], 0b100011.test_pack("xxxxxx", 1, 7, BIG_ENDIAN))
+ assert_equal([1, "\x01\x02\x03\x04\x05\x06\x07\x08", 8], 0x12345678.test_pack("xxxxxxxx", 1, 4, BIG_ENDIAN))
+ assert_equal([1, "\x00\x12\x00\x34\x00\x56\x00\x78", 4], 0x12345678.test_pack("xxxxxxxx", 2, 8, BIG_ENDIAN))
end
def test_pack_sign
- assert_equal([-1, "\x01", 1], (-1).test_pack(nil, 1, 0, BIG_ENDIAN))
- assert_equal([-1, "\x80\x70\x60\x50\x40\x30\x20\x10", 8], (-0x8070605040302010).test_pack(nil, 1, 0, BIG_ENDIAN))
+ assert_equal([-1, "\x01", 1], (-1).test_pack("x", 1, 0, BIG_ENDIAN))
+ assert_equal([-1, "\x80\x70\x60\x50\x40\x30\x20\x10", 8], (-0x8070605040302010).test_pack("xxxxxxxx", 1, 0, BIG_ENDIAN))
end
def test_unpack_zero