A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/nodejs/node/commit/4629b18397 below:

fix test-buffer-tostring-range on allocation failure · nodejs/node@4629b18 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+21

-9

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+21

-9

lines changed Original file line number Diff line number Diff line change

@@ -0,0 +1,20 @@

1 +

'use strict';

2 + 3 +

// This tests that Buffer.prototype.toString() works with buffers over 4GB.

4 +

const common = require('../common');

5 + 6 +

// Must not throw when start and end are within kMaxLength

7 +

// Cannot test on 32bit machine as we are testing the case

8 +

// when start and end are above the threshold

9 +

common.skipIf32Bits();

10 +

const threshold = 0xFFFFFFFF; // 2^32 - 1

11 +

let largeBuffer;

12 +

try {

13 +

largeBuffer = Buffer.alloc(threshold + 20);

14 +

} catch (e) {

15 +

if (e.code === 'ERR_MEMORY_ALLOCATION_FAILED' || /Array buffer allocation failed/.test(e.message)) {

16 +

common.skip('insufficient space for Buffer.alloc');

17 +

}

18 +

throw e;

19 +

}

20 +

largeBuffer.toString('utf8', threshold, threshold + 20);

Original file line number Diff line number Diff line change

@@ -1,6 +1,6 @@

1 1

'use strict';

2 2 3 -

const common = require('../common');

3 +

require('../common');

4 4

const assert = require('assert');

5 5 6 6

const rangeBuffer = Buffer.from('abc');

@@ -98,11 +98,3 @@ assert.throws(() => {

98 98

name: 'TypeError',

99 99

message: 'Unknown encoding: null'

100 100

});

101 - 102 -

// Must not throw when start and end are within kMaxLength

103 -

// Cannot test on 32bit machine as we are testing the case

104 -

// when start and end are above the threshold

105 -

common.skipIf32Bits();

106 -

const threshold = 0xFFFFFFFF;

107 -

const largeBuffer = Buffer.alloc(threshold + 20);

108 -

largeBuffer.toString('utf8', threshold, threshold + 20);

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4