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: https://github.com/nodejs/node/pull/11600 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
bb5c84a1a7
commit
0d4bbf757c
23
test/parallel/test-buffer-prototype-inspect.js
Normal file
23
test/parallel/test-buffer-prototype-inspect.js
Normal file
@ -0,0 +1,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}\.\.\. >$/.test(util.inspect(buf)));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user