summaryrefslogtreecommitdiff
path: root/test/parallel/test-buffer-prototype-inspect.js
blob: f13dda49f0dd45b70245e5ae4a9d3df0acc517fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict';
require('../common');

// lib/buffer.js defines Buffer.prototype.inspect() to override how buffers are
// presented by util.inspect().

const assert = require('assert');
const util = require('util');

{
  const buf = Buffer.from('fhqwhgads');
  assert.strictEqual(util.inspect(buf), '<Buffer 66 68 71 77 68 67 61 64 73>');
}

{
  const buf = Buffer.from('');
  assert.strictEqual(util.inspect(buf), '<Buffer >');
}

{
  const buf = Buffer.from('x'.repeat(51));
  assert.ok(/^<Buffer (?:78 ){50}\.\.\. 1 more byte>$/.test(util.inspect(buf)));
}