You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* global describe, it */
  2. var assert = require('assert')
  3. var xor = require('../')
  4. var xorInplace = require('../inplace')
  5. var fixtures = require('./fixtures')
  6. describe('xor', function () {
  7. fixtures.forEach(function (f) {
  8. it('returns ' + f.expected + ' for ' + f.a + '/' + f.b, function () {
  9. var a = new Buffer(f.a, 'hex')
  10. var b = new Buffer(f.b, 'hex')
  11. var actual = xor(a, b)
  12. assert.equal(actual.toString('hex'), f.expected)
  13. // a/b unchanged
  14. assert.equal(a.toString('hex'), f.a)
  15. assert.equal(b.toString('hex'), f.b)
  16. })
  17. })
  18. })
  19. describe('xor/inplace', function () {
  20. fixtures.forEach(function (f) {
  21. it('returns ' + f.expected + ' for ' + f.a + '/' + f.b, function () {
  22. var a = new Buffer(f.a, 'hex')
  23. var b = new Buffer(f.b, 'hex')
  24. var actual = xorInplace(a, b)
  25. assert.equal(actual.toString('hex'), f.expected)
  26. // a mutated, b unchanged
  27. assert.equal(a.toString('hex'), f.mutated || f.expected)
  28. assert.equal(b.toString('hex'), f.b)
  29. })
  30. })
  31. })