read boundaries could break a multi-character gets terminator
This commit is contained in:
		
							parent
							
								
									7bd96f53b8
								
							
						
					
					
						commit
						3406ad49cd
					
				|  | @ -83,7 +83,7 @@ module IOExtras  #:nodoc: | |||
| 
 | ||||
|       bufferIndex = 0 | ||||
|       while ((matchIndex = @outputBuffer.index(aSepString, bufferIndex)) == nil) | ||||
|         bufferIndex = @outputBuffer.bytesize | ||||
|         bufferIndex = [bufferIndex, @outputBuffer.bytesize - aSepString.bytesize].max | ||||
|         if input_finished? | ||||
|           return @outputBuffer.empty? ? nil : flush | ||||
|         end | ||||
|  |  | |||
|  | @ -75,6 +75,18 @@ class AbstractInputStreamTest < Test::Unit::TestCase | |||
|     assert_equal("o world#{$/}this is the second l", @io.gets("d l")) | ||||
|   end | ||||
| 
 | ||||
|   LONG_LINES = [ | ||||
|     'x'*48 + "\r\n", | ||||
|     'y'*49 + "\r\n", | ||||
|     'rest', | ||||
|   ] | ||||
|   def test_getsMulitCharSeperator_split | ||||
|     io = TestAbstractInputStream.new(LONG_LINES.join) | ||||
|     assert_equal(LONG_LINES[0], io.gets("\r\n")) | ||||
|     assert_equal(LONG_LINES[1], io.gets("\r\n")) | ||||
|     assert_equal(LONG_LINES[2], io.gets("\r\n")) | ||||
|   end | ||||
| 
 | ||||
|   def test_each_line | ||||
|     lineNumber=0 | ||||
|     @io.each_line { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue