You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
360 B
Go
26 lines
360 B
Go
package comb_sort
|
|
|
|
import (
|
|
sortable "github.com/0xAX/go-algorithms/sort"
|
|
"math/rand"
|
|
"testing"
|
|
)
|
|
|
|
func TestSort(t *testing.T) {
|
|
var s = make(sortable.IntSlice, 10)
|
|
|
|
for i := 0; i < 10; i++ {
|
|
s[i] = rand.Intn(i + 1)
|
|
}
|
|
|
|
Sort(&s)
|
|
|
|
for i := 0; i < 10; i++ {
|
|
if i != 9 {
|
|
if s[i] > s[i+1] {
|
|
t.Fatal("s[i] > s[i + 1]", s[i], s[i+1])
|
|
}
|
|
}
|
|
}
|
|
}
|