Skip to content

Commit e8f8968

Browse files
11happyhappy
andauthored
Added Tests for Permute function in combinatorics.jl (#52648)
Signed-off-by: happy <happy@Ubunutt.myguest.virtualbox.org> Co-authored-by: happy <happy@Ubunutt.myguest.virtualbox.org>
1 parent ad3769e commit e8f8968

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/combinatorics.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,24 @@ end
129129
end
130130
end
131131
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

Comments
 (0)