basic.js 982 B

12345678910111213141516171819202122232425
  1. var buffer = require('buffer')
  2. var isBuffer = require('../')
  3. var test = require('tape')
  4. test('is-buffer', function (t) {
  5. t.equal(isBuffer(new Buffer(4)), true, 'new Buffer(4)')
  6. t.equal(isBuffer(buffer.SlowBuffer(100)), true, 'SlowBuffer(100)')
  7. t.equal(isBuffer(undefined), false, 'undefined')
  8. t.equal(isBuffer(null), false, 'null')
  9. t.equal(isBuffer(''), false, 'empty string')
  10. t.equal(isBuffer(true), false, 'true')
  11. t.equal(isBuffer(false), false, 'false')
  12. t.equal(isBuffer(0), false, '0')
  13. t.equal(isBuffer(1), false, '1')
  14. t.equal(isBuffer(1.0), false, '1.0')
  15. t.equal(isBuffer('string'), false, 'string')
  16. t.equal(isBuffer({}), false, '{}')
  17. t.equal(isBuffer([]), false, '[]')
  18. t.equal(isBuffer(function foo () {}), false, 'function foo () {}')
  19. t.equal(isBuffer({ isBuffer: null }), false, '{ isBuffer: null }')
  20. t.equal(isBuffer({ isBuffer: function () { throw new Error() } }), false, '{ isBuffer: function () { throw new Error() } }')
  21. t.end()
  22. })