def test_zero_matrix(self):

        matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]
        expected_output = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]
        zero_matrix(matrix)
        self.assertEqual(matrix, expected_output)

        matrix = [[1, 0, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]
        zero_matrix(matrix)
        expected_output = [[0, 0, 0], [1, 0, 1], [1, 0, 1], [1, 0, 1]]
        self.assertEqual(matrix, expected_output)

        matrix = [[1, 1, 1], [1, 1, 0], [1, 1, 1], [1, 1, 1]]
        zero_matrix(matrix)
        expected_output = [[1, 1, 0], [0, 0, 0], [1, 1, 0], [1, 1, 0]]
        self.assertEqual(matrix, expected_output)

        matrix = [[0, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 0]]
        zero_matrix(matrix)
        expected_output = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0],
                           [0, 0, 0, 0]]
        self.assertEqual(matrix, expected_output)

        matrix = [[0, 1, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0]]
        zero_matrix(matrix)
        expected_output = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0],
                           [0, 0, 0, 0]]
        self.assertEqual(matrix, expected_output)
Example #2
0
    def test_zero_matrix_4(self):
        matrix = [
                [1, 1, 0, 1],
                [1, 0, 1, 1],
                [1, 1, 1, 1]]

        solution = [
                [0, 0, 0, 0],
                [0, 0, 0, 0],
                [1, 0, 0, 1]]

        zero_matrix(matrix)
        self.assertEquals(matrix, solution)
 def test(self):
     self.assertEqual(
         zero_matrix([[0, 1, 2, 3], [1, 2, 3, 0], [1, 2, 3, 4],
                      [1, 2, 3, 4]]),
         [[0, 0, 0, 0], [0, 0, 0, 0], [0, 2, 3, 0], [0, 2, 3, 0]])
     self.assertEqual(
         zero_matrix([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12],
                      [13, 0, 15, 16]]),
         [[1, 0, 3, 4], [5, 0, 7, 8], [9, 0, 11, 12], [0, 0, 0, 0]])
     self.assertEqual(
         zero_matrix([[1, 2, 3, 4, 0], [0, 7, 8, 9, 10], [11, 0, 13, 0, 15],
                      [16, 17, 0, 19,
                       20]]), [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0],
                               [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]])
Example #4
0
 def test_empty_matrix(self):
     matrix = []
     zero_matrix(matrix)
     self.assertEquals(matrix, [])