Guest User

Untitled

a guest
May 24th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. require 'test/unit'
  2. require 'date'
  3. require 'birthday'
  4.  
  5. class BirthdayCalculationTest < Test::Unit::TestCase
  6. def setup
  7. @birthday = Birthday.new(1981, 11, 4)
  8. end
  9.  
  10. def test_later_month
  11. today = Date.new(2008, 12, 4)
  12. assert_equal 335, @birthday.days_from(today)
  13. end
  14.  
  15. def test_earlier_month
  16. today = Date.new(2008, 10, 4)
  17. assert_equal 31, @birthday.days_from(today)
  18. end
  19.  
  20. def test_earlier_day
  21. today = Date.new(2008,11,3)
  22. assert_equal 1, @birthday.days_from(today)
  23. end
  24.  
  25. def test_later_day
  26. today = Date.new(2008,11,5)
  27. assert_equal 364, @birthday.days_from(today)
  28. end
  29.  
  30. def test_same_day
  31. assert_equal 0, @birthday.days_from(@birthday)
  32. end
  33.  
  34. def test_leap_year
  35. today = Date.new(2008, 2, 4)
  36. assert_equal 274, @birthday.days_from(today)
  37.  
  38. today = Date.new(2009, 2, 4)
  39. assert_equal 273, @birthday.days_from(today)
  40. end
  41. end
Add Comment
Please, Sign In to add comment