diff --git a/test/matrix/test_matrix.rb b/test/matrix/test_matrix.rb index bef03fa..14d9f91 100644 --- a/test/matrix/test_matrix.rb +++ b/test/matrix/test_matrix.rb @@ -274,6 +274,34 @@ class TestMatrix < Test::Unit::TestCase assert_raise(ExceptionForMatrix::ErrDimensionMismatch) { Matrix[[2,0,1],[0,-2,2]].cofactor(0, 0) } end + def test_row_merge + assert_equal(Matrix.empty(0, 4), Matrix.empty(0, 2).row_merge(Matrix.empty(0, 2))) + assert_equal(Matrix[[1, 2, 3]], Matrix[[1]].row_merge(Matrix[[2, 3]])) + + assert_equal( + Matrix[[1, 2, 5, 6, 7], [3, 4, 8, 9, 10]], + Matrix[[1, 2], [3, 4]].row_merge(Matrix[[5, 6, 7], [8, 9, 10]]) + ) + + assert_equal( + Matrix[[1, 2, 5], [3, 4, 6]], + Matrix[[1, 2], [3, 4]].row_merge(Matrix[[5], [6]]) + ) + + assert_equal( + Matrix[[1, 2, 5, 7], [3, 4, 6, 8]], + Matrix[[1, 2], [3, 4]].row_merge(Matrix[[5], [6]], Matrix[[7], [8]]) + ) + + assert_raise(ExceptionForMatrix::ErrDimensionMismatch) do + Matrix[[1, 2], [3, 4]].row_merge(Matrix[[5, 6], [7, 8], [9, 10]]) + end + + assert_raise(ExceptionForMatrix::ErrDimensionMismatch) do + Matrix[[1, 2], [3, 4]].row_merge(Matrix[[5, 6]]) + end + end + def test_column_merge assert_equal(Matrix.empty(4, 0), Matrix.empty(2, 0).column_merge(Matrix.empty(2, 0))) assert_equal(Matrix[[1], [2], [3]], Matrix[[1]].column_merge(Matrix[[2], [3]]))