|
| 1 | +@testsuite "sorting/sort" (AT, eltypes)->begin |
| 2 | + # Fuzzy correctness testing |
| 3 | + @testset "$ET" for ET in filter(x -> x <: Real, eltypes) |
| 4 | + for _ in 1:10 |
| 5 | + num_elems = rand(1:100_000) |
| 6 | + @test compare((A)->Base.sort!(A), AT, rand(ET, num_elems)) |
| 7 | + end |
| 8 | + # Not yet implemented |
| 9 | + # for _ in 1:5 |
| 10 | + # size = rand(1:100, 2) |
| 11 | + # @test compare((A)->Base.sort!(A; dims=1), AT, rand(ET, size...)) |
| 12 | + # @test compare((A)->Base.sort!(A; dims=2), AT, rand(ET, size...)) |
| 13 | + # end |
| 14 | + end |
| 15 | +end |
| 16 | + |
| 17 | +@testsuite "sorting/sortperm" (AT, eltypes)->begin |
| 18 | + # Fuzzy correctness testing |
| 19 | + @testset "$ET" for ET in filter(x -> x <: Real, eltypes) |
| 20 | + for _ in 1:10 |
| 21 | + num_elems = rand(1:100_000) |
| 22 | + @test compare((ix, A)->Base.sortperm!(ix, A), AT, zeros(Int32, num_elems), rand(ET, num_elems)) |
| 23 | + end |
| 24 | + # Not yet implemented |
| 25 | + # for _ in 1:5 |
| 26 | + # size = rand(1:100, 2) |
| 27 | + # @test compare((A)->Base.sort!(A; dims=1), AT, zeros(Int32, size...), rand(ET, size...)) |
| 28 | + # @test compare((A)->Base.sort!(A; dims=2), AT, zeros(Int32, size...), rand(ET, size...)) |
| 29 | + # end |
| 30 | + end |
| 31 | +end |
| 32 | + |
| 33 | +@testsuite "sorting/partialsort" (AT, eltypes)->begin |
| 34 | + local N = 10000 |
| 35 | + @testset "$ET" for ET in filter(x -> x <: Real, eltypes) |
| 36 | + @test compare((A)->Base.partialsort!(A, 1), AT, rand(ET, N)) |
| 37 | + @test compare((A)->Base.partialsort!(A, 1; rev=true), AT, rand(ET, N)) |
| 38 | + |
| 39 | + @test compare((A)->Base.partialsort!(A, N), AT, rand(ET, N)) |
| 40 | + @test compare((A)->Base.partialsort!(A, N; rev=true), AT, rand(ET, N)) |
| 41 | + |
| 42 | + @test compare((A)->Base.partialsort!(A, N÷2), AT, rand(ET, N)) |
| 43 | + @test compare((A)->Base.partialsort!(A, N÷2; rev=true), AT, rand(ET, N)) |
| 44 | + |
| 45 | + @test compare((A)->Base.partialsort!(A, (N÷10):(2N÷10)), AT, rand(ET, N)) |
| 46 | + @test compare((A)->Base.partialsort!(A, (N÷10):(2N÷10); rev=true), AT, rand(ET, N)) |
| 47 | + |
| 48 | + @test compare((A)->Base.partialsort!(A, 1:N), AT, rand(ET, N)) |
| 49 | + @test compare((A)->Base.partialsort!(A, 1:N; rev=true), AT, rand(ET, N)) |
| 50 | + end |
| 51 | +end |
0 commit comments