Sha256: 0fa7f25b1610854760b3090d8e18a33a1bb68bf6bb76b583676280259d8cd42c
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
require 'spec_helper' require 'ffi/msgpack/unpacker' require 'stringio' describe MsgPack::Unpacker do before(:all) do @packed = "\x01\x02\x03" end before(:each) do @unpacker = MsgPack::Unpacker.create(1024) end describe "buffer" do it "should enqueue data into the buffer" do size1 = @unpacker[:used] @unpacker << @packed size2 = @unpacker[:used] expect(size2 - size1).to eq(@packed.length) end it "should enqueue data from IO objects into the buffer" do io = StringIO.new(@packed) size1 = @unpacker[:used] expect(@unpacker.read(io)).to eq(true) size2 = @unpacker[:used] expect(size2 - size1).to eq(@packed.length) end end describe "each_object" do it "should unpack each Msg Object from the buffer" do objs = [] expected = [ [:positive_integer, 1], [:positive_integer, 2], [:positive_integer, 3] ] @unpacker << @packed @unpacker.each_object do |obj| objs << [obj.type, obj.values[:u64]] end expect(objs).to eq(expected) end it "should unpack each Msg Object from a stream" do io = StringIO.new(@packed) objs = [] expected = [ [:positive_integer, 1], [:positive_integer, 2], [:positive_integer, 3] ] @unpacker.stream = io @unpacker.each_object do |obj| objs << [obj.type, obj.values[:u64]] end expect(objs).to eq(expected) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ffi-msgpack-0.2.2 | spec/unpacker_spec.rb |