@@ -77,6 +77,71 @@ function checkArgs(connected) {
77
77
message : 'Already connected'
78
78
}
79
79
) ;
80
+
81
+ for ( const input of [ 'hello' , Buffer . from ( 'hello' ) ,
82
+ Buffer . from ( 'hello world' ) . subarray ( 0 , 5 ) ,
83
+ Buffer . from ( 'hello world' ) . subarray ( 6 ) ] ) {
84
+ assert . throws (
85
+ ( ) => { sock . send ( input , 6 , 0 ) ; } ,
86
+ {
87
+ code : 'ERR_OUT_OF_RANGE' ,
88
+ name : 'RangeError' ,
89
+ message : 'The value of "offset" is out of range. ' +
90
+ 'It must be <= 5. Received 6'
91
+ }
92
+ ) ;
93
+
94
+ assert . throws (
95
+ ( ) => { sock . send ( input , 0 , 6 ) ; } ,
96
+ {
97
+ code : 'ERR_OUT_OF_RANGE' ,
98
+ name : 'RangeError' ,
99
+ message : 'The value of "length" is out of range. ' +
100
+ 'It must be <= 5. Received 6'
101
+ }
102
+ ) ;
103
+
104
+ assert . throws (
105
+ ( ) => { sock . send ( input , 3 , 4 ) ; } ,
106
+ {
107
+ code : 'ERR_OUT_OF_RANGE' ,
108
+ name : 'RangeError' ,
109
+ message : 'The value of "length" is out of range. ' +
110
+ 'It must be <= 2. Received 4'
111
+ }
112
+ ) ;
113
+ }
114
+
115
+ for ( const input of [ new Uint8Array ( [ 1 , 2 , 3 , 4 , 5 ] ) ,
116
+ new DataView ( new ArrayBuffer ( 5 ) , 0 ) ,
117
+ new DataView ( new ArrayBuffer ( 6 ) , 2 ) ] ) {
118
+ assert . throws (
119
+ ( ) => { sock . send ( input , 6 , 0 ) ; } ,
120
+ {
121
+ code : 'ERR_BUFFER_OUT_OF_BOUNDS' ,
122
+ name : 'RangeError' ,
123
+ message : '"offset" is outside of buffer bounds' ,
124
+ }
125
+ ) ;
126
+
127
+ assert . throws (
128
+ ( ) => { sock . send ( input , 0 , 6 ) ; } ,
129
+ {
130
+ code : 'ERR_BUFFER_OUT_OF_BOUNDS' ,
131
+ name : 'RangeError' ,
132
+ message : '"length" is outside of buffer bounds' ,
133
+ }
134
+ ) ;
135
+
136
+ assert . throws (
137
+ ( ) => { sock . send ( input , 3 , 4 ) ; } ,
138
+ {
139
+ code : 'ERR_BUFFER_OUT_OF_BOUNDS' ,
140
+ name : 'RangeError' ,
141
+ message : '"length" is outside of buffer bounds' ,
142
+ }
143
+ ) ;
144
+ }
80
145
} else {
81
146
assert . throws ( ( ) => { sock . send ( buf , 1 , 1 , - 1 , host ) ; } , RangeError ) ;
82
147
assert . throws ( ( ) => { sock . send ( buf , 1 , 1 , 0 , host ) ; } , RangeError ) ;
@@ -90,7 +155,7 @@ function checkArgs(connected) {
90
155
code : 'ERR_INVALID_ARG_TYPE' ,
91
156
name : 'TypeError' ,
92
157
message : 'The "buffer" argument must be of type string or an instance ' +
93
- 'of Buffer, TypedArray, or DataView. Received type number (23)'
158
+ 'of Buffer, TypedArray, or DataView. Received type number (23)'
94
159
}
95
160
) ;
96
161
@@ -101,8 +166,8 @@ function checkArgs(connected) {
101
166
code : 'ERR_INVALID_ARG_TYPE' ,
102
167
name : 'TypeError' ,
103
168
message : 'The "buffer list arguments" argument must be of type string ' +
104
- 'or an instance of Buffer, TypedArray, or DataView. ' +
105
- 'Received an instance of Array'
169
+ 'or an instance of Buffer, TypedArray, or DataView. ' +
170
+ 'Received an instance of Array'
106
171
}
107
172
) ;
108
173
}
0 commit comments