GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: improve internal/buffer.js test coverage · nodejs/node@17954c2

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-buffer-readint.js
    • test-buffer-readuint.js
    • test-buffer-writeint.js
    • test-buffer-writeuint.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-buffer-readint.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-buffer-readint.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ const assert = require('assert');
169169
});
170170

171171
// Test 1 to 6 bytes.
172-
for (let i = 1; i < 6; i++) {
172+
for (let i = 1; i <= 6; i++) {
173173
['readIntBE', 'readIntLE'].forEach((fn) => {
174174
['', '0', null, {}, [], () => {}, true, false].forEach((o) => {
175175
assert.throws(
Collapse file

‎test/parallel/test-buffer-readuint.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-buffer-readuint.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const assert = require('assert');
130130
});
131131

132132
// Test 1 to 6 bytes.
133-
for (let i = 1; i < 6; i++) {
133+
for (let i = 1; i <= 6; i++) {
134134
['readUIntBE', 'readUIntLE'].forEach((fn) => {
135135
['', '0', null, {}, [], () => {}, true, false].forEach((o) => {
136136
assert.throws(
Collapse file

‎test/parallel/test-buffer-writeint.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-buffer-writeint.js
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,21 @@ const errorOutOfBounds = common.expectsError({
162162
});
163163
}
164164

165+
// Test 48 bit
166+
{
167+
const value = 0x1234567890ab;
168+
const buffer = Buffer.allocUnsafe(6);
169+
buffer.writeIntBE(value, 0, 6);
170+
assert.ok(buffer.equals(new Uint8Array([
171+
0x12, 0x34, 0x56, 0x78, 0x90, 0xab
172+
])));
173+
174+
buffer.writeIntLE(value, 0, 6);
175+
assert.ok(buffer.equals(new Uint8Array([
176+
0xab, 0x90, 0x78, 0x56, 0x34, 0x12
177+
])));
178+
}
179+
165180
// Test Int
166181
{
167182
const data = Buffer.alloc(8);
Collapse file

‎test/parallel/test-buffer-writeuint.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-buffer-writeuint.js
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,17 @@ const assert = require('assert');
110110
assert.ok(data.equals(new Uint8Array([0x6d, 0x6d, 0x6d, 0x0a, 0xf9, 0xe7])));
111111
}
112112

113+
// Test 48 bit
114+
{
115+
const value = 0x1234567890ab;
116+
const data = Buffer.allocUnsafe(6);
117+
data.writeUIntBE(value, 0, 6);
118+
assert.ok(data.equals(new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x90, 0xab])));
119+
120+
data.writeUIntLE(value, 0, 6);
121+
assert.ok(data.equals(new Uint8Array([0xab, 0x90, 0x78, 0x56, 0x34, 0x12])));
122+
}
123+
113124
// Test UInt
114125
{
115126
const data = Buffer.alloc(8);

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.