-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fs: complete error code for validateLen func in internal/fs #19909
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,6 +190,31 @@ function testFtruncate(cb) { | |
); | ||
}); | ||
|
||
[-1.5, 1.5].forEach((input) => { | ||
assert.throws( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's better to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. thanks for review :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @starkwang I must disagree. The original reason for using |
||
() => fs.ftruncate(fd, input), | ||
{ | ||
code: 'ERR_OUT_OF_RANGE', | ||
name: 'RangeError [ERR_OUT_OF_RANGE]', | ||
message: 'The value of "len" is out of range. It must be ' + | ||
`an integer. Received ${input}` | ||
} | ||
); | ||
}); | ||
|
||
// 2 ** 31 = 2147483648 | ||
[2147483648, -2147483649].forEach((input) => { | ||
assert.throws( | ||
() => fs.ftruncate(fd, input), | ||
{ | ||
code: 'ERR_OUT_OF_RANGE', | ||
name: 'RangeError [ERR_OUT_OF_RANGE]', | ||
message: 'The value of "len" is out of range. It must be ' + | ||
`> -2147483649 && < 2147483648. Received ${input}` | ||
} | ||
); | ||
}); | ||
|
||
fs.ftruncate(fd, undefined, common.mustCall(function(err) { | ||
assert.ifError(err); | ||
assert(fs.readFileSync(file5).equals(Buffer.from(''))); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️