- IsPointInPolygon added
This commit is contained in:
31
utils/utils_sort_test.go
Normal file
31
utils/utils_sort_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"sort"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSort(t *testing.T) {
|
||||
randIntList := make([]int, 100)
|
||||
for k := range randIntList {
|
||||
randIntList[k] = rand.Int()
|
||||
}
|
||||
copiedList := make([]int, len(randIntList))
|
||||
copy(copiedList, randIntList)
|
||||
sort.Sort(sort.IntSlice(randIntList))
|
||||
|
||||
sortList := make(SortList, len(copiedList))
|
||||
for k := range copiedList {
|
||||
sortList[k] = &SortItem{
|
||||
CompareValue: int64(copiedList[k]),
|
||||
Index: k,
|
||||
}
|
||||
}
|
||||
sort.Sort(sortList)
|
||||
for k := range randIntList {
|
||||
if randIntList[k] != copiedList[sortList[k].Index] {
|
||||
t.Fatal("排序出错")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user