From 9db6fb5ce56ee2e911944377edb02cb493e428b1 Mon Sep 17 00:00:00 2001 From: akr Date: Thu, 1 Apr 2004 01:53:32 +0000 Subject: [PATCH] add test_pack_U. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_pack.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index 863dfbe82f..4003004c7f 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -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,1], "\000\000\000\001\000\000\000\001\000\000\000\001".unpack('N*') 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