2020-07-15 09:34:08 +08:00
|
|
|
import unittest
|
2017-03-29 16:32:22 +08:00
|
|
|
|
|
|
|
|
2020-07-15 09:34:08 +08:00
|
|
|
class TestMaxProfit(unittest.TestCase):
|
2017-03-29 16:32:22 +08:00
|
|
|
|
|
|
|
def test_max_profit(self):
|
|
|
|
solution = Solution()
|
2020-07-15 09:34:08 +08:00
|
|
|
self.assertRaises(TypeError, solution.find_max_profit, None)
|
|
|
|
self.assertRaises(ValueError, solution.find_max_profit, [])
|
|
|
|
self.assertEqual(solution.find_max_profit([8, 5, 3, 2, 1]), -1)
|
|
|
|
self.assertEqual(solution.find_max_profit([5, 3, 7, 4, 2, 6, 9]), 7)
|
2017-03-29 16:32:22 +08:00
|
|
|
print('Success: test_max_profit')
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
test = TestMaxProfit()
|
|
|
|
test.test_max_profit()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-07-15 09:34:08 +08:00
|
|
|
main()
|