@@ -6,43 +6,43 @@ describe('packet-reader', function() {
6
6
} )
7
7
8
8
it ( 'reads perfect 1 length buffer' , function ( ) {
9
- this . reader . addChunk ( Buffer ( [ 0 , 0 , 0 , 0 , 1 , 1 ] ) )
9
+ this . reader . addChunk ( new Buffer ( [ 0 , 0 , 0 , 0 , 1 , 1 ] ) )
10
10
var result = this . reader . read ( )
11
11
assert . equal ( result . length , 1 )
12
12
assert . equal ( result [ 0 ] , 1 )
13
13
assert . strictEqual ( false , this . reader . read ( ) )
14
14
} )
15
15
16
16
it ( 'reads perfect longer buffer' , function ( ) {
17
- this . reader . addChunk ( Buffer ( [ 0 , 0 , 0 , 0 , 4 , 1 , 2 , 3 , 4 ] ) )
17
+ this . reader . addChunk ( new Buffer ( [ 0 , 0 , 0 , 0 , 4 , 1 , 2 , 3 , 4 ] ) )
18
18
var result = this . reader . read ( )
19
19
assert . equal ( result . length , 4 )
20
20
assert . strictEqual ( false , this . reader . read ( ) )
21
21
} )
22
22
23
23
it ( 'reads two parts' , function ( ) {
24
- this . reader . addChunk ( Buffer ( [ 0 , 0 , 0 , 0 , 1 ] ) )
24
+ this . reader . addChunk ( new Buffer ( [ 0 , 0 , 0 , 0 , 1 ] ) )
25
25
var result = this . reader . read ( )
26
26
assert . strictEqual ( false , result )
27
- this . reader . addChunk ( Buffer ( [ 2 ] ) )
27
+ this . reader . addChunk ( new Buffer ( [ 2 ] ) )
28
28
var result = this . reader . read ( )
29
29
assert . equal ( result . length , 1 , 'should return 1 length buffer' )
30
30
assert . equal ( result [ 0 ] , 2 )
31
31
assert . strictEqual ( this . reader . read ( ) , false )
32
32
} )
33
33
34
34
it ( 'reads multi-part' , function ( ) {
35
- this . reader . addChunk ( Buffer ( [ 0 , 0 , 0 , 0 , 16 ] ) )
35
+ this . reader . addChunk ( new Buffer ( [ 0 , 0 , 0 , 0 , 16 ] ) )
36
36
assert . equal ( false , this . reader . read ( ) )
37
- this . reader . addChunk ( Buffer ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] ) )
37
+ this . reader . addChunk ( new Buffer ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] ) )
38
38
assert . equal ( false , this . reader . read ( ) )
39
- this . reader . addChunk ( Buffer ( [ 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 ] ) )
39
+ this . reader . addChunk ( new Buffer ( [ 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 ] ) )
40
40
var result = this . reader . read ( )
41
41
assert . equal ( result . length , 16 )
42
42
} )
43
43
44
44
it ( 'reads multiple messages from single chunk' , function ( ) {
45
- this . reader . addChunk ( Buffer ( [ 0 , 0 , 0 , 0 , 1 , 1 , 0 , 0 , 0 , 0 , 2 , 1 , 2 ] ) )
45
+ this . reader . addChunk ( new Buffer ( [ 0 , 0 , 0 , 0 , 1 , 1 , 0 , 0 , 0 , 0 , 2 , 1 , 2 ] ) )
46
46
var result = this . reader . read ( )
47
47
assert . equal ( result . length , 1 , 'should have 1 length buffer' )
48
48
assert . equal ( result [ 0 ] , 1 )
@@ -54,14 +54,14 @@ describe('packet-reader', function() {
54
54
} )
55
55
56
56
it ( 'reads 1 and a split' , function ( ) {
57
- this . reader . addChunk ( Buffer ( [ 0 , 0 , 0 , 0 , 1 , 1 , 0 , 0 ] ) ) //, 0, 0, 2, 1, 2]))
57
+ this . reader . addChunk ( new Buffer ( [ 0 , 0 , 0 , 0 , 1 , 1 , 0 , 0 ] ) ) //, 0, 0, 2, 1, 2]))
58
58
var result = this . reader . read ( )
59
59
assert . equal ( result . length , 1 , 'should have 1 length buffer' )
60
60
assert . equal ( result [ 0 ] , 1 )
61
61
var result = this . reader . read ( )
62
62
assert . strictEqual ( result , false )
63
63
64
- this . reader . addChunk ( Buffer ( [ 0 , 0 , 2 , 1 , 2 ] ) )
64
+ this . reader . addChunk ( new Buffer ( [ 0 , 0 , 2 , 1 , 2 ] ) )
65
65
var result = this . reader . read ( )
66
66
assert . equal ( result . length , 2 , 'should have 2 length buffer but was ' + result . length )
67
67
assert . equal ( result [ 0 ] , 1 )
@@ -76,7 +76,7 @@ describe('variable length header', function() {
76
76
} )
77
77
78
78
it ( 'reads double message buffers' , function ( ) {
79
- this . reader . addChunk ( Buffer ( [
79
+ this . reader . addChunk ( new Buffer ( [
80
80
0 , 0 , 0 , 1 , 1 ,
81
81
0 , 0 , 0 , 2 , 1 , 2 ] ) )
82
82
var result = this . reader . read ( )
@@ -98,7 +98,7 @@ describe('1 length code', function() {
98
98
} )
99
99
100
100
it ( 'reads code' , function ( ) {
101
- this . reader . addChunk ( Buffer ( [ 9 , 0 , 0 , 0 , 1 , 1 ] ) )
101
+ this . reader . addChunk ( new Buffer ( [ 9 , 0 , 0 , 0 , 1 , 1 ] ) )
102
102
var result = this . reader . read ( )
103
103
assert ( result )
104
104
assert . equal ( this . reader . header , 9 )
@@ -108,7 +108,7 @@ describe('1 length code', function() {
108
108
109
109
it ( 'is set on uncompleted read' , function ( ) {
110
110
assert . equal ( this . reader . header , null )
111
- this . reader . addChunk ( Buffer ( [ 2 , 0 , 0 , 0 , 1 ] ) )
111
+ this . reader . addChunk ( new Buffer ( [ 2 , 0 , 0 , 0 , 1 ] ) )
112
112
assert . strictEqual ( this . reader . read ( ) , false )
113
113
assert . equal ( this . reader . header , 2 )
114
114
} )
@@ -123,7 +123,7 @@ describe('postgres style packet', function() {
123
123
} )
124
124
125
125
it ( 'reads with padded length' , function ( ) {
126
- this . reader . addChunk ( Buffer ( [ 1 , 0 , 0 , 0 , 8 , 0 , 0 , 2 , 0 ] ) )
126
+ this . reader . addChunk ( new Buffer ( [ 1 , 0 , 0 , 0 , 8 , 0 , 0 , 2 , 0 ] ) )
127
127
var result = this . reader . read ( )
128
128
assert ( result )
129
129
assert . equal ( result . length , 4 )
0 commit comments