mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
28 lines
693 B
Python
28 lines
693 B
Python
import unittest
|
|
|
|
|
|
class TestIslandPerimeter(unittest.TestCase):
|
|
|
|
def test_island_perimeter(self):
|
|
solution = Solution()
|
|
self.assertRaises(TypeError, solution.island_perimeter, None)
|
|
data = [[1, 0]]
|
|
expected = 4
|
|
self.assertEqual(solution.island_perimeter(data), expected)
|
|
data = [[0, 1, 0, 0],
|
|
[1, 1, 1, 0],
|
|
[0, 1, 0, 0],
|
|
[1, 1, 0, 0]]
|
|
expected = 16
|
|
self.assertEqual(solution.island_perimeter(data), expected)
|
|
print('Success: test_island_perimeter')
|
|
|
|
|
|
def main():
|
|
test = TestIslandPerimeter()
|
|
test.test_island_perimeter()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|