Update Sort_test.go
This commit is contained in:
parent
4e0649eee5
commit
cba17d27b7
@ -1,43 +1,27 @@
|
||||
package _1_sorts
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBubbleSort(t *testing.T) {
|
||||
a := []int{5, 4, 3, 2, 1}
|
||||
BubbleSort(a)
|
||||
t.Log(a)
|
||||
arr := []int{1,5,9,6,3,7,5,10}
|
||||
fmt.Println("排序前:",arr)
|
||||
BubbleSort(arr,len(arr))
|
||||
fmt.Println("排序后:",arr)
|
||||
}
|
||||
|
||||
func TestInsertionSort(t *testing.T) {
|
||||
arr := []int{1,5,9,6,3,7,5,10}
|
||||
fmt.Println("排序前:",arr)
|
||||
InsertionSort(arr,len(arr))
|
||||
fmt.Println("排序后:",arr)
|
||||
}
|
||||
|
||||
func TestSelectionSort(t *testing.T) {
|
||||
a := []int{5, 4, 3, 2, 1}
|
||||
SelectionSort(a)
|
||||
t.Log(a)
|
||||
}
|
||||
func TestInsertSort(t *testing.T) {
|
||||
a := []int{5, 4, 3, 2, 1}
|
||||
InsertSort(a)
|
||||
t.Log(a)
|
||||
}
|
||||
|
||||
func BenchmarkBubbleSort(b *testing.B) {
|
||||
a := []int{5, 4, 3, 2, 1}
|
||||
for i := 0; i < b.N; i++ {
|
||||
BubbleSort(a)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkSelectionSort(b *testing.B) {
|
||||
a := []int{5, 4, 3, 2, 1}
|
||||
for i := 0; i < b.N; i++ {
|
||||
SelectionSort(a)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkInsertSort(b *testing.B) {
|
||||
a := []int{5, 4, 3, 2, 1}
|
||||
for i := 0; i < b.N; i++ {
|
||||
InsertSort(a)
|
||||
}
|
||||
arr := []int{1,5,9,6,3,7,5,10}
|
||||
fmt.Println("排序前:",arr)
|
||||
SelectionSort(arr,len(arr))
|
||||
fmt.Println("排序后:",arr)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user