stringTest.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * Created by Tony on 2017/4/7.
  3. */
  4. var test = require('tape');
  5. var strUtil = require('../../public/stringUtil');
  6. //test('some string test cases', function (t) {
  7. // var reg = /^\s*$/;
  8. // var foo = " ";
  9. // t.equal(reg.test(foo), true);
  10. // foo = null;
  11. // t.equal(reg.test(foo), true);
  12. // foo = undefined;
  13. // t.equal(reg.test(foo), true);
  14. // foo = "";
  15. // t.equal(reg.test(foo), true);
  16. // foo = 0;
  17. // t.equal(reg.test(foo), true);
  18. // t.end();
  19. //});
  20. //
  21. //test('check if string type', function(t){
  22. // var foo = "";
  23. // t.equal(typeof foo, 'string');
  24. // foo = " ";
  25. // t.equal(typeof foo, 'string');
  26. // foo = 0;
  27. // t.equal(typeof foo, 'number');
  28. // foo = true;
  29. // t.equal(typeof foo, 'boolean');
  30. // foo = {};
  31. // t.equal(typeof foo, 'object');
  32. // foo = function(){};
  33. // t.equal(typeof foo, 'function');
  34. // foo = [];
  35. // t.equal(Array.isArray(foo), true);
  36. // t.end();
  37. //})
  38. test('test number to Chinese', function(t){
  39. //t.equal(strUtil.convertNumToChinese(1, true), '壹');
  40. //t.equal(strUtil.convertNumToChinese(1, false), '一');
  41. t.equal(strUtil.convertNumToChinese(11, false), '一十一');
  42. t.equal(strUtil.convertNumToChinese(12, false), '一十二');
  43. t.equal(strUtil.convertNumToChinese(21, false), '二十一');
  44. //console.log(strUtil.convertNumToChinese(102, false));
  45. t.equal(strUtil.convertNumToChinese(102, false), '一百零二');
  46. t.end();
  47. })