Skip to content
Browse files

Add test for matrix method

  • Loading branch information...
1 parent 6fda61a commit 9c7e03fa8ca816d00d49f32d285884a324bd4fbb @chaitanyav committed Jan 2, 2012
Showing with 23 additions and 0 deletions.
  1. +23 −0 test/fibonacci_test.rb
View
23 test/fibonacci_test.rb
@@ -63,4 +63,27 @@ def test_fast_val
@fib.fast_val(1.0)
end
end
+
+ def test_matrix
+ assert_equal 0, (@fib.matrix(0))[0][1]
+ assert_equal 1, (@fib.matrix(1))[0][1]
+ assert_equal 34, (@fib.matrix(9))[0][1]
+ assert_equal 55, (@fib.matrix(10))[0][1]
+ assert_equal 354224848179261915075, (@fib.matrix(100))[0][1]
+
+ matrix = @fib.matrix(100)
+ assert_equal (@fib.matrix(101))[0][1], (matrix[0][1] + matrix[1][1])
+
+ assert_raises ArgumentError do
+ @fib.matrix(-1)
+ end
+
+ assert_raises ArgumentError do
+ @fib.matrix("12")
+ end
+
+ assert_raises ArgumentError do
+ @fib.matrix(1.0)
+ end
+ end
end

0 comments on commit 9c7e03f

Please sign in to comment.
Something went wrong with that request. Please try again.