mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 02:09:59 +00:00
ruby: streaming deserializer test
This commit is contained in:
parent
b10a736744
commit
c9fcf4020f
1 changed files with 8 additions and 4 deletions
|
|
@ -204,9 +204,11 @@ class MessagePackTestFormat < Test::Unit::TestCase
|
|||
|
||||
it "gc mark" do
|
||||
obj = [{["a","b"]=>["c","d"]}, ["e","f"], "d"]
|
||||
num = 4
|
||||
raw = obj.to_msgpack * num
|
||||
pac = MessagePack::Unpacker.new
|
||||
parsed = 0
|
||||
obj.to_msgpack.split(//).each do |b|
|
||||
raw.split(//).each do |b|
|
||||
pac.feed(b)
|
||||
pac.each {|o|
|
||||
GC.start
|
||||
|
|
@ -215,16 +217,18 @@ class MessagePackTestFormat < Test::Unit::TestCase
|
|||
}
|
||||
GC.start
|
||||
end
|
||||
assert_equal(parsed, 1)
|
||||
assert_equal(parsed, num)
|
||||
end
|
||||
|
||||
it "streaming backward compatibility" do
|
||||
obj = [{["a","b"]=>["c","d"]}, ["e","f"], "d"]
|
||||
num = 4
|
||||
raw = obj.to_msgpack * num
|
||||
pac = MessagePack::Unpacker.new
|
||||
buffer = ""
|
||||
nread = 0
|
||||
parsed = 0
|
||||
obj.to_msgpack.split(//).each do |b|
|
||||
raw.split(//).each do |b|
|
||||
buffer << b
|
||||
nread = pac.execute(buffer, nread)
|
||||
if pac.finished?
|
||||
|
|
@ -237,7 +241,7 @@ class MessagePackTestFormat < Test::Unit::TestCase
|
|||
next unless buffer.empty?
|
||||
end
|
||||
end
|
||||
assert_equal(parsed, 1)
|
||||
assert_equal(parsed, num)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue