From 224cff0a5113b1ea1a09fd48caf164e5690ec8a7 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 17 Jul 2020 09:25:48 +0100 Subject: refactor --- sort/sort_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sort/sort_test.go') diff --git a/sort/sort_test.go b/sort/sort_test.go index 00f056a..d8250c4 100644 --- a/sort/sort_test.go +++ b/sort/sort_test.go @@ -7,12 +7,12 @@ import ( ) // Store results here to avoid compiler optimizations -var benchResult []ds.Comparer +var benchResult ds.ArrayList var benchResultInt []int const maxLength int = 10000 -type sortAlgorithm func([]ds.Comparer) []ds.Comparer +type sortAlgorithm func(ds.ArrayList) ds.ArrayList type sortAlgorithmInt func([]int) []int func TestSelectionSort(t *testing.T) { @@ -62,7 +62,7 @@ func test(sort sortAlgorithm, length int, t *testing.T) { t.Parallel() a := makeIntegers(length, length) a = sort(a) - if !Sorted(a) { + if !a.Sorted() { t.Errorf("Array not sorted: %v", a) } } @@ -73,8 +73,8 @@ func testShuffle(sort sortAlgorithm, length int, t *testing.T) { cb := func(t *testing.T) { t.Parallel() a := sort(ds.SortedIntegers(length)) - if Sorted(a) { - t.Errorf("Array sorted: %v", a) + if a.Sorted() { + t.Errorf("Array sorted: %v", a.FirstN(10)) } } t.Run(fmt.Sprintf("%d", length), cb) @@ -91,7 +91,7 @@ func benchmark(sort sortAlgorithm, length int, b *testing.B) { b.Run(fmt.Sprintf("%d", length), cb) } -func makeIntegers(length, max int) []ds.Comparer { +func makeIntegers(length, max int) ds.ArrayList { //return ds.ReverseSortedIntegers(length) return ds.RandomIntegers(length, max) } -- cgit v1.2.3