@@ -70,9 +70,11 @@ describe('parsers', function () {
70
70
'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ' +
71
71
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ' +
72
72
'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
74
74
var replyCount = 0
75
+ var sizes = [ 4 , Math . pow ( 2 , 17 ) ]
75
76
function checkReply ( reply ) {
77
+ assert . strictEqual ( sizes [ replyCount ] , reply . length )
76
78
replyCount ++
77
79
}
78
80
var parser = new Parser ( {
@@ -200,7 +202,7 @@ describe('parsers', function () {
200
202
it ( 'should handle \\r and \\n characters properly' , function ( ) {
201
203
// If a string contains \r or \n characters it will always be send as a bulk string
202
204
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' ]
204
206
function checkReply ( reply ) {
205
207
assert . strictEqual ( reply , entries [ replyCount ] )
206
208
replyCount ++
@@ -217,8 +219,16 @@ describe('parsers', function () {
217
219
assert . strictEqual ( replyCount , 4 )
218
220
parser . execute ( new Buffer ( '+foo\r' ) )
219
221
assert . strictEqual ( replyCount , 4 )
220
- parser . execute ( new Buffer ( '\n' ) )
222
+ parser . execute ( new Buffer ( '\n$6\r\nfoobar\r ' ) )
221
223
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 )
222
232
} )
223
233
224
234
it ( 'line breaks in the beginning of the last chunk' , function ( ) {
@@ -271,10 +281,9 @@ describe('parsers', function () {
271
281
parser . execute ( new Buffer (
272
282
'abcdefghij\r\n' +
273
283
'$100\r\nabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\r\n' +
274
- '$100\r\nabcdefghijabcdefghijabcdefghijabcdefghij '
284
+ '$100\r\nabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij '
275
285
) )
276
286
assert . strictEqual ( replyCount , 3 )
277
- parser . execute ( new Buffer ( 'abcdefghijabcdefghijabcdefghij' ) )
278
287
parser . execute ( new Buffer ( 'abcdefghijabcdefghijabcdefghij\r' ) )
279
288
assert . strictEqual ( replyCount , 3 )
280
289
parser . execute ( new Buffer ( '\n' ) )
0 commit comments