|
129 | 129 | end |
130 | 130 | end |
131 | 131 | end |
| 132 | + |
| 133 | +@testset "permute!" begin |
| 134 | + #simple array |
| 135 | + @test permute!([1,2,3,4,5],[3,2,1,5,4]) == [3,2,1,5,4] |
| 136 | + #empty array |
| 137 | + @test permute!([],[]) == [] |
| 138 | + #single-element array |
| 139 | + @test permute!([5],[1]) == [5] |
| 140 | + #repeated elements in array |
| 141 | + @test permute!([1,2,2,3,3,3],[2,1,3,5,4,6]) == [2,1,2,3,3,3] |
| 142 | + #permutation vector contains zero |
| 143 | + @test_throws BoundsError permute!([1,2,3],[0,1,2]) |
| 144 | + #permutation vector contains negative indices |
| 145 | + @test_throws BoundsError permute!([1,2,3],[2,-1,1]) |
| 146 | + #permutation vector contains indices larger than array size |
| 147 | + @test_throws BoundsError permute!([1,2,3],[2,4,1]) |
| 148 | + #permutation vector is empty |
| 149 | + @test_throws DimensionMismatch permute!([1,2,3],[]) |
| 150 | + #array is empty |
| 151 | + @test_throws BoundsError permute!([],[2,1]) |
| 152 | +end |
0 commit comments