diff --git a/test/matrix/test_matrix.rb b/test/matrix/test_matrix.rb index 7c466e6..bef03fa 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_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]])) + + assert_equal( + Matrix[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]], + Matrix[[1, 2], [3, 4]].column_merge(Matrix[[5, 6], [7, 8], [9, 10]]) + ) + + assert_equal( + Matrix[[1, 2], [3, 4], [5, 6]], + Matrix[[1, 2], [3, 4]].column_merge(Matrix[[5, 6]]) + ) + + assert_equal( + Matrix[[1, 2], [3, 4], [5, 6], [7, 8]], + Matrix[[1, 2], [3, 4]].column_merge(Matrix[[5, 6]], Matrix[[7, 8]]) + ) + + assert_raise(ExceptionForMatrix::ErrDimensionMismatch) do + Matrix[[1, 2], [3, 4]].column_merge(Matrix[[5, 6, 7], [8, 9, 10]]) + end + + assert_raise(ExceptionForMatrix::ErrDimensionMismatch) do + Matrix[[1, 2], [3, 4]].column_merge(Matrix[[5], [6]]) + end + end + def test_regular? assert(Matrix[[1, 0], [0, 1]].regular?) assert(Matrix[[1, 0, 0], [0, 1, 0], [0, 0, 1]].regular?)