|
|
@ -1,6 +1,7 @@
|
|
|
|
package main
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"sort"
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
|
|
utils "github.com/0xAX/go-algorithms"
|
|
|
|
utils "github.com/0xAX/go-algorithms"
|
|
|
@ -29,7 +30,7 @@ func TestSort(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
tt.f(arr)
|
|
|
|
tt.f(arr)
|
|
|
|
|
|
|
|
|
|
|
|
if !isSorted(arr) {
|
|
|
|
if !sort.IntsAreSorted(arr) {
|
|
|
|
t.Errorf("%v is not sorted", arr)
|
|
|
|
t.Errorf("%v is not sorted", arr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -51,13 +52,3 @@ func BenchmarkSort(b *testing.B) {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func isSorted(arr []int) bool {
|
|
|
|
|
|
|
|
for i := 0; i < len(arr) - 1; i++ {
|
|
|
|
|
|
|
|
if arr[i] > arr[i + 1] {
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|