Permalink
Browse files

buffer: remove duplicate assertion tests

Many assertion tests are duplicated in buffer.js. These few could be easily
removed and still have all tests pass.
  • Loading branch information...
1 parent 5e4e87a commit 13c5db977190f926a213fc8ad7204e1febe36009 @trevnorris trevnorris committed with bnoordhuis Nov 9, 2012
Showing with 0 additions and 33 deletions.
  1. +0 −33 lib/buffer.js
View
33 lib/buffer.js
@@ -1047,15 +1047,6 @@ Buffer.prototype.writeInt8 = function(value, offset, noAssert) {
var buffer = this;
if (!noAssert) {
- assert.ok(value !== undefined && value !== null,
- 'missing value');
-
- assert.ok(offset !== undefined && offset !== null,
- 'missing offset');
-
- assert.ok(offset < buffer.length,
- 'Trying to write beyond buffer length');
-
verifsint(value, 0x7f, -0x80);
}
@@ -1068,18 +1059,6 @@ Buffer.prototype.writeInt8 = function(value, offset, noAssert) {
function writeInt16(buffer, value, offset, isBigEndian, noAssert) {
if (!noAssert) {
- assert.ok(value !== undefined && value !== null,
- 'missing value');
-
- assert.ok(typeof (isBigEndian) === 'boolean',
- 'missing or invalid endian');
-
- assert.ok(offset !== undefined && offset !== null,
- 'missing offset');
-
- assert.ok(offset + 1 < buffer.length,
- 'Trying to write beyond buffer length');
-
verifsint(value, 0x7fff, -0x8000);
}
@@ -1100,18 +1079,6 @@ Buffer.prototype.writeInt16BE = function(value, offset, noAssert) {
function writeInt32(buffer, value, offset, isBigEndian, noAssert) {
if (!noAssert) {
- assert.ok(value !== undefined && value !== null,
- 'missing value');
-
- assert.ok(typeof (isBigEndian) === 'boolean',
- 'missing or invalid endian');
-
- assert.ok(offset !== undefined && offset !== null,
- 'missing offset');
-
- assert.ok(offset + 3 < buffer.length,
- 'Trying to write beyond buffer length');
-
verifsint(value, 0x7fffffff, -0x80000000);
}

2 comments on commit 13c5db9

@mscdex

I could see how verifsint() can be used to verify that value is a number (and thus isn't null or undefined), but where are the other checks duplicated at?

@bnoordhuis
Node.js Foundation member

@mscdex In the non-member writeUInt*() functions.

Please sign in to comment.