--- /dev/null
+var Buffer = require('../../').Buffer
+if (process.env.OBJECT_IMPL) Buffer.TYPED_ARRAY_SUPPORT = false
+var common = {};
+var assert = require('assert');
+
+var Buffer = require('../../').Buffer;
+
+var b = new Buffer('abcdef');
+var buf_a = new Buffer('a');
+var buf_bc = new Buffer('bc');
+var buf_f = new Buffer('f');
+var buf_z = new Buffer('z');
+var buf_empty = new Buffer('');
+
+assert.equal(b.indexOf('a'), 0);
+assert.equal(b.indexOf('a', 1), -1);
+assert.equal(b.indexOf('a', -1), -1);
+assert.equal(b.indexOf('a', -4), -1);
+assert.equal(b.indexOf('a', -b.length), 0);
+assert.equal(b.indexOf('a', NaN), 0);
+assert.equal(b.indexOf('a', -Infinity), 0);
+assert.equal(b.indexOf('a', Infinity), -1);
+assert.equal(b.indexOf('bc'), 1);
+assert.equal(b.indexOf('bc', 2), -1);
+assert.equal(b.indexOf('bc', -1), -1);
+assert.equal(b.indexOf('bc', -3), -1);
+assert.equal(b.indexOf('bc', -5), 1);
+assert.equal(b.indexOf('bc', NaN), 1);
+assert.equal(b.indexOf('bc', -Infinity), 1);
+assert.equal(b.indexOf('bc', Infinity), -1);
+assert.equal(b.indexOf('f'), b.length - 1);
+assert.equal(b.indexOf('z'), -1);
+assert.equal(b.indexOf(''), -1);
+assert.equal(b.indexOf('', 1), -1);
+assert.equal(b.indexOf('', b.length + 1), -1);
+assert.equal(b.indexOf('', Infinity), -1);
+assert.equal(b.indexOf(buf_a), 0);
+assert.equal(b.indexOf(buf_a, 1), -1);
+assert.equal(b.indexOf(buf_a, -1), -1);
+assert.equal(b.indexOf(buf_a, -4), -1);
+assert.equal(b.indexOf(buf_a, -b.length), 0);
+assert.equal(b.indexOf(buf_a, NaN), 0);
+assert.equal(b.indexOf(buf_a, -Infinity), 0);
+assert.equal(b.indexOf(buf_a, Infinity), -1);
+assert.equal(b.indexOf(buf_bc), 1);
+assert.equal(b.indexOf(buf_bc, 2), -1);
+assert.equal(b.indexOf(buf_bc, -1), -1);
+assert.equal(b.indexOf(buf_bc, -3), -1);
+assert.equal(b.indexOf(buf_bc, -5), 1);
+assert.equal(b.indexOf(buf_bc, NaN), 1);
+assert.equal(b.indexOf(buf_bc, -Infinity), 1);
+assert.equal(b.indexOf(buf_bc, Infinity), -1);
+assert.equal(b.indexOf(buf_f), b.length - 1);
+assert.equal(b.indexOf(buf_z), -1);
+assert.equal(b.indexOf(buf_empty), -1);
+assert.equal(b.indexOf(buf_empty, 1), -1);
+assert.equal(b.indexOf(buf_empty, b.length + 1), -1);
+assert.equal(b.indexOf(buf_empty, Infinity), -1);
+assert.equal(b.indexOf(0x61), 0);
+assert.equal(b.indexOf(0x61, 1), -1);
+assert.equal(b.indexOf(0x61, -1), -1);
+assert.equal(b.indexOf(0x61, -4), -1);
+assert.equal(b.indexOf(0x61, -b.length), 0);
+assert.equal(b.indexOf(0x61, NaN), 0);
+assert.equal(b.indexOf(0x61, -Infinity), 0);
+assert.equal(b.indexOf(0x61, Infinity), -1);
+assert.equal(b.indexOf(0x0), -1);
+
+assert.throws(function() {
+ b.indexOf(function() { });
+});
+assert.throws(function() {
+ b.indexOf({});
+});
+assert.throws(function() {
+ b.indexOf([]);
+});
+
var Buffer = require('../../').Buffer
if (process.env.OBJECT_IMPL) Buffer.TYPED_ARRAY_SUPPORT = false
-// var common = require('../common');
+var common = {};
var assert = require('assert');
var Buffer = require('../../').Buffer;
new SlowBuffer(smalloc.kMaxLength + 1);
}, RangeError);
-// Test truncation after decode
-// var crypto = require('crypto');
+if (common.hasCrypto) {
+ // Test truncation after decode
+ var crypto = require('crypto');
-var b1 = new Buffer('YW55=======', 'base64');
-var b2 = new Buffer('YW55', 'base64');
+ var b1 = new Buffer('YW55=======', 'base64');
+ var b2 = new Buffer('YW55', 'base64');
-assert.equal(
- 1 /*crypto.createHash('sha1').update(b1).digest('hex')*/,
- 1 /*crypto.createHash('sha1').update(b2).digest('hex')*/
-);
+ assert.equal(
+ 1 /*crypto.createHash('sha1').update(b1).digest('hex')*/,
+ 1 /*crypto.createHash('sha1').update(b2).digest('hex')*/
+ );
+} else {
+// console.log('1..0 # Skipped: missing crypto');
+}
// Test Compare
var b = new Buffer(1).fill('a');
// Regression test for https://github.com/iojs/io.js/issues/649.
assert.throws(function() { Buffer(1422561062959).toString('utf8'); });
+var ps = Buffer.poolSize;
+Buffer.poolSize = 0;
+assert.equal(Buffer(1).parent, undefined);
+Buffer.poolSize = ps;
+