Пример #1
0
func benchmarkMSort(i int, b *testing.B) {
	for j := 0; j < b.N; j++ {
		b.StopTimer()
		values := perm(i)
		b.StartTimer()
		mergesort.Sort(values)
	}
}
Пример #2
0
func TestMSort(t *testing.T) {
	expected := []int{3, 9, 10, 27, 38, 43, 82}
	orig := []int{38, 27, 43, 3, 9, 82, 10}

	mergesort.Sort(orig)

	if !reflect.DeepEqual(orig, expected) {
		t.Fatalf("expected %v, actual is %v", expected, orig)
	}
}