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