diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-26 13:05:08 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-26 13:05:08 +0000 |
commit | bfc502fe517dee050085df406c72f61593a9d2fa (patch) | |
tree | ee4003091d3c27e617967b8087bb59067b32c8a9 /test/ruby/test_integer.rb | |
parent | 35adbb5f8890cfba80b35f3042f1fb45f91c8790 (diff) | |
download | ruby-bfc502fe517dee050085df406c72f61593a9d2fa.tar.gz |
more tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_integer.rb')
-rw-r--r-- | test/ruby/test_integer.rb | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb index 55dbf35cc7..82a73345d7 100644 --- a/test/ruby/test_integer.rb +++ b/test/ruby/test_integer.rb @@ -592,10 +592,10 @@ class TestInteger < Test::Unit::TestCase end def test_pack - %w[c C s S s! S! i I l L l! L! q Q].each {|template| + %w[c C s S s! S! i I i! I! l L l! L! q Q n N v V].each {|template| size = [0].pack(template).size mask = (1 << (size * 8)) - 1 - if /[A-Z]/ =~ template + if /[A-Znv]/ =~ template min = 0 max = (1 << (size * 8))-1 else @@ -613,6 +613,26 @@ class TestInteger < Test::Unit::TestCase } end + def test_pack_ber + template = "w" + VS.reverse_each {|a| + next if a < 0 + s = [a].pack(template) + b = s.unpack(template)[0] + assert_equal(a, b, "[#{a}].pack(#{template.dump}).unpack(#{template.dump})") + } + end + + def test_pack_utf8 + template = "U" + VS.reverse_each {|a| + next if a < 0 || 0x7fffffff < a + s = [a].pack(template) + b = s.unpack(template)[0] + assert_equal(a, b, "[#{a}].pack(#{template.dump}).unpack(#{template.dump})") + } + end + def test_Integer assert_raise(ArgumentError) {Integer("0x-1")} assert_raise(ArgumentError) {Integer("-0x-1")} |