Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ If the list has no items, or if the `totalLength` is 0, then a new zero-length
If `totalLength` is not provided, it is calculated from the `Buffer` instances
in `list` by adding their lengths.

If `totalLength` is provided, it is coerced to an unsigned integer. If the
If `totalLength` is provided, it must be an unsigned integer. If the
combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
truncated to `totalLength`. If the combined length of the `Buffer`s in `list` is
less than `totalLength`, the remaining space is filled with zeros.
Expand Down
16 changes: 16 additions & 0 deletions test/parallel/test-buffer-concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ assert.throws(() => {
'or Uint8Array. Received type number (3)'
});

assert.throws(() => {
Buffer.concat([Buffer.from('hello')], 3.5);
}, {
code: 'ERR_OUT_OF_RANGE',
message: 'The value of "length" is out of range. It must be an integer. ' +
'Received 3.5'
});

assert.throws(() => {
Buffer.concat([Buffer.from('hello')], -2);
}, {
code: 'ERR_OUT_OF_RANGE',
message: 'The value of "length" is out of range. It must be >= 0 && <= 9007199254740991. ' +
'Received -2'
});

// eslint-disable-next-line node-core/crypto-check
const random10 = common.hasCrypto ?
require('crypto').randomBytes(10) :
Expand Down
Loading