Пример #1
0
def test_number_of_islands_7():
    grid = [
        ["0"],
    ]
    expected = 0
    actual = num_islands(grid)
    assert actual == expected
Пример #2
0
def test_number_of_islands_6():
    grid = [
        ["1"],
    ]
    expected = 1
    actual = num_islands(grid)
    assert actual == expected
Пример #3
0
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
Пример #4
0
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
Пример #5
0
 def test_empty_1(self):
     result = num_islands([])
     self.assertEqual(result, 0)
Пример #6
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)
Пример #7
0
 def test_none(self):
     result = num_islands(None)
     self.assertEqual(result, 0)
Пример #8
0
 def test_two_rows_2(self):
     result = num_islands([[1, 0, 1], [1, 1, 0]])
     self.assertEqual(result, 2)
Пример #9
0
 def test_one_column(self):
     result = num_islands([[1], [0], [1]])
     self.assertEqual(result, 2)
Пример #10
0
 def test_one_row(self):
     result = num_islands([[1, 0, 1]])
     self.assertEqual(result, 2)
Пример #11
0
 def test_one_land(self):
     result = num_islands([[1]])
     self.assertEqual(result, 1)
Пример #12
0
 def test_one_water(self):
     result = num_islands([[0]])
     self.assertEqual(result, 0)