-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
test: added coverage tests related with method fs.read and fs.readSync #17875
Changes from 4 commits
37c97b1
d7326b2
bd3aa3e
5e59b4f
9ec700b
71396a2
c0e9cde
b0dd43c
6c0da34
9e5ccf0
46510f5
b343671
cb3de88
df30fd5
83e5215
24c71fb
c569727
6ca10de
9f122e3
d3ac18a
c560ae4
bfae5ac
25475ad
047b2d7
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright Joyent, Inc. and other Node contributors. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a | ||
// copy of this software and associated documentation files (the | ||
// "Software"), to deal in the Software without restriction, including | ||
// without limitation the rights to use, copy, modify, merge, publish, | ||
// distribute, sublicense, and/or sell copies of the Software, and to permit | ||
// persons to whom the Software is furnished to do so, subject to the | ||
// following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included | ||
// in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
// USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
'use strict'; | ||
const common = require('../common'); | ||
const fixtures = require('../common/fixtures'); | ||
const fs = require('fs'); | ||
const filepath = fixtures.path('x.txt'); | ||
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. Nit: add empty line after all the 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. empty lines added |
||
const fd = fs.openSync(filepath, 'r'); | ||
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. Shouldn't this be 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. @mmarchini Sync I/O is okay the initialization stage. 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. Didn't know that. Thanks! |
||
|
||
const expected = Buffer.from('xyz\n'); | ||
|
||
common.expectsError( | ||
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. I'd suggest changing the common.expectsError(() => {
fs.read(fd,
Buffer.allocUnsafe(expected.length),
0,
expected.length,
0,
common.mustNotCall());
}, { code: 'ERR_INVALID_ARG_TYPE', type: TypeError }); 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. ok thanks for all, I 'll make some changes. |
||
fs.read.bind(fd, | ||
Buffer.allocUnsafe(expected.length), | ||
0, | ||
expected.length, | ||
0, | ||
common.mustNotCall()), | ||
{ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }); | ||
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. For Also, a general rule is that we also test the "message" of the error object. 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. @apapirovski I have a doubt when the parameter |
||
|
||
common.expectsError( | ||
fs.read.bind(undefined, | ||
fd, | ||
Buffer.allocUnsafe(expected.length), | ||
-1, | ||
expected.length, | ||
0, | ||
common.mustNotCall()), | ||
{ code: 'ERR_OUT_OF_RANGE', type: RangeError }); | ||
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. Does this have an upper boundary or just lower? If it does, that would ideally also be tested. |
||
|
||
common.expectsError( | ||
fs.read.bind(undefined, | ||
fd, | ||
Buffer.allocUnsafe(expected.length), | ||
0, | ||
-1, | ||
0, | ||
common.mustNotCall()), | ||
{ code: 'ERR_OUT_OF_RANGE', type: RangeError }); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright Joyent, Inc. and other Node contributors. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a | ||
// copy of this software and associated documentation files (the | ||
// "Software"), to deal in the Software without restriction, including | ||
// without limitation the rights to use, copy, modify, merge, publish, | ||
// distribute, sublicense, and/or sell copies of the Software, and to permit | ||
// persons to whom the Software is furnished to do so, subject to the | ||
// following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included | ||
// in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
// USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
'use strict'; | ||
const common = require('../common'); | ||
const fixtures = require('../common/fixtures'); | ||
const fs = require('fs'); | ||
const filepath = fixtures.path('x.txt'); | ||
const fd = fs.openSync(filepath, 'r'); | ||
|
||
const expected = Buffer.from('xyz\n'); | ||
|
||
common.expectsError( | ||
fs.readSync.bind(fd, | ||
Buffer.allocUnsafe(expected.length), | ||
0, | ||
expected.length, | ||
0), | ||
{ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }); | ||
|
||
common.expectsError( | ||
fs.readSync.bind(undefined, | ||
fd, | ||
Buffer.allocUnsafe(expected.length), | ||
-1, | ||
expected.length, | ||
0), | ||
{ code: 'ERR_OUT_OF_RANGE', type: RangeError }); | ||
|
||
common.expectsError( | ||
fs.readSync.bind(undefined, | ||
1, | ||
Buffer.allocUnsafe(expected.length), | ||
0, | ||
-1, | ||
0), | ||
{ code: 'ERR_OUT_OF_RANGE', type: RangeError }); |
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.
Correct me if I'm wrong, but this shouldn't say
Copyright Joyent, Inc.
unless you work thereThere 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.
The license header is only necessary for pre-io.js files.
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.
sorry I'll fix it