diff options
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")} |