-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsertionsort_test.go
62 lines (53 loc) · 1.51 KB
/
insertionsort_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package sorting
import (
"fmt"
"testing"
)
func TestInsertionSort_10e1(t *testing.T) {
var integers []int32
for i:=1; i<4; i++ {
filename := fmt.Sprintf(FILENAME_TMPL, 1, i)
integers, _ = readFile(filename)
insertionsort(integers)
if !isSorted(integers) {
t.Error("insertionsort fails with an sorted array.")
}
}
}
func TestInsertionSort_10e2(t *testing.T) {
var integers []int32
for i:=1; i<4; i++ {
filename := fmt.Sprintf(FILENAME_TMPL, 2, i)
integers, _ = readFile(filename)
insertionsort(integers)
if !isSorted(integers) {
t.Error("insertionsort fails with an sorted array.")
}
}
}
func TestInsertionSort_10e3(t *testing.T) {
var integers []int32
for i:=1; i<4; i++ {
filename := fmt.Sprintf(FILENAME_TMPL, 3, i)
integers, _ = readFile(filename)
insertionsort(integers)
if !isSorted(integers) {
t.Error("insertionsort fails with an sorted array.")
}
}
}
func BenchmarkInsertionSort_10e1(b *testing.B) {
benchmark_algorithm(insertionsort, 1, b)
}
func BenchmarkInsertionSort_10e2(b *testing.B) {
benchmark_algorithm(insertionsort, 2, b)
}
func BenchmarkInsertionSort_10e3(b *testing.B) {
benchmark_algorithm(insertionsort, 3, b)
}
func BenchmarkInsertionSort_10e4(b *testing.B) {
benchmark_algorithm(insertionsort, 4, b)
}
func BenchmarkInsertionSort_10e5(b *testing.B) {
benchmark_algorithm(insertionsort, 5, b)
}