From f3329140f8307e81288df966d36edf6d9528fcca Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Sat, 29 Jul 2017 02:18:10 +0200 Subject: [PATCH] add tests for Diagonal constructor --- test/linalg/diagonal.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/linalg/diagonal.jl b/test/linalg/diagonal.jl index 40194a5f20a39..a159e441bb6cc 100644 --- a/test/linalg/diagonal.jl +++ b/test/linalg/diagonal.jl @@ -18,6 +18,16 @@ srand(1) end D = Diagonal(d) DM = diagm(d) + + @testset "constructor" begin + for x in (d, GenericArray(d)) + @test Diagonal(x)::Diagonal{elty,typeof(x)} == DM + @test Diagonal(x).diag === x + @test Diagonal{elty}(x)::Diagonal{elty,typeof(x)} == DM + @test Diagonal{elty}(x).diag === x + end + end + @testset "Basic properties" begin @test eye(Diagonal{elty},n) == Diagonal(ones(elty,n)) @test_throws ArgumentError size(D,0)