Example #1
0
func TestBubbleSort(t *testing.T) {
	BubbleSort(util.GenArray(0))
	a := BubbleSort(util.GenArray(100))
	c := util.CheckArray(a)
	if c != 0 {
		t.Error("Sort array fail, first fail index", c)
	}
}
func TestMain(t *testing.T) {
	a := util.GenArray(100)
	for i := 0; i < 100; i = i + 2 {
		r := checkTuple(a[i], a[i+1])
		if !r {
			t.Error("Error", a[i], a[i+1], Gcd(a[i], a[i+1]))
		}
	}
}
Example #3
0
func benchmarkBubbleSort(n int, b *testing.B) {
	a := util.GenArray(n)
	for i := 0; i < b.N; i++ {
		BubbleSort(a)
	}
}
Example #4
0
func benchmarkSort(f func([]int) []int, n int, b *testing.B) {
	a := util.GenArray(n)
	for i := 0; i < b.N; i++ {
		f(a)
	}
}