From 66c0767be4be23782c155805df61b64c48624f48 Mon Sep 17 00:00:00 2001 From: larissayvette Date: Tue, 20 Dec 2016 12:49:51 +0100 Subject: [PATCH] test: basic functionality of readUIntLE() PR-URL: https://github.com/nodejs/node/pull/10359 Reviewed-By: Julian Duque Reviewed-By: Rich Trott Reviewed-By: Italo A. Casas Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- test/parallel/test-buffer-readuintle.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/parallel/test-buffer-readuintle.js diff --git a/test/parallel/test-buffer-readuintle.js b/test/parallel/test-buffer-readuintle.js new file mode 100644 index 0000000000..982adb8607 --- /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' +);