常用类型及数据操作方法
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.

62 lines
1.3 KiB

3 years ago
3 years ago
3 years ago
  1. package helper
  2. import (
  3. "fmt"
  4. "strings"
  5. "testing"
  6. )
  7. func Test_ToInt64(t *testing.T) {
  8. var str interface{} = 45.00
  9. ret := ToInt64(str)
  10. t.Log(ret)
  11. }
  12. func Test_GetRandomNumber(t *testing.T) {
  13. rand := GetRandomNumber(8)
  14. fmt.Println(rand)
  15. }
  16. func Test_GetRandomString(t *testing.T) {
  17. rand := GetRandomString(25)
  18. fmt.Println(rand)
  19. }
  20. func Test_DeleteExtraSpace(t *testing.T) {
  21. s := "c s dfdf dff df x"
  22. s2 := DeleteExtraSpace(s)
  23. t.Log(s2)
  24. }
  25. func Test_StringJoin(t *testing.T) {
  26. s1 := "testing"
  27. s2 := "测试一"
  28. s3 := "二"
  29. s4 := " ,s e"
  30. fmt.Println(StringJoin(s1, s2, s3, s4))
  31. }
  32. func Test_ToString(t *testing.T) {
  33. var str float64 = 0.15
  34. t.Log(str)
  35. ret := ToString(str)
  36. t.Log(ret)
  37. }
  38. func Test_StrFirstToUpper(t *testing.T) {
  39. var str string = "departmentID"
  40. ret := StrFirstToUpper(str)
  41. t.Log(ret)
  42. }
  43. func Test_ToInt(t *testing.T) {
  44. var str string = "sd23455667,123456789aq,qq123456789"
  45. ret := ToInt(str)
  46. t.Log(ret)
  47. }
  48. func Test_IsInStringArray(t *testing.T) {
  49. var s string = "1,19,37,220,351,466,585,655,801,820,933,1046,1168,1263,1375,1532,1709,1827,1965,1977,1988,2003,2011,2017,2025,2035,2041,2050,2056,2065,2070,2077,2082,2091,2123,2146,2150,2156,2162,2291,2323,2367,2572,2670,2816,2898,3022,3126,3178,3206,3325,3716,3738"
  50. arr := strings.Split(s, ",")
  51. t.Log(IsInStringArray(arr, "351"))
  52. }