UINT32_toString-test.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. var assert = require('assert')
  2. var UINT32 = require('..').UINT32
  3. describe('toString method', function () {
  4. describe('from 0', function () {
  5. it('should return "0"', function (done) {
  6. var u = UINT32(0).toString()
  7. assert.equal( u, '0' )
  8. done()
  9. })
  10. })
  11. describe('from low bit number', function () {
  12. it('should return the number', function (done) {
  13. var u = UINT32(123).toString()
  14. assert.equal( u, '123' )
  15. done()
  16. })
  17. })
  18. describe('from high bit number', function () {
  19. it('should return the number', function (done) {
  20. var n = Math.pow(2,17)
  21. var u = UINT32(n).toString()
  22. assert.equal( u, ''+n )
  23. done()
  24. })
  25. })
  26. describe('from high and low bit number', function () {
  27. it('should return the number', function (done) {
  28. var n = Math.pow(2,17) + 123
  29. var u = UINT32(n).toString()
  30. assert.equal( u, ''+n )
  31. done()
  32. })
  33. })
  34. describe('< radix', function () {
  35. it('should return the number', function (done) {
  36. var u = UINT32(4).toString()
  37. assert.equal( u, '4' )
  38. done()
  39. })
  40. })
  41. describe('= radix', function () {
  42. it('should return the number', function (done) {
  43. var u = UINT32(2).toString(2)
  44. assert.equal( u, '10' )
  45. done()
  46. })
  47. })
  48. })