Files
python/exercises/practice/rectangles/rectangles_test.py
BethanyG be794198e1 [Resistor Color Expert]: Corrected Small Typos (#3469)
* Corrected small typos around resistor bands.

* Due to failing CI, alterations to the test generator script were needed.
The generated vs submitted diff now skips the first three lines of the file
so that the generation date is not picked up and flagged as needing regeneration.

Sadly, a workaround was also needed to prevent Python difflib from noting the difference
anyways and producing an empty "false positive" diff.

All templates and test files also needed to be altered to ensure that the first three
lines of every test file will always be the autogeneration comment and date.

Hopefully, this will now stop the CI failures without creating any subtle additional bugs.

* Touch up to bowling template.  Added back the error raising utility.
* Touch up to two-bucket template to add back in error raising utility.
[no important files changed]
2023-07-21 16:54:40 -07:00

103 lines
2.9 KiB
Python

# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/rectangles/canonical-data.json
# File last updated on 2023-07-19
import unittest
from rectangles import (
rectangles,
)
class RectanglesTest(unittest.TestCase):
def test_no_rows(self):
self.assertEqual(rectangles([]), 0)
def test_no_columns(self):
self.assertEqual(rectangles([""]), 0)
def test_no_rectangles(self):
self.assertEqual(rectangles([" "]), 0)
def test_one_rectangle(self):
self.assertEqual(rectangles(["+-+", "| |", "+-+"]), 1)
def test_two_rectangles_without_shared_parts(self):
self.assertEqual(rectangles([" +-+", " | |", "+-+-+", "| | ", "+-+ "]), 2)
def test_five_rectangles_with_shared_parts(self):
self.assertEqual(rectangles([" +-+", " | |", "+-+-+", "| | |", "+-+-+"]), 5)
def test_rectangle_of_height_1_is_counted(self):
self.assertEqual(rectangles(["+--+", "+--+"]), 1)
def test_rectangle_of_width_1_is_counted(self):
self.assertEqual(rectangles(["++", "||", "++"]), 1)
def test_1x1_square_is_counted(self):
self.assertEqual(rectangles(["++", "++"]), 1)
def test_only_complete_rectangles_are_counted(self):
self.assertEqual(rectangles([" +-+", " |", "+-+-+", "| | -", "+-+-+"]), 1)
def test_rectangles_can_be_of_different_sizes(self):
self.assertEqual(
rectangles(
[
"+------+----+",
"| | |",
"+---+--+ |",
"| | |",
"+---+-------+",
]
),
3,
)
def test_corner_is_required_for_a_rectangle_to_be_complete(self):
self.assertEqual(
rectangles(
[
"+------+----+",
"| | |",
"+------+ |",
"| | |",
"+---+-------+",
]
),
2,
)
def test_large_input_with_many_rectangles(self):
self.assertEqual(
rectangles(
[
"+---+--+----+",
"| +--+----+",
"+---+--+ |",
"| +--+----+",
"+---+--+--+-+",
"+---+--+--+-+",
"+------+ | |",
" +-+",
]
),
60,
)
def test_rectangles_must_have_four_sides(self):
self.assertEqual(
rectangles(
[
"+-+ +-+",
"| | | |",
"+-+-+-+",
" | | ",
"+-+-+-+",
"| | | |",
"+-+ +-+",
]
),
5,
)