Exemplo n.º 1
0
 def testKnownCases(self):
     """Tests some known cases."""
     # Test the given example
     self.assertEquals(
         3, Q1.counting_islands(_map_grid("FTFT|TTFF|FFTF|FFTF")))
     # Test other map example
     self.assertEquals(
         2, Q1.counting_islands(_map_grid("FTFFF|FTTTT|TTFFF|FFTTF")))
     # Test other map example - ring island
     self.assertEquals(
         2, Q1.counting_islands(_map_grid("TTTTT|TFFFT|TFTFT|TFFFT|TTTTT")))
Exemplo n.º 2
0
 def testNoIslandsCase(self):
     """Tests the case when there are no islands in a map grid"""
     no_islands_map = [[False] * 5 for _ in range(7)]
     self.assertEquals(0, Q1.counting_islands(no_islands_map))
Exemplo n.º 3
0
 def testAllLandCase(self):
     """Tests the case when all map tiles are land"""
     all_land_map = [[True] * 10 for _ in range(4)]
     self.assertEquals(1, Q1.counting_islands(all_land_map))
Exemplo n.º 4
0
 def testEmptyCase(self):
     """Tests the case when map argument is empty."""
     self.assertEquals(0, Q1.counting_islands(_map_grid("")))