Skip to content

Commit

Permalink
add new test sample for golang-quicksort
Browse files Browse the repository at this point in the history
  • Loading branch information
swnb committed Jan 16, 2019
1 parent befd67b commit 948335f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions go/12_sorts/QuickSort_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
package _2_sorts

import "testing"
import (
"math/rand"
"testing"
)

func createRandomArr(length int) []int {
arr := make([]int, length, length)
for i := 0; i < length; i++ {
arr[i] = rand.Intn(100)
}
return arr
}

func TestQuickSort(t *testing.T) {
arr := []int{5, 4}
QuickSort(arr)
t.Log(arr)

arr = []int{5, 4, 3, 2, 1}
arr = createRandomArr(100)
QuickSort(arr)
t.Log(arr)
}

0 comments on commit 948335f

Please sign in to comment.