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

41 lines
797 B

  1. package helper
  2. import (
  3. "fmt"
  4. "testing"
  5. )
  6. func Test_Diff(t *testing.T) {
  7. var aa = []string{"43", "33"}
  8. var bb = []string{"2", "33", "1"}
  9. cc := Diff(aa, bb)
  10. fmt.Println(cc)
  11. }
  12. func Test_Intersect(t *testing.T) {
  13. var aa = []string{"43", "33"}
  14. var bb = []string{"2", "33", "1"}
  15. cc := Intersect(aa, bb)
  16. fmt.Println(cc)
  17. }
  18. func Test_Union(t *testing.T) {
  19. var aa = []string{"43", "33"}
  20. var bb = []string{"2", "33", "1"}
  21. cc := Union(aa, bb)
  22. fmt.Println(cc)
  23. }
  24. func Test_Unique(t *testing.T) {
  25. var str = []string{"1", "2", "2"}
  26. ret, err := Unique(str)
  27. fmt.Println(ret, err)
  28. }
  29. func Test_StringSliceSort(t *testing.T) {
  30. var str = []string{"10", "2", "5"}
  31. ret, err := StringSliceSort(str,"asc")
  32. fmt.Println(ret, err)
  33. ret2, err := StringSliceSort(str,"desc")
  34. fmt.Println(ret2, err)
  35. }