Skip to content

Commit 3142a5e

Browse files
DRY up test with for loops
Co-authored-by: Steven G. Johnson <[email protected]>
1 parent 602578d commit 3142a5e

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

test/dense.jl

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,16 @@ Random.seed!(1234323)
5757
@test cond(Mars, Inf) 7.1
5858
end
5959
@testset "Empty matrices" begin
60-
# zero for square (i.e. 0×0) matrices
61-
@test cond(zeros(Int, 0, 0), 1) === 0.0
62-
@test cond(zeros(Int, 0, 0), 2) === 0.0
63-
@test cond(zeros(Int, 0, 0), Inf) === 0.0
64-
@test cond(zeros(0, 0), 1) === 0.0
65-
@test cond(zeros(0, 0), 2) === 0.0
66-
@test cond(zeros(0, 0), Inf) === 0.0
67-
@test cond(zeros(ComplexF64, 0, 0), 1) === 0.0
68-
@test cond(zeros(ComplexF64, 0, 0), 2) === 0.0
69-
@test cond(zeros(ComplexF64, 0, 0), Inf) === 0.0
70-
# error for non-square matrices
71-
@test_throws DimensionMismatch cond(zeros(10, 0), 1)
72-
@test_throws DimensionMismatch cond(zeros(0, 10), 1)
73-
@test_throws DimensionMismatch cond(zeros(10, 0), 2)
74-
@test_throws DimensionMismatch cond(zeros(0, 10), 2)
75-
@test_throws DimensionMismatch cond(zeros(10, 0), Inf)
76-
@test_throws DimensionMismatch cond(zeros(0, 10), Inf)
60+
for norm in (1,2,Inf)
61+
# zero for square (i.e. 0×0) matrices
62+
@test cond(zeros(Int, 0, 0), norm) === 0.0
63+
@test cond(zeros(0, 0), norm) === 0.0
64+
@test cond(zeros(ComplexF64, 0, 0), norm) === 0.0
65+
# error for non-square matrices
66+
for size in ((10,0), (0,10))
67+
@test_throws DimensionMismatch cond(zeros(size...), norm)
68+
end
69+
end
7770
end
7871
end
7972

0 commit comments

Comments
 (0)