node/test/parallel/test-buffer-bad-overload.js
Sam Shull bae695f4f3 test: add regex check in test-buffer-bad-overload
Creating a buffer from a number should throw an error with a message
that describes the issue.

PR-URL: https://github.com/nodejs/node/pull/10038
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-21 20:53:52 -05:00

16 lines
318 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
assert.doesNotThrow(function() {
Buffer.allocUnsafe(10);
});
assert.throws(function() {
Buffer.from(10, 'hex');
}, /^TypeError: "value" argument must not be a number$/);
assert.doesNotThrow(function() {
Buffer.from('deadbeaf', 'hex');
});