test: basic functionality of readUIntBE()
PR-URL: https://github.com/nodejs/node/pull/10417 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com> Reviewed-By: Julian Duque <julianduquej@gmail.com>
This commit is contained in:
parent
7021e6b52d
commit
a5103ce4b5
24
test/parallel/test-buffer-readuintbe.js
Normal file
24
test/parallel/test-buffer-readuintbe.js
Normal file
@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
// testing basic functionality of readUIntBE()
|
||||
|
||||
const buf = Buffer.from([42, 84, 168, 127]);
|
||||
const result = buf.readUIntBE(2);
|
||||
|
||||
assert.strictEqual(result, 84);
|
||||
|
||||
assert.throws(
|
||||
() => {
|
||||
buf.readUIntBE(5);
|
||||
},
|
||||
/Index out of range/
|
||||
);
|
||||
|
||||
assert.doesNotThrow(
|
||||
() => {
|
||||
buf.readUIntBE(5, 0, true);
|
||||
},
|
||||
'readUIntBE() should not throw if noAssert is true'
|
||||
);
|
Loading…
x
Reference in New Issue
Block a user