@@ -49,7 +49,7 @@ testBufs('\u0222aa', 8, 1, 'utf8');
49
49
testBufs ( 'a\u0234b\u0235c\u0236' , 4 , - 1 , 'utf8' ) ;
50
50
testBufs ( 'a\u0234b\u0235c\u0236' , 4 , 1 , 'utf8' ) ;
51
51
testBufs ( 'a\u0234b\u0235c\u0236' , 12 , 1 , 'utf8' ) ;
52
- assert . equal ( Buffer . allocUnsafe ( 1 ) . fill ( 0 ) . fill ( '\u0222' ) [ 0 ] , 0xc8 ) ;
52
+ assert . strictEqual ( Buffer . allocUnsafe ( 1 ) . fill ( 0 ) . fill ( '\u0222' ) [ 0 ] , 0xc8 ) ;
53
53
54
54
55
55
// BINARY
@@ -112,8 +112,8 @@ testBufs('\u0222aa', 8, 1, 'ucs2');
112
112
testBufs ( 'a\u0234b\u0235c\u0236' , 4 , - 1 , 'ucs2' ) ;
113
113
testBufs ( 'a\u0234b\u0235c\u0236' , 4 , 1 , 'ucs2' ) ;
114
114
testBufs ( 'a\u0234b\u0235c\u0236' , 12 , 1 , 'ucs2' ) ;
115
- assert . equal ( Buffer . allocUnsafe ( 1 ) . fill ( '\u0222' , 'ucs2' ) [ 0 ] ,
116
- os . endianness ( ) === 'LE' ? 0x22 : 0x02 ) ;
115
+ assert . strictEqual ( Buffer . allocUnsafe ( 1 ) . fill ( '\u0222' , 'ucs2' ) [ 0 ] ,
116
+ os . endianness ( ) === 'LE' ? 0x22 : 0x02 ) ;
117
117
118
118
119
119
// HEX
@@ -137,7 +137,8 @@ testBufs('61c8b462c8b563c8b6', 4, 1, 'hex');
137
137
testBufs ( '61c8b462c8b563c8b6' , 12 , 1 , 'hex' ) ;
138
138
// Make sure this operation doesn't go on forever
139
139
buf1 . fill ( 'yKJh' , 'hex' ) ;
140
- assert . throws ( ( ) => buf1 . fill ( '\u0222' , 'hex' ) ) ;
140
+ assert . throws ( ( ) =>
141
+ buf1 . fill ( '\u0222' , 'hex' ) , / ^ T y p e E r r o r : I n v a l i d h e x s t r i n g $ / ) ;
141
142
142
143
143
144
// BASE64
@@ -183,14 +184,25 @@ deepStrictEqualValues(genBuffer(4, [hexBufFill, 1, -1]), [0, 0, 0, 0]);
183
184
184
185
185
186
// Check exceptions
186
- assert . throws ( ( ) => buf1 . fill ( 0 , - 1 ) ) ;
187
- assert . throws ( ( ) => buf1 . fill ( 0 , 0 , buf1 . length + 1 ) ) ;
188
- assert . throws ( ( ) => buf1 . fill ( '' , - 1 ) ) ;
189
- assert . throws ( ( ) => buf1 . fill ( '' , 0 , buf1 . length + 1 ) ) ;
190
- assert . throws ( ( ) => buf1 . fill ( 'a' , 0 , buf1 . length , 'node rocks!' ) ) ;
191
- assert . throws ( ( ) => buf1 . fill ( 'a' , 0 , 0 , NaN ) ) ;
192
- assert . throws ( ( ) => buf1 . fill ( 'a' , 0 , 0 , null ) ) ;
193
- assert . throws ( ( ) => buf1 . fill ( 'a' , 0 , 0 , 'foo' ) ) ;
187
+ assert . throws ( ( ) => buf1 . fill ( 0 , - 1 ) , / ^ R a n g e E r r o r : O u t o f r a n g e i n d e x $ / ) ;
188
+ assert . throws ( ( ) =>
189
+ buf1 . fill ( 0 , 0 , buf1 . length + 1 ) ,
190
+ / ^ R a n g e E r r o r : O u t o f r a n g e i n d e x $ / ) ;
191
+ assert . throws ( ( ) => buf1 . fill ( '' , - 1 ) , / ^ R a n g e E r r o r : O u t o f r a n g e i n d e x $ / ) ;
192
+ assert . throws ( ( ) =>
193
+ buf1 . fill ( '' , 0 , buf1 . length + 1 ) ,
194
+ / ^ R a n g e E r r o r : O u t o f r a n g e i n d e x $ / ) ;
195
+ assert . throws ( ( ) =>
196
+ buf1 . fill ( 'a' , 0 , buf1 . length , 'node rocks!' ) ,
197
+ / ^ T y p e E r r o r : U n k n o w n e n c o d i n g : n o d e r o c k s ! $ / ) ;
198
+ assert . throws ( ( ) =>
199
+ buf1 . fill ( 'a' , 0 , 0 , NaN ) ,
200
+ / ^ T y p e E r r o r : e n c o d i n g m u s t b e a s t r i n g $ / ) ;
201
+ assert . throws ( ( ) =>
202
+ buf1 . fill ( 'a' , 0 , 0 , null ) ,
203
+ / ^ T y p e E r r o r : e n c o d i n g m u s t b e a s t r i n g $ / ) ;
204
+ assert . throws ( ( ) =>
205
+ buf1 . fill ( 'a' , 0 , 0 , 'foo' ) , / ^ T y p e E r r o r : U n k n o w n e n c o d i n g : f o o $ / ) ;
194
206
195
207
196
208
function genBuffer ( size , args ) {
@@ -269,8 +281,12 @@ function testBufs(string, offset, length, encoding) {
269
281
}
270
282
271
283
// Make sure these throw.
272
- assert . throws ( ( ) => Buffer . allocUnsafe ( 8 ) . fill ( 'a' , - 1 ) ) ;
273
- assert . throws ( ( ) => Buffer . allocUnsafe ( 8 ) . fill ( 'a' , 0 , 9 ) ) ;
284
+ assert . throws ( ( ) =>
285
+ Buffer . allocUnsafe ( 8 ) . fill ( 'a' , - 1 ) ,
286
+ / ^ R a n g e E r r o r : O u t o f r a n g e i n d e x $ / ) ;
287
+ assert . throws ( ( ) =>
288
+ Buffer . allocUnsafe ( 8 ) . fill ( 'a' , 0 , 9 ) ,
289
+ / ^ R a n g e E r r o r : O u t o f r a n g e i n d e x $ / ) ;
274
290
275
291
// Make sure this doesn't hang indefinitely.
276
292
Buffer . allocUnsafe ( 8 ) . fill ( '' ) ;
@@ -369,7 +385,7 @@ assert.throws(() => {
369
385
}
370
386
} ;
371
387
Buffer . alloc ( 1 ) . fill ( Buffer . alloc ( 1 ) , 0 , end ) ;
372
- } ) ;
388
+ } , / ^ R a n g e E r r o r : o u t o f r a n g e i n d e x $ / ) ;
373
389
// Make sure -1 is making it to Buffer::Fill().
374
390
assert . ok ( elseWasLast ,
375
391
'internal API changed, -1 no longer in correct location' ) ;
@@ -389,4 +405,4 @@ assert.throws(() => {
389
405
enumerable : true
390
406
} ) ;
391
407
buf . fill ( '' ) ;
392
- } ) ;
408
+ } , / ^ R a n g e E r r o r : o u t o f r a n g e i n d e x $ / ) ;
0 commit comments