diff options
author | Bryan Duxbury <bryanduxbury@apache.org> | 2010-01-06 23:12:09 +0000 |
---|---|---|
committer | Bryan Duxbury <bryanduxbury@apache.org> | 2010-01-06 23:12:09 +0000 |
commit | 35565a4719679523779d946420992bde33a4987c (patch) | |
tree | 6ed14b92463c081d5a5c7f65231d74254f0ce4a6 /lib/rb/spec | |
parent | 3076fb8d791a07d6f4933bcfb7875ef0d27cb70e (diff) | |
download | thrift-35565a4719679523779d946420992bde33a4987c.tar.gz |
THRIFT-671. rb: Ruby compact protocol implementation gets mixed up when there are fields that don't fit in the delta space
This patch adds a test and a fix for the problem.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@896712 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'lib/rb/spec')
-rw-r--r-- | lib/rb/spec/compact_protocol_spec.rb | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/rb/spec/compact_protocol_spec.rb b/lib/rb/spec/compact_protocol_spec.rb index b9a798103..1fa218222 100644 --- a/lib/rb/spec/compact_protocol_spec.rb +++ b/lib/rb/spec/compact_protocol_spec.rb @@ -86,12 +86,12 @@ describe Thrift::CompactProtocol do it "should make method calls correctly" do client_out_trans = Thrift::MemoryBufferTransport.new client_out_proto = Thrift::CompactProtocol.new(client_out_trans) - + client_in_trans = Thrift::MemoryBufferTransport.new client_in_proto = Thrift::CompactProtocol.new(client_in_trans) - + processor = Srv::Processor.new(JankyHandler.new) - + client = Srv::Client.new(client_in_proto, client_out_proto) client.send_Janky(1) # puts client_out_trans.inspect_buffer @@ -99,6 +99,22 @@ describe Thrift::CompactProtocol do client.recv_Janky.should == 2 end + it "should deal with fields following fields that have non-delta ids" do + brcp = BreaksRubyCompactProtocol.new( + :field1 => "blah", + :field2 => BigFieldIdStruct.new( + :field1 => "string1", + :field2 => "string2"), + :field3 => 3) + ser = Thrift::Serializer.new(Thrift::CompactProtocolFactory.new) + bytes = ser.serialize(brcp) + + deser = Thrift::Deserializer.new(Thrift::CompactProtocolFactory.new) + brcp2 = BreaksRubyCompactProtocol.new + deser.deserialize(brcp2, bytes) + brcp2.should == brcp + end + class JankyHandler def Janky(i32arg) i32arg * 2 |