string_test.go 780 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package util
  2. import (
  3. "fmt"
  4. "testing"
  5. "time"
  6. )
  7. func TestSplitChar(t *testing.T) {
  8. {
  9. char := SplitIgnoreSpace(" hello.world ", ".")
  10. fmt.Println(char)
  11. }
  12. {
  13. char := SplitIgnoreSpace(".hello.world", ".")
  14. fmt.Println(char)
  15. }
  16. {
  17. char := SplitIgnoreSpace("hello. .world.", ".")
  18. fmt.Println(char)
  19. }
  20. {
  21. char := SplitIgnoreSpace(".hello.world.", ".")
  22. fmt.Println(char)
  23. }
  24. }
  25. func TestToString(t *testing.T) {
  26. t.Log(ToString("11111"))
  27. t.Log(ToString(1111))
  28. t.Log(ToString(1111.111))
  29. t.Log(ToString(time.Now()))
  30. t.Log(ToString([]string{"1", "2"}))
  31. t.Log(ToString(map[string]string{"1": "2", "2": "3"}))
  32. }
  33. func TestJoinIgnoreSpace(t *testing.T) {
  34. t.Log(JoinIgnoreSpace([]string{"1", "2", "3"}, ","))
  35. t.Log(JoinIgnoreSpace([]string{"1", "", "3"}, " || "))
  36. }