2020-07-15 09:23:57 +08:00
|
|
|
import unittest
|
2017-03-29 16:44:38 +08:00
|
|
|
|
|
|
|
|
2020-07-15 09:23:57 +08:00
|
|
|
class TestMathOps(unittest.TestCase):
|
2017-03-29 16:44:38 +08:00
|
|
|
|
|
|
|
def test_math_ops(self):
|
|
|
|
solution = Solution()
|
2020-07-15 09:23:57 +08:00
|
|
|
self.assertRaises(TypeError, solution.insert, None)
|
2017-03-29 16:44:38 +08:00
|
|
|
solution.insert(5)
|
|
|
|
solution.insert(2)
|
|
|
|
solution.insert(7)
|
|
|
|
solution.insert(9)
|
|
|
|
solution.insert(9)
|
|
|
|
solution.insert(2)
|
|
|
|
solution.insert(9)
|
|
|
|
solution.insert(4)
|
|
|
|
solution.insert(3)
|
|
|
|
solution.insert(3)
|
|
|
|
solution.insert(2)
|
2020-07-15 09:23:57 +08:00
|
|
|
self.assertEqual(solution.max, 9)
|
|
|
|
self.assertEqual(solution.min, 2)
|
|
|
|
self.assertEqual(solution.mean, 5)
|
|
|
|
self.assertTrue(solution.mode in (2, 9))
|
2017-03-29 16:44:38 +08:00
|
|
|
print('Success: test_math_ops')
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
test = TestMathOps()
|
|
|
|
test.test_math_ops()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-07-15 09:23:57 +08:00
|
|
|
main()
|