Beispiel #1
0
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)
		}
	}
}
Beispiel #2
0
func benchString(b *testing.B, size int, algorithm func(sort.Interface)) {
	b.StopTimer()
	for i := 0; i < b.N; i++ {
		data := make([]string, size)
		for i := 0; i < len(data); i++ {
			data[i] = strconv.Itoa(i ^ 0x2cc)
		}
		b.StartTimer()
		sorting.Strings(data, algorithm)
		b.StopTimer()
	}
}