Skip to content

Commit 0dd6e4a

Browse files
HarshithaKPBridgeAR
authored andcommitted
test: buffer.write with longer string scenario
Make sure longer strings are written up to the buffer end Refs: #32119 PR-URL: #32123 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 04f2caa commit 0dd6e4a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

test/parallel/test-buffer-write.js

+3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ for (let i = 1; i < 4; i++) {
9090
const z = Buffer.alloc(4, 0);
9191
assert.strictEqual(z.write('\u0001', 3, 'ucs2'), 0);
9292
assert.strictEqual(Buffer.compare(z, Buffer.alloc(4, 0)), 0);
93+
// Make sure longer strings are written up to the buffer end.
94+
assert.strictEqual(z.write('abcd', 2), 2);
95+
assert.deepStrictEqual([...z], [0, 0, 0x61, 0x62]);
9396

9497
// Large overrun could corrupt the process
9598
assert.strictEqual(Buffer.alloc(4)

0 commit comments

Comments
 (0)