regx_test.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package regx
  2. import (
  3. "share/logging"
  4. "testing"
  5. )
  6. func init() {
  7. logging.SetLogModel(true, true)
  8. }
  9. func TestIsChineseString(t *testing.T) {
  10. s := "全是中文吗"
  11. logging.Info("test string: %v", s)
  12. if IsChineseString(s) {
  13. logging.Info("pass")
  14. } else {
  15. logging.Info("no pass")
  16. }
  17. s += " "
  18. logging.Info("test string: %v", s)
  19. if IsChineseString(s) {
  20. logging.Info("pass")
  21. } else {
  22. logging.Info("no pass")
  23. }
  24. }
  25. func TestIsDecNumber(t *testing.T) {
  26. s := "1234789"
  27. logging.Info("test string: %v", s)
  28. if IsDecNumber(s) {
  29. logging.Info("pass")
  30. } else {
  31. logging.Info("no pass")
  32. }
  33. s = "1234789"
  34. logging.Info("test string: %v", s)
  35. if IsDecNumber(s) {
  36. logging.Info("pass")
  37. } else {
  38. logging.Info("no pass")
  39. }
  40. }
  41. func TestIsOctNumber(t *testing.T) {
  42. s := "-0111"
  43. logging.Info("test string: %v", s)
  44. if IsOctNumber(s) {
  45. logging.Info("pass")
  46. } else {
  47. logging.Info("no pass")
  48. }
  49. }
  50. func TestIsHexNumber(t *testing.T) {
  51. s := "0X0012312ae"
  52. logging.Info("test string: %v", s)
  53. if IsHexNumber(s) {
  54. logging.Info("pass")
  55. } else {
  56. logging.Info("no pass")
  57. }
  58. }
  59. func TestIsBinNumber(t *testing.T) {
  60. s := "01111"
  61. logging.Info("test string: %v", s)
  62. if IsBinNumber(s) {
  63. logging.Info("pass")
  64. } else {
  65. logging.Info("no pass")
  66. }
  67. }