You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
540 B

4 years ago
  1. 'use strict';
  2. var Buffer = require('../../').Buffer;
  3. var assert = require('assert');
  4. var safe = Buffer.alloc(10);
  5. function isZeroFilled(buf) {
  6. for (var n = 0; n < buf.length; n++)
  7. if (buf[n] !== 0) return false;
  8. return true;
  9. }
  10. assert(isZeroFilled(safe));
  11. // Test that unsafe allocations doesn't affect subsequent safe allocations
  12. Buffer.allocUnsafe(10);
  13. assert(isZeroFilled(new Float64Array(10)));
  14. new Buffer(10);
  15. assert(isZeroFilled(new Float64Array(10)));
  16. Buffer.allocUnsafe(10);
  17. assert(isZeroFilled(Buffer.alloc(10)));