���� JFIF �� � ( %"1"%)+...383,7(-.-
![]() Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20 System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64 User : apache ( 48) PHP Version : 7.4.20 Disable Function : NONE Directory : /home/real/node-v13.0.1/test/parallel/ |
'use strict'; require('../common'); const assert = require('assert'); const buffer = require('buffer'); const SlowBuffer = buffer.SlowBuffer; const ones = [1, 1, 1, 1]; // Should create a Buffer let sb = SlowBuffer(4); assert(sb instanceof Buffer); assert.strictEqual(sb.length, 4); sb.fill(1); for (const [key, value] of sb.entries()) { assert.deepStrictEqual(value, ones[key]); } // underlying ArrayBuffer should have the same length assert.strictEqual(sb.buffer.byteLength, 4); // Should work without new sb = SlowBuffer(4); assert(sb instanceof Buffer); assert.strictEqual(sb.length, 4); sb.fill(1); for (const [key, value] of sb.entries()) { assert.deepStrictEqual(value, ones[key]); } // Should work with edge cases assert.strictEqual(SlowBuffer(0).length, 0); try { assert.strictEqual( SlowBuffer(buffer.kMaxLength).length, buffer.kMaxLength); } catch (e) { // Don't match on message as it is from the JavaScript engine. V8 and // ChakraCore provide different messages. assert.strictEqual(e.name, 'RangeError'); } // Should throw with invalid length type const bufferInvalidTypeMsg = { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError', message: /^The "size" argument must be of type number/, }; assert.throws(() => SlowBuffer(), bufferInvalidTypeMsg); assert.throws(() => SlowBuffer({}), bufferInvalidTypeMsg); assert.throws(() => SlowBuffer('6'), bufferInvalidTypeMsg); assert.throws(() => SlowBuffer(true), bufferInvalidTypeMsg); // Should throw with invalid length value const bufferMaxSizeMsg = { code: 'ERR_INVALID_OPT_VALUE', name: 'RangeError', message: /^The value "[^"]*" is invalid for option "size"$/ }; assert.throws(() => SlowBuffer(NaN), bufferMaxSizeMsg); assert.throws(() => SlowBuffer(Infinity), bufferMaxSizeMsg); assert.throws(() => SlowBuffer(-1), bufferMaxSizeMsg); assert.throws(() => SlowBuffer(buffer.kMaxLength + 1), bufferMaxSizeMsg);