From 7c4e2ad2fd4e109bead0ad22f4ce74ece16dced8 Mon Sep 17 00:00:00 2001 From: gogotanaka Date: Wed, 29 Oct 2014 11:39:27 -0700 Subject: [PATCH 2/3] Add tests for Vectro.independent? --- test/matrix/test_vector.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/matrix/test_vector.rb b/test/matrix/test_vector.rb index 0448dac..73441ee 100644 --- a/test/matrix/test_vector.rb +++ b/test/matrix/test_vector.rb @@ -92,6 +92,25 @@ class TestVector < Test::Unit::TestCase assert_equal(Vector[2.0,4.0,6.0], a) end + def test_independent? + assert(Vector.independent?(@v1, @w1)) + assert( + Vector.independent?( + Vector.basis(size: 3, index: 0), + Vector.basis(size: 3, index: 1), + Vector.basis(size: 3, index: 2), + ) + ) + + refute(Vector.independent?(@v1, Vector[2,4,6])) + refute(Vector.independent?(Vector[2,4], Vector[1,3], Vector[5,6])) + + assert_raise(Vector::TypeError) { Vector.independent?(@v1, 3) } + assert_raise(Vector::ErrDimensionMismatch) { Vector.independent?(@v1, Vector[2,4]) } + + assert(@v1.independent?(Vector[1,2,4], Vector[1,3,4])) + end + def test_mul assert_equal(Vector[2,4,6], @v1 * 2) assert_equal(Matrix[[1, 4, 9], [2, 8, 18], [3, 12, 27]], @v1 * Matrix[[1,4,9]]) -- 1.8.5.2 (Apple Git-48)