-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshellsort_test.go
More file actions
62 lines (53 loc) · 1.44 KB
/
shellsort_test.go
File metadata and controls
62 lines (53 loc) · 1.44 KB
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 TestShellSort_10e1(t *testing.T) {
var integers []int32
for i:=1; i<4; i++ {
filename := fmt.Sprintf(FILENAME_TMPL, 1, i)
integers, _ = readFile(filename)
shellsort(integers)
if !isSorted(integers) {
t.Error("shellsort fails with an sorted array.")
}
}
}
func TestShellSort_10e2(t *testing.T) {
var integers []int32
for i:=1; i<4; i++ {
filename := fmt.Sprintf(FILENAME_TMPL, 2, i)
integers, _ = readFile(filename)
shellsort(integers)
if !isSorted(integers) {
t.Error("shellsort fails with an sorted array.")
}
}
}
func TestShellSort_10e3(t *testing.T) {
var integers []int32
for i:=1; i<4; i++ {
filename := fmt.Sprintf(FILENAME_TMPL, 3, i)
integers, _ = readFile(filename)
shellsort(integers)
if !isSorted(integers) {
t.Error("shellsort fails with an sorted array.")
}
}
}
func BenchmarkShellSort_10e1(b *testing.B) {
benchmark_algorithm(shellsort, 1, b)
}
func BenchmarkShellSort_10e2(b *testing.B) {
benchmark_algorithm(shellsort, 2, b)
}
func BenchmarkShellSort_10e3(b *testing.B) {
benchmark_algorithm(shellsort, 3, b)
}
func BenchmarkShellSort_10e4(b *testing.B) {
benchmark_algorithm(shellsort, 4, b)
}
func BenchmarkShellSort_10e5(b *testing.B) {
benchmark_algorithm(shellsort, 5, b)
}