Skip to content

Commit 0d0fd94

Browse files
Merge pull request wangzheng0822#72 from luckydog612/patch-3
Update Sort_test.go
2 parents 40e8576 + cba17d2 commit 0d0fd94

File tree

1 file changed

+15
-31
lines changed

1 file changed

+15
-31
lines changed

go/11_sorts/Sort_test.go

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,27 @@
11
package _1_sorts
22

33
import (
4+
"fmt"
45
"testing"
56
)
67

78
func TestBubbleSort(t *testing.T) {
8-
a := []int{5, 4, 3, 2, 1}
9-
BubbleSort(a)
10-
t.Log(a)
9+
arr := []int{1,5,9,6,3,7,5,10}
10+
fmt.Println("排序前:",arr)
11+
BubbleSort(arr,len(arr))
12+
fmt.Println("排序后:",arr)
1113
}
1214

13-
func TestSelectionSort(t *testing.T) {
14-
a := []int{5, 4, 3, 2, 1}
15-
SelectionSort(a)
16-
t.Log(a)
17-
}
18-
func TestInsertSort(t *testing.T) {
19-
a := []int{5, 4, 3, 2, 1}
20-
InsertSort(a)
21-
t.Log(a)
22-
}
23-
24-
func BenchmarkBubbleSort(b *testing.B) {
25-
a := []int{5, 4, 3, 2, 1}
26-
for i := 0; i < b.N; i++ {
27-
BubbleSort(a)
28-
}
15+
func TestInsertionSort(t *testing.T) {
16+
arr := []int{1,5,9,6,3,7,5,10}
17+
fmt.Println("排序前:",arr)
18+
InsertionSort(arr,len(arr))
19+
fmt.Println("排序后:",arr)
2920
}
3021

31-
func BenchmarkSelectionSort(b *testing.B) {
32-
a := []int{5, 4, 3, 2, 1}
33-
for i := 0; i < b.N; i++ {
34-
SelectionSort(a)
35-
}
36-
}
37-
38-
func BenchmarkInsertSort(b *testing.B) {
39-
a := []int{5, 4, 3, 2, 1}
40-
for i := 0; i < b.N; i++ {
41-
InsertSort(a)
42-
}
22+
func TestSelectionSort(t *testing.T) {
23+
arr := []int{1,5,9,6,3,7,5,10}
24+
fmt.Println("排序前:",arr)
25+
SelectionSort(arr,len(arr))
26+
fmt.Println("排序后:",arr)
4327
}

0 commit comments

Comments
 (0)