Exemple #1
0
 def test_when_birthday_is_tomorrow_of_leap_day(self):
     # 3/1 生まれの人は, 閏年では 2/29 に歳をとり, 閏年以外では 2/28 に歳をとる.
     self.assertEqual(0, date_basis_age(date(2000, 3, 1), date(2000, 3, 1)))
     self.assertEqual(0, date_basis_age(date(2000, 3, 1), date(2001, 2,
                                                               27)))
     self.assertEqual(1, date_basis_age(date(2000, 3, 1), date(2001, 2,
                                                               28)))
     self.assertEqual(1, date_basis_age(date(2000, 3, 1), date(2002, 2,
                                                               27)))
     self.assertEqual(2, date_basis_age(date(2000, 3, 1), date(2002, 2,
                                                               28)))
     self.assertEqual(2, date_basis_age(date(2000, 3, 1), date(2003, 2,
                                                               27)))
     self.assertEqual(3, date_basis_age(date(2000, 3, 1), date(2003, 2,
                                                               28)))
     self.assertEqual(3, date_basis_age(date(2000, 3, 1), date(2004, 2,
                                                               27)))
     self.assertEqual(3, date_basis_age(date(2000, 3, 1), date(2004, 2,
                                                               28)))
     self.assertEqual(4, date_basis_age(date(2000, 3, 1), date(2004, 2,
                                                               29)))
Exemple #2
0
 def test_when_birthday_is_normal_day(self):
     self.assertEqual(0, date_basis_age(date(2000, 7, 7), date(2000, 7, 7)))
     self.assertEqual(1, date_basis_age(date(2000, 7, 7), date(2001, 7, 6)))
     self.assertEqual(1, date_basis_age(date(2000, 7, 7), date(2001, 7, 7)))
     self.assertEqual(2, date_basis_age(date(2000, 7, 7), date(2002, 7, 6)))
     self.assertEqual(2, date_basis_age(date(2000, 7, 7), date(2002, 7, 7)))
     self.assertEqual(3, date_basis_age(date(2000, 7, 7), date(2003, 7, 6)))
Exemple #3
0
 def test_when_birthday_is_leap_day(self):
     # 誕生日が閏日の人は, 閏年には 2/28 に歳をとる.
     self.assertEqual(0, date_basis_age(date(2000, 2, 29),
                                        date(2000, 2, 29)))
     self.assertEqual(0, date_basis_age(date(2000, 2, 29), date(2000, 3,
                                                                1)))
     self.assertEqual(1, date_basis_age(date(2000, 2, 29),
                                        date(2001, 2, 28)))
     self.assertEqual(1, date_basis_age(date(2000, 2, 29), date(2001, 3,
                                                                1)))
     self.assertEqual(2, date_basis_age(date(2000, 2, 29),
                                        date(2002, 2, 28)))
     self.assertEqual(2, date_basis_age(date(2000, 2, 29), date(2002, 3,
                                                                1)))
     self.assertEqual(3, date_basis_age(date(2000, 2, 29),
                                        date(2003, 2, 28)))
     self.assertEqual(3, date_basis_age(date(2000, 2, 29), date(2003, 3,
                                                                1)))
     self.assertEqual(4, date_basis_age(date(2000, 2, 29),
                                        date(2004, 2, 28)))
     self.assertEqual(4, date_basis_age(date(2000, 2, 29),
                                        date(2004, 2, 29)))
Exemple #4
0
 def test_when_birthday_is_new_years_eve(self):
     self.assertEqual(
         0, date_basis_age(date(2000, 12, 31), date(2000, 12, 31)))
     self.assertEqual(
         1, date_basis_age(date(2000, 12, 31), date(2001, 12, 30)))
     self.assertEqual(
         1, date_basis_age(date(2000, 12, 31), date(2001, 12, 31)))
     self.assertEqual(
         2, date_basis_age(date(2000, 12, 31), date(2002, 12, 30)))
     self.assertEqual(
         2, date_basis_age(date(2000, 12, 31), date(2002, 12, 31)))
     self.assertEqual(
         3, date_basis_age(date(2000, 12, 31), date(2003, 12, 30)))