diff options
| author | Paul Buetow <paul@buetow.org> | 2020-07-14 09:44:02 +0100 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2020-07-14 09:44:02 +0100 |
| commit | 6c598a53d3366d8ff7250bdc1ce29fa4c36ec246 (patch) | |
| tree | 60b13e5dde965117392b7d15e5eb1e6b406de665 /sort/test.go | |
| parent | aee630b03f48a9f528a4a50e9dcb0fdc8ef20aa5 (diff) | |
better testing
Diffstat (limited to 'sort/test.go')
| -rw-r--r-- | sort/test.go | 19 |
1 files changed, 19 insertions, 0 deletions
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) +} |
