From 6c598a53d3366d8ff7250bdc1ce29fa4c36ec246 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 14 Jul 2020 09:44:02 +0100 Subject: better testing --- sort/test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 sort/test.go (limited to 'sort/test.go') diff --git a/sort/test.go b/sort/test.go new file mode 100644 index 0000000..fa12555 --- /dev/null +++ b/sort/test.go @@ -0,0 +1,19 @@ +package sort + +import ( + "algorithms/ds" + "fmt" + "testing" +) + +func test(name string, length int, sort func([]ds.Comparer) []ds.Comparer, t *testing.T) { + cb := func(t *testing.T) { + t.Parallel() + a := ds.RandomIntegers(length, length) + a = sort(a) + if !Sorted(a) { + t.Errorf("Array not sorted: %v", a) + } + } + t.Run(fmt.Sprintf("Test%s%d", name, length), cb) +} -- cgit v1.2.3