summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorTomoyuki Sahara <[email protected]>2014-12-12 12:01:58 +0900
committerTomoyuki Sahara <[email protected]>2014-12-12 12:01:58 +0900
commit669fe705cc490eedd2f4a09ed558f8186813d7a5 (patch)
treed85018b11517f106cfe290a605f543efc8014c95 /test
parent5b65ca3ebb3fb718138e1d23c4881a129b8606e2 (diff)
downloadmruby-669fe705cc490eedd2f4a09ed558f8186813d7a5.tar.gz
mruby-669fe705cc490eedd2f4a09ed558f8186813d7a5.zip
"i" and "I".
Diffstat (limited to 'test')
-rw-r--r--test/pack.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/pack.rb b/test/pack.rb
index c7899e2d7..5e9932f4f 100644
--- a/test/pack.rb
+++ b/test/pack.rb
@@ -121,3 +121,27 @@ assert 'pack double' do
assert_pack 'D', "@\b\x00\x00\x00\x00\x00\x00", [3.0]
end
end
+
+assert 'pack/unpack "i"' do
+ int_size = [0].pack('i').size
+ raise "pack('i').size is too small (#{int_size})" if int_size < 2
+
+ if PACK_IS_LITTLE_ENDIAN
+ str = "\xC7\xCF" + "\xFF" * (int_size-2)
+ else
+ str = "\xFF" * (int_size-2) + "\xC7\xCF"
+ end
+ assert_pack 'i', str, [-12345]
+end
+
+assert 'pack/unpack "I"' do
+ uint_size = [0].pack('I').size
+ raise "pack('I').size is too small (#{uint_size})" if uint_size < 2
+
+ if PACK_IS_LITTLE_ENDIAN
+ str = "\x39\x30" + "\0" * (uint_size-2)
+ else
+ str = "\0" * (uint_size-2) + "\x39\x30"
+ end
+ assert_pack 'I', str, [12345]
+end