def test_input_unchanged(self): m1 = [[6, 6], [3, 1]] m2 = [[1, 2], [3, 4]] m1_original = deepcopy(m1) m2_original = deepcopy(m2) matrix_add(m1, m2) self.assertEqual(m1, m1_original) self.assertEqual(m2, m2_original)
def test_two_by_two_matrixes(self): m1 = [[6, 6], [3, 1]] m2 = [[1, 2], [3, 4]] m3 = [[7, 8], [6, 5]] self.assertEqual(matrix_add(m1, m2), m3)
def test_two_by_three_matrixes(self): m1 = [[1, 2, 3], [4, 5, 6]] m2 = [[-1, -2, -3], [-4, -5, -6]] m3 = [[0, 0, 0], [0, 0, 0]] self.assertEqual(matrix_add(m1, m2), m3)
def test_single_items(self): self.assertEqual(matrix_add([[5]], [[-2]]), [[3]])