diff --git a/test/capacity_test.js b/test/capacity_test.js index c3d635e..04f504d 100644 --- a/test/capacity_test.js +++ b/test/capacity_test.js @@ -18,16 +18,18 @@ it('Does not increase capacity when there is sufficient capacity', () => { }) it('Uses exponential doubling capacity scaling', () => { - const res1 = CalculateCapacity(8192, 8193, 1024 * 1024) - assert.deepEqual(res1, [true, 16384]) - const res2 = CalculateCapacity(16384, 16385, 1024 * 1024) - assert.deepEqual(res2, [true, 32768]) + // Capacities at or above Buffer.poolSize are unaffected by the minimum-capacity + // floor, so these exercise pure doubling regardless of the platform's pool size. + const res1 = CalculateCapacity(Buffer.poolSize, Buffer.poolSize + 1, 1024 * 1024) + assert.deepEqual(res1, [true, Buffer.poolSize * 2]) + const res2 = CalculateCapacity(Buffer.poolSize * 2, Buffer.poolSize * 2 + 1, 1024 * 1024) + assert.deepEqual(res2, [true, Buffer.poolSize * 4]) }) it('Uses required capacity when it exceeds doubling', () => { - const [resize, newCapacity] = CalculateCapacity(1024, 16384, 1024 * 1024) + const [resize, newCapacity] = CalculateCapacity(Buffer.poolSize, Buffer.poolSize * 4, 1024 * 1024) assert.equal(resize, true) - assert.equal(newCapacity, 16384) + assert.equal(newCapacity, Buffer.poolSize * 4) }) it('Does not exceed max over allocation', () => {