2020-07-13 21:26:50 -04:00
|
|
|
import unittest
|
2017-03-27 05:23:15 -04:00
|
|
|
|
|
|
|
|
2020-07-13 21:26:50 -04:00
|
|
|
class TestMatrixMultiplicationCost(unittest.TestCase):
|
2017-03-27 05:23:15 -04:00
|
|
|
|
|
|
|
def test_find_min_cost(self):
|
|
|
|
matrix_mult_cost = MatrixMultiplicationCost()
|
2020-07-13 21:26:50 -04:00
|
|
|
self.assertRaises(TypeError, matrix_mult_cost.find_min_cost, None)
|
|
|
|
self.assertEqual(matrix_mult_cost.find_min_cost([]), 0)
|
2017-03-27 05:23:15 -04:00
|
|
|
matrices = [Matrix(2, 3),
|
|
|
|
Matrix(3, 6),
|
|
|
|
Matrix(6, 4),
|
|
|
|
Matrix(4, 5)]
|
|
|
|
expected_cost = 124
|
2020-07-13 21:26:50 -04:00
|
|
|
self.assertEqual(matrix_mult_cost.find_min_cost(matrices), expected_cost)
|
2017-03-27 05:23:15 -04:00
|
|
|
print('Success: test_find_min_cost')
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
test = TestMatrixMultiplicationCost()
|
|
|
|
test.test_find_min_cost()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-07-13 21:26:50 -04:00
|
|
|
main()
|