From fa4a958589f42e73c6348eb46da1ec69a0810ff4 Mon Sep 17 00:00:00 2001 From: Kevin Clark Date: Wed, 18 Jun 2008 01:13:18 +0000 Subject: [PATCH] Add two missing tests for FramedTransport git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@668981 13f79535-47bb-0310-9956-ffa450edef68 --- lib/rb/spec/transport_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/rb/spec/transport_spec.rb b/lib/rb/spec/transport_spec.rb index 5c9da721..941df285 100644 --- a/lib/rb/spec/transport_spec.rb +++ b/lib/rb/spec/transport_spec.rb @@ -137,6 +137,10 @@ class ThriftTransportSpec < Spec::ExampleGroup ftrans.read(16).should == "a frame" end + it "should return nothing if asked for <= 0" do + FramedTransport.new(@trans).read(-2).should == "" + end + it "should pull a new frame when the first is exhausted" do frame = "this is a frame" frame2 = "yet another frame" @@ -159,6 +163,15 @@ class ThriftTransportSpec < Spec::ExampleGroup ftrans.write("this is a frame") end + it "should write slices of the buffer" do + ftrans = FramedTransport.new(@trans) + ftrans.write("foobar", 3) + ftrans.write("barfoo", 1) + @trans.stub!(:flush) + @trans.should_receive(:write).with("\000\000\000\004foob") + ftrans.flush + end + it "should flush frames with a 4-byte header" do ftrans = FramedTransport.new(@trans) @trans.should_receive(:write).with("\000\000\000\035one/two/three/this is a frame").ordered -- 2.17.1