isByteValue.js 656 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. var test = require('tape');
  3. var forEach = require('foreach');
  4. var debug = require('object-inspect');
  5. var isByteValue = require('../../helpers/isByteValue');
  6. var v = require('es-value-fixtures');
  7. test('isByteValue', function (t) {
  8. forEach([].concat(
  9. v.notNonNegativeIntegers,
  10. -1,
  11. -42,
  12. -Infinity,
  13. Infinity,
  14. v.nonIntegerNumbers
  15. ), function (nonByteValue) {
  16. t.equal(isByteValue(nonByteValue), false, debug(nonByteValue) + ' is not a byte value');
  17. });
  18. for (var i = 0; i <= 255; i += 1) {
  19. t.equal(isByteValue(i), true, i + ' is a byte value');
  20. }
  21. t.equal(isByteValue(256), false, '256 is not a byte value');
  22. t.end();
  23. });