@@ -70,9 +70,11 @@ describe('parsers', function () {
7070 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ' +
7171 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ' +
7272 'ut aliquip ex ea commodo consequat. Duis aute irure dolor in' // 256 chars
73- var bigString = ( new Array ( Math . pow ( 2 , 17 ) / lorem . length ) . join ( lorem ) ) // Math.pow(2, 17) chars long
73+ var bigString = ( new Array ( Math . pow ( 2 , 17 ) / lorem . length + 1 ) . join ( lorem ) ) // Math.pow(2, 17) chars long
7474 var replyCount = 0
75+ var sizes = [ 4 , Math . pow ( 2 , 17 ) ]
7576 function checkReply ( reply ) {
77+ assert . strictEqual ( sizes [ replyCount ] , reply . length )
7678 replyCount ++
7779 }
7880 var parser = new Parser ( {
@@ -200,7 +202,7 @@ describe('parsers', function () {
200202 it ( 'should handle \\r and \\n characters properly' , function ( ) {
201203 // If a string contains \r or \n characters it will always be send as a bulk string
202204 var replyCount = 0
203- var entries = [ 'foo\r' , 'foo\r\nbar' , '\r\nfoo' , 'foo\r\n' , 'foo' ]
205+ var entries = [ 'foo\r' , 'foo\r\nbar' , '\r\nfoo' , 'foo\r\n' , 'foo' , 'foobar' , 'foo\r' , 'äfooöü' , 'abc' ]
204206 function checkReply ( reply ) {
205207 assert . strictEqual ( reply , entries [ replyCount ] )
206208 replyCount ++
@@ -217,8 +219,16 @@ describe('parsers', function () {
217219 assert . strictEqual ( replyCount , 4 )
218220 parser . execute ( new Buffer ( '+foo\r' ) )
219221 assert . strictEqual ( replyCount , 4 )
220- parser . execute ( new Buffer ( '\n' ) )
222+ parser . execute ( new Buffer ( '\n$6\r\nfoobar\r ' ) )
221223 assert . strictEqual ( replyCount , 5 )
224+ parser . execute ( new Buffer ( '\n$4\r\nfoo\r\r\n' ) )
225+ assert . strictEqual ( replyCount , 7 )
226+ parser . execute ( new Buffer ( '$9\r\näfo' ) )
227+ parser . execute ( new Buffer ( 'oö' ) )
228+ parser . execute ( new Buffer ( 'ü\r' ) )
229+ assert . strictEqual ( replyCount , 7 )
230+ parser . execute ( new Buffer ( '\n+abc\r\n' ) )
231+ assert . strictEqual ( replyCount , 9 )
222232 } )
223233
224234 it ( 'line breaks in the beginning of the last chunk' , function ( ) {
@@ -271,10 +281,9 @@ describe('parsers', function () {
271281 parser . execute ( new Buffer (
272282 'abcdefghij\r\n' +
273283 '$100\r\nabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\r\n' +
274- '$100\r\nabcdefghijabcdefghijabcdefghijabcdefghij '
284+ '$100\r\nabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij '
275285 ) )
276286 assert . strictEqual ( replyCount , 3 )
277- parser . execute ( new Buffer ( 'abcdefghijabcdefghijabcdefghij' ) )
278287 parser . execute ( new Buffer ( 'abcdefghijabcdefghijabcdefghij\r' ) )
279288 assert . strictEqual ( replyCount , 3 )
280289 parser . execute ( new Buffer ( '\n' ) )
0 commit comments