mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-25 10:09:11 +01:00
ruby: streaming deserializer test
This commit is contained in:
parent
b10a736744
commit
c9fcf4020f
@ -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…
x
Reference in New Issue
Block a user