GeezerVison is showing github.com — test: deflake test-buffer-large-size · nodejs/node@660d238
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboard +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +'use strict'; |
| 2 | +const common = require('../common'); |
| 3 | + |
| 4 | +// Buffer with size > INT32_MAX |
| 5 | +common.skipIf32Bits(); |
| 6 | + |
| 7 | +const assert = require('node:assert'); |
| 8 | +const size = 2 ** 31; |
| 9 | + |
| 10 | +// Test Buffer.allocUnsafe with size larger than integer range |
| 11 | +try { |
| 12 | + assert.throws(() => Buffer.allocUnsafeSlow(size).toString('utf8'), { code: 'ERR_STRING_TOO_LONG' }); |
| 13 | +} catch (e) { |
| 14 | + if (e.code !== 'ERR_MEMORY_ALLOCATION_FAILED') { |
| 15 | + throw e; |
| 16 | + } |
| 17 | + common.skip('insufficient space for Buffer.allocUnsafeSlow'); |
| 18 | +} |
Collapse file
Copy file name to clipboard +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +'use strict'; |
| 2 | +const common = require('../common'); |
| 3 | + |
| 4 | +// Buffer with size > INT32_MAX |
| 5 | +common.skipIf32Bits(); |
| 6 | + |
| 7 | +const assert = require('node:assert'); |
| 8 | +const size = 2 ** 31; |
| 9 | + |
| 10 | +try { |
| 11 | + // Test Buffer.allocUnsafe with size larger than integer range |
| 12 | + assert.throws(() => Buffer.allocUnsafe(size).toString('utf8'), { code: 'ERR_STRING_TOO_LONG' }); |
| 13 | +} catch (e) { |
| 14 | + if (e.code !== 'ERR_MEMORY_ALLOCATION_FAILED') { |
| 15 | + throw e; |
| 16 | + } |
| 17 | + common.skip('insufficient space for Buffer.allocUnsafe'); |
| 18 | +} |
Collapse file
Copy file name to clipboard +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +'use strict'; |
| 2 | +const common = require('../common'); |
| 3 | + |
| 4 | +// Buffer with size > INT32_MAX |
| 5 | +common.skipIf32Bits(); |
| 6 | + |
| 7 | +const assert = require('node:assert'); |
| 8 | +const size = 2 ** 31; |
| 9 | + |
| 10 | +// Test Buffer.alloc with size larger than integer range |
| 11 | +try { |
| 12 | + assert.throws(() => Buffer.alloc(size).toString('utf8'), { code: 'ERR_STRING_TOO_LONG' }); |
| 13 | +} catch (e) { |
| 14 | + if (e.code !== 'ERR_MEMORY_ALLOCATION_FAILED') { |
| 15 | + throw e; |
| 16 | + } |
| 17 | + common.skip('insufficient space for Buffer.alloc'); |
| 18 | +} |
Collapse file
Copy file name to clipboard +22Lines changed: 22 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +'use strict'; |
| 2 | +const common = require('../common'); |
| 3 | + |
| 4 | +// Buffer with size > INT32_MAX |
| 5 | +common.skipIf32Bits(); |
| 6 | + |
| 7 | +const assert = require('node:assert'); |
| 8 | +const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH; |
| 9 | + |
| 10 | +const size = 2 ** 31; |
| 11 | + |
| 12 | +// Test Buffer.write with size larger than integer range |
| 13 | +try { |
| 14 | + const buf = Buffer.alloc(size); |
| 15 | + assert.strictEqual(buf.write('a', 2, kStringMaxLength), 1); |
| 16 | + assert.strictEqual(buf.write('a', 2, size), 1); |
| 17 | +} catch (e) { |
| 18 | + if (e.code !== 'ERR_MEMORY_ALLOCATION_FAILED') { |
| 19 | + throw e; |
| 20 | + } |
| 21 | + common.skip('insufficient space for Buffer.alloc'); |
| 22 | +} |
Collapse file
Copy file name to clipboard +22Lines changed: 22 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +'use strict'; |
| 2 | +const common = require('../common'); |
| 3 | + |
| 4 | +// Buffer with size > INT32_MAX |
| 5 | +common.skipIf32Bits(); |
| 6 | + |
| 7 | +const assert = require('node:assert'); |
| 8 | +const { |
| 9 | + SlowBuffer, |
| 10 | +} = require('node:buffer'); |
| 11 | + |
| 12 | +const size = 2 ** 31; |
| 13 | + |
| 14 | +// Test SlowBuffer with size larger than integer range |
| 15 | +try { |
| 16 | + assert.throws(() => SlowBuffer(size).toString('utf8'), { code: 'ERR_STRING_TOO_LONG' }); |
| 17 | +} catch (e) { |
| 18 | + if (e.code !== 'ERR_MEMORY_ALLOCATION_FAILED') { |
| 19 | + throw e; |
| 20 | + } |
| 21 | + common.skip('insufficient space for SlowBuffer'); |
| 22 | +} |
Collapse file
Copy file name to clipboardExpand all lines: test/pummel/test-buffer-large-size.js -51Lines changed: 0 additions & 51 deletions