diff options
| author | frsyuki <frsyuki@users.sourceforge.jp> | 2010-06-03 21:52:01 +0900 |
|---|---|---|
| committer | frsyuki <frsyuki@users.sourceforge.jp> | 2010-06-03 21:52:01 +0900 |
| commit | 251090406a642d968e314db3aa1d5240db00598a (patch) | |
| tree | 89bbff957e03f24c9128c77fe62c7cdc85f44c65 /ruby | |
| parent | 9c3ed173b1c497cfe9bdfff2e5e695e5a3377e0a (diff) | |
| download | msgpack-python-251090406a642d968e314db3aa1d5240db00598a.tar.gz | |
ruby: adds a test case for buffering
Diffstat (limited to 'ruby')
| -rw-r--r-- | ruby/test/test_pack_unpack.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/ruby/test/test_pack_unpack.rb b/ruby/test/test_pack_unpack.rb index e22bab3..9dff44f 100644 --- a/ruby/test/test_pack_unpack.rb +++ b/ruby/test/test_pack_unpack.rb @@ -203,6 +203,37 @@ class MessagePackTestPackUnpack < Test::Unit::TestCase # #check_map 5, (1<<32)-1 # memory error # end + it "buffer" do + str = "a"*32*1024*4 + raw = str.to_msgpack + pac = MessagePack::Unpacker.new + + len = 0 + parsed = false + + n = 655 + time = raw.size / n + time += 1 unless raw.size % n == 0 + off = 0 + + time.times do + assert(!parsed) + + fe = raw[off, n] + assert(fe.length > 0) + off += fe.length + + pac.feed fe + pac.each {|obj| + assert(!parsed) + assert_equal(obj, str) + parsed = true + } + end + + assert(parsed) + end + it "gc mark" do obj = [{["a","b"]=>["c","d"]}, ["e","f"], "d"] num = 4 |
