2013-08-02 12:03:27 -05:00
|
|
|
import unittest
|
|
|
|
|
|
2019-05-30 06:10:31 -07:00
|
|
|
from leap import leap_year
|
2014-06-11 15:06:22 +02:00
|
|
|
|
2019-03-25 09:02:07 -05:00
|
|
|
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.5.1
|
2013-08-02 12:03:27 -05:00
|
|
|
|
2019-04-03 14:43:14 +01:00
|
|
|
|
2018-06-13 09:12:09 -04:00
|
|
|
class LeapTest(unittest.TestCase):
|
2019-08-16 11:41:55 -04:00
|
|
|
def test_year_not_divisible_by_4_in_common_year(self):
|
2019-05-30 06:10:31 -07:00
|
|
|
self.assertIs(leap_year(2015), False)
|
2013-08-02 12:03:27 -05:00
|
|
|
|
2019-08-16 11:41:55 -04:00
|
|
|
def test_year_divisible_by_2_not_divisible_by_4_in_common_year(self):
|
2019-05-30 06:10:31 -07:00
|
|
|
self.assertIs(leap_year(1970), False)
|
2019-03-25 09:02:07 -05:00
|
|
|
|
2019-08-16 11:41:55 -04:00
|
|
|
def test_year_divisible_by_4_not_divisible_by_100_in_leap_year(self):
|
2019-05-30 06:10:31 -07:00
|
|
|
self.assertIs(leap_year(1996), True)
|
2014-04-22 21:58:09 -06:00
|
|
|
|
2019-08-16 11:41:55 -04:00
|
|
|
def test_year_divisible_by_100_not_divisible_by_400_in_common_year(self):
|
2019-05-30 06:10:31 -07:00
|
|
|
self.assertIs(leap_year(2100), False)
|
2014-04-22 21:58:09 -06:00
|
|
|
|
2019-08-16 11:41:55 -04:00
|
|
|
def test_year_divisible_by_400_in_leap_year(self):
|
2019-05-30 06:10:31 -07:00
|
|
|
self.assertIs(leap_year(2000), True)
|
2013-08-02 12:03:27 -05:00
|
|
|
|
2019-08-16 11:41:55 -04:00
|
|
|
def test_year_divisible_by_200_not_divisible_by_400_in_common_year(self):
|
2019-05-30 06:10:31 -07:00
|
|
|
self.assertIs(leap_year(1800), False)
|
2018-11-01 16:45:46 +01:00
|
|
|
|
2016-11-29 09:44:47 +01:00
|
|
|
|
2019-08-16 11:41:55 -04:00
|
|
|
if __name__ == "__main__":
|
2013-08-02 12:03:27 -05:00
|
|
|
unittest.main()
|