| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- import org.junit.Before;
- import org.junit.Ignore;
- import org.junit.Test;
-
- import static org.junit.Assert.assertEquals;
-
- public final class RectangleCounterTest {
-
- private RectangleCounter rectangleCounter;
-
- @Before
- public void setUp() {
- rectangleCounter = new RectangleCounter();
- }
-
- @Test
- public void testInputWithNoColumnsContainsNoRectangles() {
- String[] inputGrid = new String[]{};
-
- assertEquals(0, rectangleCounter.countRectangles(inputGrid));
- }
-
- @Ignore
- @Test
- public void testNonTrivialInputWithNoRectangles() {
- String[] inputGrid = new String[]{" "};
-
- assertEquals(0, rectangleCounter.countRectangles(inputGrid));
- }
-
- @Ignore
- @Test
- public void testInputWithOneRectangle() {
- String[] inputGrid = new String[]{
- "+-+",
- "| |",
- "+-+"
- };
-
- assertEquals(1, rectangleCounter.countRectangles(inputGrid));
- }
-
- @Ignore
- @Test
- public void testInputWithTwoRectanglesWithoutSharedEdges() {
- String[] inputGrid = new String[]{
- " +-+",
- " | |",
- "+-+-+",
- "| | ",
- "+-+ "
- };
-
- assertEquals(2, rectangleCounter.countRectangles(inputGrid));
- }
-
- @Ignore
- @Test
- public void testInputWithFiveRectanglesWithSharedEdges() {
- String[] inputGrid = new String[]{
- " +-+",
- " | |",
- "+-+-+",
- "| | |",
- "+-+-+"
- };
-
- assertEquals(5, rectangleCounter.countRectangles(inputGrid));
- }
-
- @Ignore
- @Test
- public void testThatRectangleOfHeightOneIsCounted() {
- String[] inputGrid = new String[]{
- "+--+",
- "+--+"
- };
-
- assertEquals(1, rectangleCounter.countRectangles(inputGrid));
- }
-
- @Ignore
- @Test
- public void testThatRectangleOfWidthOneIsCounted() {
- String[] inputGrid = new String[]{
- "++",
- "||",
- "++"
- };
-
- assertEquals(1, rectangleCounter.countRectangles(inputGrid));
- }
-
- @Ignore
- @Test
- public void testThatOneByOneSquareIsCounted() {
- String[] inputGrid = new String[]{
- "++",
- "++"
- };
-
- assertEquals(1, rectangleCounter.countRectangles(inputGrid));
- }
-
- @Ignore
- @Test
- public void testThatIncompleteRectanglesAreNotCounted() {
- String[] inputGrid = new String[]{
- " +-+",
- " |",
- "+-+-+",
- "| | -",
- "+-+-+"
- };
-
- assertEquals(1, rectangleCounter.countRectangles(inputGrid));
- }
-
- @Ignore
- @Test
- public void testThatRectanglesOfDifferentSizesAreAllCounted() {
- String[] inputGrid = new String[]{
- "+------+----+",
- "| | |",
- "+---+--+ |",
- "| | |",
- "+---+-------+"
- };
-
- assertEquals(3, rectangleCounter.countRectangles(inputGrid));
- }
-
- @Ignore
- @Test
- public void testThatIntersectionsWithoutCornerCharacterDoNotCountAsRectangleCorners() {
- String[] inputGrid = new String[]{
- "+------+----+",
- "| | |",
- "+------+ |",
- "| | |",
- "+---+-------+"
- };
-
- assertEquals(2, rectangleCounter.countRectangles(inputGrid));
- }
-
- @Ignore
- @Test
- public void testLargeInputWithManyRectangles() {
- String[] inputGrid = new String[]{
- "+---+--+----+",
- "| +--+----+",
- "+---+--+ |",
- "| +--+----+",
- "+---+--+--+-+",
- "+---+--+--+-+",
- "+------+ | |",
- " +-+"
- };
-
- assertEquals(60, rectangleCounter.countRectangles(inputGrid));
- }
-
- }
|