Skip to content

Commit 826decf

Browse files
larissayvetteevanlucas
authored andcommitted
test: basic functionality of readUIntBE()
PR-URL: #10417 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: Julian Duque <[email protected]>
1 parent 6d15e7b commit 826decf

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
require('../common');
3+
const assert = require('assert');
4+
5+
// testing basic functionality of readUIntBE()
6+
7+
const buf = Buffer.from([42, 84, 168, 127]);
8+
const result = buf.readUIntBE(2);
9+
10+
assert.strictEqual(result, 84);
11+
12+
assert.throws(
13+
() => {
14+
buf.readUIntBE(5);
15+
},
16+
/Index out of range/
17+
);
18+
19+
assert.doesNotThrow(
20+
() => {
21+
buf.readUIntBE(5, 0, true);
22+
},
23+
'readUIntBE() should not throw if noAssert is true'
24+
);

0 commit comments

Comments
 (0)