Skip to content

Commit bdeb681

Browse files
authored
Add !isone test for truncated identity mats to conformance tests (#2394)
1 parent 73c0ef1 commit bdeb681

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

ext/TestExt/Rings-conformance-tests.jl

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,29 @@ function test_MatSpace_interface(S::MatSpace; reps = 10)
704704
@test ncols(b) == ncols(S)+1
705705

706706
end
707-
@test iszero(zero_matrix(R, nrows(S), ncols(S)))
707+
708+
# zero matrices
709+
a = zero_matrix(R, nrows(S), ncols(S))
710+
@test parent(a) === S
711+
@test iszero(a)
712+
a = zero(S)
713+
@test parent(a) === S
714+
@test iszero(a)
715+
716+
# (truncated) identity matrices
717+
if nrows(S) == ncols(S)
718+
a = diagonal_matrix(one(R), nrows(S), ncols(S))
719+
@test parent(a) === S
720+
@test isone(a)
721+
a = one(S)
722+
@test parent(a) === S
723+
@test isone(a)
724+
else
725+
a = diagonal_matrix(one(R), nrows(S), ncols(S))
726+
@test parent(a) === S
727+
@test !isone(a)
728+
@test_throws DomainError one(S)
729+
end
708730
end
709731

710732
@testset "Views" begin
@@ -833,6 +855,15 @@ function test_MatRing_interface(S::MatRing; reps = 15)
833855
@test a == S(T[a[i, j] for i in 1:nrows(a), j in 1:ncols(a)])
834856
@test a == S(T[a[i, j] for i in 1:nrows(a) for j in 1:ncols(a)])
835857
end
858+
@test iszero(zero(S))
859+
@test isone(one(S))
860+
if is_trivial(S)
861+
@test iszero(one(S))
862+
@test isone(zero(S))
863+
else
864+
@test !iszero(one(S))
865+
@test !isone(zero(S))
866+
end
836867
end
837868

838869
@testset "Basic manipulation of matrices" begin

0 commit comments

Comments
 (0)