Advertisement
ZaBlanc

Kata 8/23 Fibonacci Tests

Aug 23rd, 2011
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.65 KB | None | 0 0
  1. require "test/unit"
  2. require 'fibonacci'
  3.  
  4. class FibonacciTest < Test::Unit::TestCase
  5.  
  6.   def test_fibonacci_impossibility
  7.     assert_raise(ArgumentError) { Fibonacci.get_sequence(-1) }
  8.   end
  9.  
  10.   def test_fibonacci_sequence
  11.     assert_fibonacci_sequence([], 0)
  12.     assert_fibonacci_sequence([1], 1)
  13.     assert_fibonacci_sequence([1, 1], 2)
  14.     assert_fibonacci_sequence([1, 1, 2], 3)
  15.     assert_fibonacci_sequence([1, 1, 2, 3], 4)
  16.     assert_fibonacci_sequence([1, 1, 2, 3, 5], 5)
  17.     assert_fibonacci_sequence([1, 1, 2, 3, 5, 8], 6)
  18.   end
  19.  
  20.   def assert_fibonacci_sequence(act, num)
  21.     assert_equal(act, Fibonacci.get_sequence(num))
  22.   end
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement