mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
add test_pack_U.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b3009ced33
commit
9db6fb5ce5
1 changed files with 11 additions and 0 deletions
|
@ -42,4 +42,15 @@ class TestPack < Test::Unit::TestCase
|
||||||
assert_equal [1,1], "\000\000\000\001\000\000\000\001".unpack('N*')
|
assert_equal [1,1], "\000\000\000\001\000\000\000\001".unpack('N*')
|
||||||
assert_equal [1,1,1], "\000\000\000\001\000\000\000\001\000\000\000\001".unpack('N*')
|
assert_equal [1,1,1], "\000\000\000\001\000\000\000\001\000\000\000\001".unpack('N*')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_pack_U
|
||||||
|
assert_raises(RangeError) { [-0x40000001].pack("U") }
|
||||||
|
assert_raises(RangeError) { [-0x40000000].pack("U") }
|
||||||
|
assert_raises(RangeError) { [-1].pack("U") }
|
||||||
|
assert_equal "\000", [0].pack("U")
|
||||||
|
assert_equal "\374\277\277\277\277\277", [0x3fffffff].pack("U")
|
||||||
|
assert_equal "\375\200\200\200\200\200", [0x40000000].pack("U")
|
||||||
|
assert_equal "\375\277\277\277\277\277", [0x7fffffff].pack("U")
|
||||||
|
assert_raises(RangeError) { [0x80000000].pack("U") }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue