Skip to content

Commit

Permalink
More tests for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
versilov committed Apr 24, 2018
1 parent 33430f6 commit 6f0cd8f
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/matrex_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ defmodule MatrexTest do
assert_raise ArgumentError, fn ->
Matrex.at(matrix, 0, 3)
end

assert_raise ArgumentError, fn ->
Matrex.at(matrix, -2, 1)
end
end

test "#column returns column of the matrix" do
Expand All @@ -107,6 +111,19 @@ defmodule MatrexTest do
assert Matrex.column(matrix, 3) == Matrex.new([[7], [13], [19], [25], [1]])
end

test "#column_as_list returns column of matrix" do
matrix =
Matrex.new([
[16, 23, 5, 7, 14],
[22, 4, 6, 13, 20],
[3, 10, 12, 19, 21],
[9, 11, 18, 25, 2],
[15, 17, 24, 1, 8]
])

assert Matrex.column_as_list(matrix, 2) == [5, 6, 12, 18, 24]
end

test "#divide divides two matrices" do
first = Matrex.new(2, 3, [[1, 2, 6], [9, 10, 18]])
second = Matrex.new(2, 3, [[2, 2, 3], [3, 5, 6]])
Expand Down Expand Up @@ -397,6 +414,9 @@ defmodule MatrexTest do
[1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1]
])

ones_not_square_matrix = Matrex.ones(3, 4)
assert ones_not_square_matrix == Matrex.new([[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]])
end

test "#random creates matrix of random values" do
Expand All @@ -417,6 +437,19 @@ defmodule MatrexTest do
assert Matrex.row(matrix, 3) == Matrex.new([[9, 11, 18, 25, 2]])
end

test "#row_as_list returns row of a matrix" do
matrix =
Matrex.new([
[16, 23, 5, 7, 14],
[22, 4, 6, 13, 20],
[3, 10, 12, 19, 21],
[9, 11, 18, 25, 2],
[15, 17, 24, 1, 8]
])

assert Matrex.row_as_list(matrix, 2) == [3, 10, 12, 19, 21]
end

test "#row_to_list get row of a matrix" do
input = Matrex.new([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
expected = [7, 8, 9]
Expand Down

0 comments on commit 6f0cd8f

Please sign in to comment.