UINT64_rotateLeft-test.js 899 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. var assert = require('assert')
  2. var UINT64 = require('..').UINT64
  3. describe('rotateLeft method', function () {
  4. describe('0rotl1', function () {
  5. it('should return 0', function (done) {
  6. var u = UINT64(0).rotateLeft(1)
  7. assert.equal( u.toNumber(), 0 )
  8. done()
  9. })
  10. })
  11. describe('1rotl2', function () {
  12. it('should return 4', function (done) {
  13. var u = UINT64(1).rotateLeft(2)
  14. assert.equal( u.toNumber(), 4 )
  15. done()
  16. })
  17. })
  18. describe('1rotl16', function () {
  19. it('should return 2^16', function (done) {
  20. var n = Math.pow(2, 16)
  21. var u = UINT64(1).rotateLeft(16)
  22. assert.equal( u.toNumber(), n )
  23. done()
  24. })
  25. })
  26. describe('1rotl32', function () {
  27. it('should return 1', function (done) {
  28. var u = UINT64(1).rotateLeft(32)
  29. assert.equal( u.toString(16), '100000000' )
  30. done()
  31. })
  32. })
  33. })