Skip to content

Commit 2ab1736

Browse files
kshyattandyferris
authored andcommitted
Misc error tests and such (#207)
1 parent 9c245df commit 2ab1736

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

test/MMatrix.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
@test (ex = macroexpand(:(@MMatrix Float32[i*j*k for i = 1:2, j=2:3, k=3:4])); isa(ex, Expr) && ex.head == :error)
4646
@test (ex = macroexpand(:(@MMatrix fill(2.3, 4, 5, 6))); isa(ex, Expr) && ex.head == :error)
4747
@test (ex = macroexpand(:(@MMatrix ones(4, 5, 6, 7))); isa(ex, Expr) && ex.head == :error)
48+
@test (ex = macroexpand(:(@MMatrix ones)); isa(ex, Expr) && ex.head == :error)
4849
@test (ex = macroexpand(:(@MMatrix eye(4, 5, 6, 7))); isa(ex, Expr) && ex.head == :error)
4950

5051
@test ((@MMatrix zeros(2,2))::MMatrix{2, 2, Float64}).data === (0.0, 0.0, 0.0, 0.0)

test/SMatrix.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
@test SMatrix{2,2,Int}((1,2,3,4)).data === (1,2,3,4)
2525
@test SMatrix{2,2}((1,2,3,4)).data === (1,2,3,4)
2626
@test SMatrix{2}((1,2,3,4)).data === (1,2,3,4)
27+
@test_throws DimensionMismatch SMatrix{2}((1,2,3,4,5))
2728

2829
@test ((@SMatrix [1.0])::SMatrix{1,1}).data === (1.0,)
2930
@test ((@SMatrix [1 2])::SMatrix{1,2}).data === (1, 2)
@@ -43,6 +44,7 @@
4344
@test (ex = macroexpand(:(@SMatrix Float64[i*j*k for i = 1:2, j=2:3, k=3:4])); isa(ex, Expr) && ex.head == :error)
4445
@test (ex = macroexpand(:(@SMatrix fill(1.5, 2, 3, 4))); isa(ex, Expr) && ex.head == :error)
4546
@test (ex = macroexpand(:(@SMatrix ones(2, 3, 4, 5))); isa(ex, Expr) && ex.head == :error)
47+
@test (ex = macroexpand(:(@SMatrix ones)); isa(ex, Expr) && ex.head == :error)
4648
@test (ex = macroexpand(:(@SMatrix eye(2, 3, 4, 5))); isa(ex, Expr) && ex.head == :error)
4749

4850
@test ((@SMatrix fill(1.3, 2,2))::SMatrix{2, 2, Float64}).data === (1.3, 1.3, 1.3, 1.3)

test/SizedArray.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525

2626
@testset "back to Array" begin
2727
@test Array(SizedArray{Tuple{2}, Int, 1}([3, 4])) == [3, 4]
28+
@test Array{Int}(SizedArray{Tuple{2}, Int, 1}([3, 4])) == [3, 4]
29+
@test Array{Int, 1}(SizedArray{Tuple{2}, Int, 1}([3, 4])) == [3, 4]
2830
@test Vector(SizedArray{Tuple{4}, Int, 1}(collect(3:6))) == collect(3:6)
31+
@test convert(Vector, SizedArray{Tuple{4}, Int, 1}(collect(3:6))) == collect(3:6)
32+
@test Matrix(SMatrix{2,2}((1,2,3,4))) == [1 3; 2 4]
33+
@test convert(Matrix, SMatrix{2,2}((1,2,3,4))) == [1 3; 2 4]
2934
end
3035
end

0 commit comments

Comments
 (0)