File tree Expand file tree Collapse file tree 2 files changed +18
-18
lines changed Expand file tree Collapse file tree 2 files changed +18
-18
lines changed Original file line number Diff line number Diff line change @@ -9,13 +9,16 @@ const {
99 kMaxLength,
1010} = require ( 'buffer' ) ;
1111
12+ < << << << HEAD
1213// Verify the maximum Uint8Array size. There is no concrete limit by spec. The
1314// internal limits should be updated if this fails.
1415assert . throws (
1516 ( ) => new Uint8Array ( kMaxLength + 1 ) ,
1617 { message : `Invalid typed array length: ${ kMaxLength + 1 } ` } ,
1718) ;
1819
20+ = === ===
21+ >>> >>> > b3e1523f34 ( Adapt tests for increased TypedArray sizes ( #161 ) )
1922const b = Buffer . allocUnsafe ( 1024 ) ;
2023assert . strictEqual ( b . length , 1024 ) ;
2124
Original file line number Diff line number Diff line change @@ -18,26 +18,23 @@ const {
1818 } ,
1919} = require ( 'buffer' ) ;
2020
21- const len = MAX_STRING_LENGTH + 1 ;
22- const message = {
23- code : 'ERR_STRING_TOO_LONG' ,
24- name : 'Error' ,
25- } ;
26-
27- function test ( getBuffer ) {
28- let buf ;
21+ // Find the maximum supported buffer length.
22+ let limit = 1 << 31 ; // 2GB
23+ while ( true ) {
2924 try {
30- buf = getBuffer ( ) ;
25+ Buffer ( limit ) ;
26+ limit *= 2 ;
3127 } catch ( e ) {
32- // If the buffer allocation fails, we skip the test.
33- if ( e . code === 'ERR_MEMORY_ALLOCATION_FAILED' || / A r r a y b u f f e r a l l o c a t i o n f a i l e d / . test ( e . message ) ) {
34- return ;
35- }
28+ break ;
3629 }
37- assert . throws ( ( ) => { buf . toString ( 'utf8' ) ; } , message ) ;
3830}
3931
40- test ( ( ) => Buffer ( len ) ) ;
41- test ( ( ) => Buffer . alloc ( len ) ) ;
42- test ( ( ) => Buffer . allocUnsafe ( len ) ) ;
43- test ( ( ) => Buffer . allocUnsafeSlow ( len ) ) ;
32+ const message = {
33+ code : 'ERR_STRING_TOO_LONG' ,
34+ name : 'Error' ,
35+ } ;
36+ assert . throws ( ( ) => Buffer ( limit ) . toString ( 'utf8' ) , message ) ;
37+ assert . throws ( ( ) => SlowBuffer ( limit ) . toString ( 'utf8' ) , message ) ;
38+ assert . throws ( ( ) => Buffer . alloc ( limit ) . toString ( 'utf8' ) , message ) ;
39+ assert . throws ( ( ) => Buffer . allocUnsafe ( limit ) . toString ( 'utf8' ) , message ) ;
40+ assert . throws ( ( ) => Buffer . allocUnsafeSlow ( limit ) . toString ( 'utf8' ) , message ) ;
You can’t perform that action at this time.
0 commit comments