From 948335f2c9a512beb8a3adf2e67b0abb0037dbe5 Mon Sep 17 00:00:00 2001 From: swnb <1786718956@qq.com> Date: Wed, 16 Jan 2019 16:29:24 +0800 Subject: [PATCH] add new test sample for golang-quicksort --- go/12_sorts/QuickSort_test.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/go/12_sorts/QuickSort_test.go b/go/12_sorts/QuickSort_test.go index 4e0ba089..569982d6 100644 --- a/go/12_sorts/QuickSort_test.go +++ b/go/12_sorts/QuickSort_test.go @@ -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) }