package utils import ( "fmt" "github.com/stretchr/testify/assert" "testing" ) func TestIsContain(t *testing.T) { ass := assert.New(t) // test Int intSlice := []int{1, 2, 3} ass.Equal(true, IsContain(intSlice, 1)) ass.Equal(false, IsContain(intSlice, 5)) // test String stringSlice := []string{"1", "2", "3"} ass.Equal(true, IsContain(stringSlice, "1")) ass.Equal(false, IsContain(stringSlice, "5")) // test Map mapSlice := []map[string]interface{}{{"id": 1}, {"id": 2}} ass.Equal(true, IsContain(mapSlice, map[string]interface{}{"id": 1})) ass.Equal(false, IsContain(mapSlice, map[string]interface{}{"id": 3})) // test Slice sliceSlice := [][]int{{1, 1, 1}, {2, 2, 2}} ass.Equal(true, IsContain(sliceSlice, []int{1, 1, 1})) ass.Equal(false, IsContain(sliceSlice, []int{1, 1, 2})) //test Struct type TestStruct struct { ID int } structSlice := []TestStruct{{ID: 1}} ass.Equal(true, IsContain(structSlice, TestStruct{ID: 1})) ass.Equal(false, IsContain(structSlice, TestStruct{ID: 2})) } func TestCheckMobile(t *testing.T) { ass := assert.New(t) ass.Equal(true, CheckMobile("18007097771")) ass.Equal(true, CheckMobile("19507097771")) } func TestRandomOrder(t *testing.T) { fmt.Println(RandomOrder("10", 2)) }