2020-07-15 09:34:08 +08:00
|
|
|
import unittest
|
2017-03-29 16:35:42 +08:00
|
|
|
|
|
|
|
|
2020-07-15 09:34:08 +08:00
|
|
|
class TestSolution(unittest.TestCase):
|
2017-03-29 16:35:42 +08:00
|
|
|
|
|
|
|
def test_find_busiest_period(self):
|
|
|
|
solution = Solution()
|
2020-07-15 09:34:08 +08:00
|
|
|
self.assertRaises(TypeError, solution.find_busiest_period, None)
|
|
|
|
self.assertEqual(solution.find_busiest_period([]), None)
|
2017-03-29 16:35:42 +08:00
|
|
|
data = [
|
|
|
|
Data(3, 2, EventType.EXIT),
|
|
|
|
Data(1, 2, EventType.ENTER),
|
|
|
|
Data(3, 1, EventType.ENTER),
|
|
|
|
Data(7, 3, EventType.ENTER),
|
|
|
|
Data(9, 2, EventType.EXIT),
|
|
|
|
Data(8, 2, EventType.EXIT),
|
|
|
|
]
|
2020-07-15 09:34:08 +08:00
|
|
|
self.assertEqual(solution.find_busiest_period(data), Period(7, 8))
|
2017-03-29 16:35:42 +08:00
|
|
|
print('Success: test_find_busiest_period')
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
test = TestSolution()
|
|
|
|
test.test_find_busiest_period()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-07-15 09:34:08 +08:00
|
|
|
main()
|