summaryrefslogtreecommitdiff
path: root/sort/sort_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'sort/sort_test.go')
-rw-r--r--sort/sort_test.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/sort/sort_test.go b/sort/sort_test.go
index b632be8..ee49893 100644
--- a/sort/sort_test.go
+++ b/sort/sort_test.go
@@ -15,10 +15,7 @@ const maxLength int = 1000000
const factor int = 100
const maxSlowLength int = 100000
-var arrayListCache map[string]ds.ArrayList[int]
-
type sortAlgorithm[V ds.Number] func(ds.ArrayList[V]) ds.ArrayList[V]
-type sortAlgorithmInt func([]int) []int
func TestSleepSort(t *testing.T) {
a := ds.NewRandomArrayList[int](10, 10)
@@ -153,8 +150,17 @@ func BenchmarkShuffleSort(b *testing.B) {
}
*/
+// shortMaxLength caps the largest input size exercised under `go test -short`
+// (used by `make verify`, which runs under the race detector where the
+// million-element cases would be far too slow). The full range still runs in a
+// plain `make test`.
+const shortMaxLength int = 10000
+
func test[V ds.Number](sort sortAlgorithm[V], l int, t *testing.T) {
cb := func(t *testing.T) {
+ if testing.Short() && l > shortMaxLength {
+ t.Skipf("skipping size %d in -short mode", l)
+ }
t.Parallel()
a := ds.NewRandomArrayList[V](l, -1)
a = sort(a)
@@ -167,6 +173,9 @@ func test[V ds.Number](sort sortAlgorithm[V], l int, t *testing.T) {
func testShuffleSort[V ds.Number](sort sortAlgorithm[V], l int, t *testing.T) {
cb := func(t *testing.T) {
+ if testing.Short() && l > shortMaxLength {
+ t.Skipf("skipping size %d in -short mode", l)
+ }
t.Parallel()
a := sort(ds.NewAscendingArrayList[V](l))
if a.Sorted() {