Skip to content

Commit 1445e28

Browse files
Trottaddaleax
authored andcommitted
test: add test-buffer-prototype-inspect
lib/buffer.js defines Buffer.prototype.inspect() to override how buffers are presented by util.inspect(). Add basic tests for it. PR-URL: #11600 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 3e79dff commit 1445e28

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
require('../common');
3+
4+
// lib/buffer.js defines Buffer.prototype.inspect() to override how buffers are
5+
// presented by util.inspect().
6+
7+
const assert = require('assert');
8+
const util = require('util');
9+
10+
{
11+
const buf = Buffer.from('fhqwhgads');
12+
assert.strictEqual(util.inspect(buf), '<Buffer 66 68 71 77 68 67 61 64 73>');
13+
}
14+
15+
{
16+
const buf = Buffer.from('');
17+
assert.strictEqual(util.inspect(buf), '<Buffer >');
18+
}
19+
20+
{
21+
const buf = Buffer.from('x'.repeat(51));
22+
assert.ok(/^<Buffer (78 ){50}\.\.\. >$/.test(util.inspect(buf)));
23+
}

0 commit comments

Comments
 (0)