Example #1
0
  buf.writeFloatLE(0.0, -1);
}, RangeError);

// offset checks
{
  const buf = new Buffer(0);

  assert.throws(function() { buf.readUInt8(0); }, RangeError);
  assert.throws(function() { buf.readInt8(0); }, RangeError);
}

{
  const buf = new Buffer([0xFF]);

  assert.equal(buf.readUInt8(0), 255);
  assert.equal(buf.readInt8(0), -1);
}

[16, 32].forEach(function(bits) {
  var buf = new Buffer(bits / 8 - 1);

  assert.throws(function() { buf['readUInt' + bits + 'BE'](0); },
                RangeError,
                'readUInt' + bits + 'BE');

  assert.throws(function() { buf['readUInt' + bits + 'LE'](0); },
                RangeError,
                'readUInt' + bits + 'LE');

  assert.throws(function() { buf['readInt' + bits + 'BE'](0); },
                RangeError,
Example #2
0
assert.throws(function() { buf.readInt8(0); }, /beyond buffer length/);
Example #3
0
assert.throws(function() { buf.readInt8(0); }, RangeError);