Files
python/exercises/rectangles/rectangles_count_test.py

74 lines
1.7 KiB
Python
Raw Normal View History

import unittest
from rectangles import count
2015-11-08 01:31:17 +01:00
class WordTest(unittest.TestCase):
2015-11-08 01:31:17 +01:00
# unit tests
def test_zero_area_1(self):
assert 0 == count()
def test_zero_area_2(self):
lines = ""
assert 0 == count(lines)
2015-11-08 01:31:17 +01:00
def test_empty_area(self):
lines = " "
assert 0 == count(lines)
2015-11-08 01:31:17 +01:00
def test_one_rectangle(self):
lines = ["+-+",
"| |",
"+-+",
]
assert 1 == count(lines)
2015-11-08 01:31:17 +01:00
def test_two_rectangles_no_shared_parts(self):
lines = [" +-+",
" | |",
"+-+-+",
"| | ",
"+-+ "
]
assert 2 == count(lines)
2015-11-08 01:31:17 +01:00
def test_five_rectangles_three_regions(self):
lines = [" +-+",
" | |",
"+-+-+",
"| | |",
"+-+-+"
]
assert 5 == count(lines)
2015-11-08 01:31:17 +01:00
def test_incomplete_rectangles(self):
lines = [" +-+",
" |",
"+-+-+",
"| | -",
"+-+-+"
]
assert 1 == count(lines)
2015-11-08 01:31:17 +01:00
def test_complicated(self):
lines = ["+------+----+",
"| | |",
"+---+--+ |",
"| | |",
"+---+-------+"
]
assert 3 == count(lines)
2015-11-08 01:31:17 +01:00
def test_not_so_complicated(self):
lines = ["+------+----+",
"| | |",
"+------+ |",
"| | |",
"+---+-------+"
]
assert 2 == count(lines)
2016-11-29 09:44:47 +01:00
if __name__ == '__main__':
2015-11-08 01:31:17 +01:00
unittest.main()