mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
test: basic functionality of readUIntLE()
PR-URL: https://github.com/nodejs/node/pull/10359 Reviewed-By: Julian Duque <julianduquej@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
904b66d870
commit
66c0767be4
24
test/parallel/test-buffer-readuintle.js
Normal file
24
test/parallel/test-buffer-readuintle.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
'use strict';
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
// testing basic functionality of readUIntLE()
|
||||
|
||||
const buf = Buffer.from([42, 84, 168, 127]);
|
||||
const result = buf.readUIntLE(2);
|
||||
|
||||
assert.strictEqual(result, 168);
|
||||
|
||||
assert.throws(
|
||||
() => {
|
||||
buf.readUIntLE(5);
|
||||
},
|
||||
/Index out of range/
|
||||
);
|
||||
|
||||
assert.doesNotThrow(
|
||||
() => {
|
||||
buf.readUIntLE(5, 0, true);
|
||||
},
|
||||
'readUIntLE() should not throw if noAssert is true'
|
||||
);
|
||||
Loading…
Reference in New Issue
Block a user