| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 47080bc commit 95db7d5
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,13 +78,21 @@ assert.throws( | |||
| 78 | 78 | } | |
| 79 | 79 | ); | |
| 80 | 80 | ||
| 81 | - ['buffer', 'offset', 'length'].forEach((option) => | ||
| 82 | - assert.throws( | ||
| 83 | - () => fs.read(fd, { | ||
| 84 | - [option]: null | ||
| 85 | - }), | ||
| 86 | - `not throws when options.${option} is null` | ||
| 87 | - )); | ||
| 81 | + assert.throws( | ||
| 82 | + () => fs.read(fd, { buffer: null }, common.mustNotCall()), | ||
| 83 | + /TypeError: Cannot read property 'byteLength' of null/, | ||
| 84 | + 'throws when options.buffer is null' | ||
| 85 | + ); | ||
| 86 | + | ||
| 87 | + assert.throws( | ||
| 88 | + () => fs.readSync(fd, { buffer: null }), | ||
| 89 | + { | ||
| 90 | + name: 'TypeError', | ||
| 91 | + message: 'The "buffer" argument must be an instance of Buffer, ' + | ||
| 92 | + 'TypedArray, or DataView. Received an instance of Object', | ||
| 93 | + }, | ||
| 94 | + 'throws when options.buffer is null' | ||
| 95 | + ); | ||
| 88 | 96 | ||
| 89 | 97 | assert.throws( | |
| 90 | 98 | () => fs.read(null, Buffer.alloc(1), 0, 1, 0), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,6 +52,23 @@ for (const e of fileInfo) { | |||
| 52 | 52 | assert.deepStrictEqual(buf, e.contents); | |
| 53 | 53 | })); | |
| 54 | 54 | } | |
| 55 | + // Test readFile size too large | ||
| 56 | + { | ||
| 57 | + const kIoMaxLength = 2 ** 31 - 1; | ||
| 58 | + | ||
| 59 | + const file = path.join(tmpdir.path, `${prefix}-too-large.txt`); | ||
| 60 | + fs.writeFileSync(file, Buffer.from('0')); | ||
| 61 | + fs.truncateSync(file, kIoMaxLength + 1); | ||
| 62 | + | ||
| 63 | + fs.readFile(file, common.expectsError({ | ||
| 64 | + code: 'ERR_FS_FILE_TOO_LARGE', | ||
| 65 | + name: 'RangeError', | ||
| 66 | + })); | ||
| 67 | + assert.throws(() => { | ||
| 68 | + fs.readFileSync(file); | ||
| 69 | + }, { code: 'ERR_FS_FILE_TOO_LARGE', name: 'RangeError' }); | ||
| 70 | + } | ||
| 71 | + | ||
| 55 | 72 | { | |
| 56 | 73 | // Test cancellation, before | |
| 57 | 74 | const signal = AbortSignal.abort(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments