Changeset 725
- Timestamp:
- 06/29/08 19:04:48 (2 months ago)
- Files:
-
- trunk/lib/protocols/linetext2.rb (modified) (1 diff)
- trunk/tests/test_ltp2.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/protocols/linetext2.rb
r724 r725 84 84 @lt2_textpos += will_take 85 85 if @lt2_textpos >= @lt2_textsize 86 # Reset line mode (the default behavior) BEFORE calling the 87 # receive_binary_data. This makes it possible for user code 88 # to call set_text_mode, enabling chains of text blocks 89 # (which can possibly be of different sizes). 90 set_line_mode 86 91 receive_binary_data @lt2_textbuffer.join 87 92 receive_end_of_binary_data 88 set_line_mode89 93 end 90 94 trunk/tests/test_ltp2.rb
r724 r725 292 292 assert( a.end ) 293 293 end 294 295 296 # This tests a bug fix in which calling set_text_mode failed when called 297 # inside receive_binary_data. 298 # 299 class BinaryPair 300 include EM::Protocols::LineText2 301 attr_reader :sizes 302 def initialize *args 303 super 304 set_text_mode 1 305 @sizes = [] 306 end 307 def receive_binary_data dt 308 @sizes << dt.length 309 set_text_mode( (dt.length == 1) ? 2 : 1 ) 310 end 311 end 312 def test_binary_pairs 313 test_data = "123" * 5 314 a = BinaryPair.new 315 a.receive_data test_data 316 assert_equal( [1,2,1,2,1,2,1,2,1,2], a.sizes ) 317 end 318 294 319 end 295 320
