diff --git a/test/parallel/test-buffer-readuintle.js b/test/parallel/test-buffer-readuintle.js new file mode 100644 index 00000000000000..982adb8607eaa1 --- /dev/null +++ b/test/parallel/test-buffer-readuintle.js @@ -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' +);