def test_number_of_islands_7(): grid = [ ["0"], ] expected = 0 actual = num_islands(grid) assert actual == expected
def test_number_of_islands_6(): grid = [ ["1"], ] expected = 1 actual = num_islands(grid) assert actual == expected
def test_number_of_islands_2(): grid = [ ["1", "1", "0", "0", "0"], ["1", "1", "0", "0", "0"], ["0", "0", "1", "0", "0"], ["0", "0", "0", "1", "1"], ] expected = 3 actual = num_islands(grid) assert actual == expected
def test_number_of_islands_5(): grid = [ ["1", "O", "O", "O", "O", "O"], ["1", "O", "1", "1", "1", "1"], ["O", "O", "O", "O", "O", "O"], ["1", "1", "1", "O", "1", "1"], ["1", "1", "1", "O", "1", "1"], ["O", "O", "O", "O", "1", "1"], ] expected = 4 actual = num_islands(grid) assert actual == expected
def test_empty_1(self): result = num_islands([]) self.assertEqual(result, 0)
def test_given_2(self): result = num_islands([[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 1]]) self.assertEqual(result, 3)
def test_none(self): result = num_islands(None) self.assertEqual(result, 0)
def test_two_rows_2(self): result = num_islands([[1, 0, 1], [1, 1, 0]]) self.assertEqual(result, 2)
def test_one_column(self): result = num_islands([[1], [0], [1]]) self.assertEqual(result, 2)
def test_one_row(self): result = num_islands([[1, 0, 1]]) self.assertEqual(result, 2)
def test_one_land(self): result = num_islands([[1]]) self.assertEqual(result, 1)
def test_one_water(self): result = num_islands([[0]]) self.assertEqual(result, 0)