From 826decf8e5ea3b54079006878ef92018fc26973f Mon Sep 17 00:00:00 2001 From: larissayvette Date: Thu, 22 Dec 2016 00:29:38 +0100 Subject: [PATCH] test: basic functionality of readUIntBE() PR-URL: https://github.com/nodejs/node/pull/10417 Reviewed-By: James M Snell Reviewed-By: Rich Trott Reviewed-By: Italo A. Casas Reviewed-By: Julian Duque --- test/parallel/test-buffer-readuintbe.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/parallel/test-buffer-readuintbe.js diff --git a/test/parallel/test-buffer-readuintbe.js b/test/parallel/test-buffer-readuintbe.js new file mode 100644 index 00000000000000..162e9fea27a14f --- /dev/null +++ b/test/parallel/test-buffer-readuintbe.js @@ -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' +);