From 3d13f85310729962d94243e65b26785889e3a11c Mon Sep 17 00:00:00 2001 From: gogotanaka Date: Wed, 29 Oct 2014 00:57:52 -0700 Subject: [PATCH 2/3] Add test for Matrix#[] --- test/matrix/test_matrix.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/matrix/test_matrix.rb b/test/matrix/test_matrix.rb index 3fdef3b..e016cb8 100644 --- a/test/matrix/test_matrix.rb +++ b/test/matrix/test_matrix.rb @@ -74,6 +74,23 @@ class TestMatrix < Test::Unit::TestCase assert_equal(@m1, -(-@m1)) end + def test_aref + assert_equal(5, @m1[1, 1]) + assert_nil(@m1[1, 3]) + + assert_equal(Vector[1, 2], @m1[0, 0..1]) + assert_equal(Vector[2, 3], @m1[0, 1..-1]) + assert_nil(@m1[10, 0..1]) + assert_nil(@m1[1, 10..11]) + + assert_equal(Vector[2, 5], @m1[0..1, 1]) + assert_equal(Vector[3, 6], @m1[0..-1, 2]) + assert_nil(@m1[10..11, 1]) + assert_nil(@m1[0..1, 10]) + + assert_equal(@m1.minor(0..1, 0..1), @m1[0..1, 0..1]) + end + def test_rank [ [[0]], -- 1.8.5.2 (Apple Git-48)