Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions test/parallel/test-buffer-copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ let cntr = 0;
b.fill(++cntr);
c.fill(++cntr);
const copied = b.copy(c, 0, 0, 512);
assert.strictEqual(512, copied);
assert.strictEqual(copied, 512);
for (let i = 0; i < c.length; i++) {
assert.strictEqual(b[i], c[i]);
assert.strictEqual(c[i], b[i]);
}
}

Expand All @@ -23,9 +23,9 @@ let cntr = 0;
b.fill(++cntr);
c.fill(++cntr);
const copied = c.copy(b, 0, 0);
assert.strictEqual(c.length, copied);
assert.strictEqual(copied, c.length);
for (let i = 0; i < c.length; i++) {
assert.strictEqual(c[i], b[i]);
assert.strictEqual(b[i], c[i]);
}
}

Expand All @@ -34,9 +34,9 @@ let cntr = 0;
b.fill(++cntr);
c.fill(++cntr);
const copied = c.copy(b, 0);
assert.strictEqual(c.length, copied);
assert.strictEqual(copied, c.length);
for (let i = 0; i < c.length; i++) {
assert.strictEqual(c[i], b[i]);
assert.strictEqual(b[i], c[i]);
}
}

Expand All @@ -45,9 +45,9 @@ let cntr = 0;
b.fill(++cntr);
c.fill(++cntr);
const copied = b.copy(c);
assert.strictEqual(c.length, copied);
assert.strictEqual(copied, c.length);
for (let i = 0; i < c.length; i++) {
assert.strictEqual(b[i], c[i]);
assert.strictEqual(c[i], b[i]);
}
}

Expand All @@ -56,9 +56,9 @@ let cntr = 0;
b.fill(++cntr);
c.fill(++cntr);
const copied = b.copy(c, 0, b.length - Math.floor(c.length / 2));
assert.strictEqual(Math.floor(c.length / 2), copied);
assert.strictEqual(copied, Math.floor(c.length / 2));
for (let i = 0; i < Math.floor(c.length / 2); i++) {
assert.strictEqual(b[b.length - Math.floor(c.length / 2) + i], c[i]);
assert.strictEqual(c[i], b[b.length - Math.floor(c.length / 2) + i]);
}
for (let i = Math.floor(c.length / 2) + 1; i < c.length; i++) {
assert.strictEqual(c[c.length - 1], c[i]);
Expand All @@ -70,9 +70,9 @@ let cntr = 0;
b.fill(++cntr);
c.fill(++cntr);
const copied = b.copy(c, 0, 0, 513);
assert.strictEqual(c.length, copied);
assert.strictEqual(copied, c.length);
for (let i = 0; i < c.length; i++) {
assert.strictEqual(b[i], c[i]);
assert.strictEqual(c[i], b[i]);
}
}

Expand All @@ -81,9 +81,9 @@ let cntr = 0;
b.fill(++cntr);
b.fill(++cntr, 256);
const copied = b.copy(b, 0, 256, 1024);
assert.strictEqual(768, copied);
assert.strictEqual(copied, 768);
for (let i = 0; i < b.length; i++) {
assert.strictEqual(cntr, b[i]);
assert.strictEqual(b[i], cntr);
}
}

Expand All @@ -106,7 +106,7 @@ assert.throws(function() {
c.fill(++cntr);
b.copy(c, 0, 0, 1025);
for (let i = 0; i < c.length; i++) {
assert.strictEqual(b[i], c[i]);
assert.strictEqual(c[i], b[i]);
}
}

Expand All @@ -126,9 +126,9 @@ assert.strictEqual(b.copy(c, 512, 0, 10), 0);
b.fill(++cntr);
d.fill(++cntr);
const copied = b.copy(d, 0, 0, 512);
assert.strictEqual(512, copied);
assert.strictEqual(copied, 512);
for (let i = 0; i < d.length; i++) {
assert.strictEqual(b[i], d[i]);
assert.strictEqual(d[i], b[i]);
}
}

Expand All @@ -139,8 +139,8 @@ assert.strictEqual(b.copy(c, 512, 0, 10), 0);
e.fill(++cntr);
c.fill(++cntr);
const copied = Buffer.prototype.copy.call(e, c, 0, 0, 512);
assert.strictEqual(512, copied);
assert.strictEqual(copied, 512);
for (let i = 0; i < c.length; i++) {
assert.strictEqual(e[i], c[i]);
assert.strictEqual(c[i], e[i]);
}
}