mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
test: buffer.write with longer string scenario
Make sure longer strings are written up to the buffer end Refs: https://github.com/nodejs/node/pull/32119 PR-URL: https://github.com/nodejs/node/pull/32123 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
1 parent
6dca708699
commit
7fcb8da777
1 file changed
+3
@@ -90,6 +90,9 @@ for (let i = 1; i < 4; i++) {
|
||||
const z = Buffer.alloc(4, 0);
|
||||
assert.strictEqual(z.write('\u0001', 3, 'ucs2'), 0);
|
||||
assert.strictEqual(Buffer.compare(z, Buffer.alloc(4, 0)), 0);
|
||||
// Make sure longer strings are written up to the buffer end.
|
||||
assert.strictEqual(z.write('abcd', 2), 2);
|
||||
assert.deepStrictEqual([...z], [0, 0, 0x61, 0x62]);
|
||||
|
||||
// Large overrun could corrupt the process
|
||||
assert.strictEqual(Buffer.alloc(4)
|
||||
|
||||
Reference in new issue
Block a user