Skip to content

Commit 195b0e2

Browse files
committed
Add test for julia/Matrix.jl
1 parent 12a5cf5 commit 195b0e2

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

test/Rings-test.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
include("julia/Integers-test.jl")
2+
include("julia/Matrix-test.jl")
23
include("broadcasting-test.jl")
34

45
# artificially low cutoffs for testing purposes

test/julia/Matrix-test.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@testset "Julia.Matrix.manipulation" begin
2+
r, c = 1, 2
3+
A = zero_matrix(Int, r, c)
4+
A[1, :] = [10, -2]
5+
B = Int[10 -2]
6+
7+
@test A == B
8+
@test number_of_rows(A) == r
9+
@test number_of_columns(A) == c
10+
end
11+
12+
@testset "Julia.Matrix.array_creation" begin
13+
M = matrix_ring(ZZ, 2)
14+
m1 = M(ZZ[1 2; 3 4])
15+
m2 = M(ZZ[1 0; 0 1])
16+
arr = Array(M, 2)
17+
arr[1] = deepcopy(m1)
18+
arr[2] = deepcopy(m2)
19+
@test arr[1] == m1
20+
@test arr[2] == m2
21+
end
22+
23+
@testset "Julia.Matrix.permutations" begin
24+
M = matrix_space(ZZ, 2, 3)
25+
m1 = M(ZZ[1 2 3; 3 4 5])
26+
m2 = swap_rows(m1, 1, 2)
27+
m3 = swap_cols(m1, 3, 1)
28+
@test m2 == M(ZZ[3 4 5; 1 2 3])
29+
@test m3 == M(ZZ[3 2 1; 5 4 3])
30+
end

0 commit comments

Comments
 (0)