func TestStrings(t *testing.T) { data := strings for _, alg := range algorithms { sorting.Strings(data[:], alg) if !sort.StringsAreSorted(data[:]) { t.Errorf("%v\n", util.GetFuncName(alg)) t.Errorf("sorted: %v\n", strings) t.Errorf(" got: %v\n", data) } } }
func TestFloat64s(t *testing.T) { data := float64s for _, alg := range algorithms { sorting.Float64s(data[:], alg) if !sort.Float64sAreSorted(data[:]) { t.Errorf("%v\n", util.GetFuncName(alg)) t.Errorf("sorted: %v\n", float64s) t.Errorf(" got: %v\n", data) } } }
func TestInts(t *testing.T) { data := ints for _, alg := range algorithms { sorting.Ints(data[:], alg) if !sort.IntsAreSorted(data[:]) { t.Errorf("%v\n", util.GetFuncName(alg)) t.Errorf("sorted: %v\n", ints) t.Errorf(" got: %v\n", data) } } }
func TestSortStringSlice(t *testing.T) { data := strings for _, alg := range algorithms { a := sort.StringSlice(data[:]) alg(a) if !sort.IsSorted(a) { t.Errorf("%v\n", util.GetFuncName(alg)) t.Errorf("sorted: %v\n", strings) t.Errorf(" got: %v\n", data) } } }
func TestSortLarge_Random(t *testing.T) { n := 10000 if testing.Short() { n /= 100 } data := make([]int, n) for i := 0; i < len(data); i++ { data[i] = rand.Intn(100) } if sort.IntsAreSorted(data) { t.Fatalf("terrible rand.rand") } for _, alg := range algorithms { sorting.Ints(data, alg) if !sort.IntsAreSorted(data) { t.Errorf("%v failed to sort 10K ints\n", util.GetFuncName(alg)) } } }