Sha256: 604643b54da2754aadeb45555409032a497b296b6ee6ba6276b847566d2945e4

Contents?: true

Size: 840 Bytes

Versions: 6

Compression:

Stored size: 840 Bytes

Contents

'use strict';
var Buffer = require('../../').Buffer;
if (Buffer.TYPED_ARRAY_SUPPORT) return;
// Flags: --zero-fill-buffers

// when using --zero-fill-buffers, every Buffer and SlowBuffer
// instance must be zero filled upon creation


var SlowBuffer = require('../../').SlowBuffer;
var assert = require('assert');

function isZeroFilled(buf) {
  for (var n = 0; n < buf.length; n++)
    if (buf[n] > 0) return false;
  return true;
}

// This can be somewhat unreliable because the
// allocated memory might just already happen to
// contain all zeroes. The test is run multiple
// times to improve the reliability.
for (var i = 0; i < 50; i++) {
  var bufs = [
    Buffer.alloc(20),
    Buffer.allocUnsafe(20),
    SlowBuffer(20),
    Buffer(20),
    new SlowBuffer(20)
  ];
  for (var buf of bufs) {
    assert(isZeroFilled(buf));
  }
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
brwy_rails-0.0.6 test/dummy/node_modules/buffer/test/node/test-buffer-zero-fill-cli.js
brwy_rails-0.0.5 test/dummy/node_modules/buffer/test/node/test-buffer-zero-fill-cli.js
brwy_rails-0.0.4 test/dummy/node_modules/buffer/test/node/test-buffer-zero-fill-cli.js
brwy_rails-0.0.3 test/dummy/node_modules/buffer/test/node/test-buffer-zero-fill-cli.js
brwy_rails-0.0.2 test/dummy/node_modules/buffer/test/node/test-buffer-zero-fill-cli.js
brwy_rails-0.0.1 test/dummy/node_modules/buffer/test/node/test-buffer-zero-fill-cli.js