Created
October 17, 2008 16:22
-
-
Save seven1m/17456 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
require 'date' | |
class BirthdayCalculationTest < Test::Unit::TestCase | |
def test_calculation | |
bday = Birthday.new(1981, 12, 4) | |
today = Date.new(2008, 11, 4) | |
assert_equal 30, bday.days_from(today) | |
end | |
def test_lower_month_number | |
bday = Birthday.new(1981, 1, 4) | |
today = Date.new(2008, 11, 4) | |
assert_equal 61, bday.days_from(today) | |
end | |
def test_leap_year | |
bday = Birthday.new(1981, 3, 4) | |
today = Date.new(2008, 2, 4) | |
assert_equal 29, bday.days_from(today) | |
today = Date.new(2009, 2, 4) | |
assert_equal 28, bday.days_from(today) | |
end | |
end | |
class Birthday < Date | |
def days_from(from_day) | |
# return number of days (without taking birthday year in consideration) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment