Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'test/unit'
- require 'date'
- require 'birthday'
- class BirthdayCalculationTest < Test::Unit::TestCase
- def setup
- @birthday = Birthday.new(1981, 11, 4)
- end
- def test_later_month
- today = Date.new(2008, 12, 4)
- assert_equal 335, @birthday.days_from(today)
- end
- def test_earlier_month
- today = Date.new(2008, 10, 4)
- assert_equal 31, @birthday.days_from(today)
- end
- def test_earlier_day
- today = Date.new(2008,11,3)
- assert_equal 1, @birthday.days_from(today)
- end
- def test_later_day
- today = Date.new(2008,11,5)
- assert_equal 364, @birthday.days_from(today)
- end
- def test_same_day
- assert_equal 0, @birthday.days_from(@birthday)
- end
- def test_leap_year
- today = Date.new(2008, 2, 4)
- assert_equal 274, @birthday.days_from(today)
- today = Date.new(2009, 2, 4)
- assert_equal 273, @birthday.days_from(today)
- end
- end
Add Comment
Please, Sign In to add comment