summaryrefslogtreecommitdiff
path: root/test/ruby/test_integer.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-26 13:05:08 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-26 13:05:08 +0000
commitbfc502fe517dee050085df406c72f61593a9d2fa (patch)
treeee4003091d3c27e617967b8087bb59067b32c8a9 /test/ruby/test_integer.rb
parent35adbb5f8890cfba80b35f3042f1fb45f91c8790 (diff)
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.rb24
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")}