* pack.c: Support Q! and q! for long long.

(natstr): Moved to toplevel.  Add q and Q if there is long long type.
  (endstr): Moved to toplevel.
  (NATINT_PACK): Consider long long.
  (NATINT_LEN_Q): New macro.
  (pack_pack): Support Q! and q!.
  (pack_unpack): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2013-04-02 11:28:57 +00:00
parent 6d0c59f156
commit 583c8e8915
4 changed files with 65 additions and 17 deletions

View file

@ -403,8 +403,15 @@ class TestPack < Test::Unit::TestCase
assert_equal([578437695752307201, -506097522914230529], s2.unpack("q*"))
assert_equal([578437695752307201, 17940646550795321087], s1.unpack("Q*"))
s1 = [578437695752307201, -506097522914230529].pack("q!*")
s2 = [578437695752307201, 17940646550795321087].pack("Q!*")
assert_equal([578437695752307201, -506097522914230529], s2.unpack("q!*"))
assert_equal([578437695752307201, 17940646550795321087], s1.unpack("Q!*"))
assert_equal(8, [1].pack("q").bytesize)
assert_equal(8, [1].pack("Q").bytesize)
assert_operator(8, :<=, [1].pack("q!").bytesize)
assert_operator(8, :<=, [1].pack("Q!").bytesize)
end
def test_pack_unpack_nN