package jxutils import ( "fmt" "testing" "git.rosy.net.cn/baseapi/utils" ) func TestSplitSlice(t *testing.T) { testValue1 := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} list := utils.Interface2Slice(testValue1) result := SplitSlice(list, 3) if !(len(result) == 4 && len(result[3]) == 1) { t.Log("result is not ok") } testValue2 := []string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"} list = utils.Interface2Slice(testValue2) result = SplitSlice(list, 1) if !(len(result) == 10 && len(result[3]) == 1) { t.Log("result is not ok") } t.Log(result) } func TestGetPolygonFromCircle(t *testing.T) { points := GetPolygonFromCircle(104.054727, 30.575362, 1000, 8) for _, v := range points { t.Log(fmt.Sprintf("lng=%f&lat=%f", v[0], v[1])) } t.Log(points) } func TestFakeID(t *testing.T) { id := GenFakeID() if !IsFakeID(id) { t.Fatalf("wrong result for id:%d", id) } id = 0 if !IsFakeID(id) { t.Fatalf("wrong result for id:%d", id) } id = 23424234 if IsFakeID(id) { t.Fatalf("wrong result for id:%d", id) } } func TestIsMobileFake(t *testing.T) { if IsMobileFake("13888888888") { t.Fatal("wrong 1") } if IsMobileFake("13888888888-123") { t.Fatal("wrong 2") } if IsMobileFake("13888888888,123") { t.Fatal("wrong 3") } if !IsMobileFake("138****8888") { t.Fatal("wrong 4") } }