Skip to content

Commit 28fe67b

Browse files
author
motalib-code
committed
Improve test coverage: add edge case tests, remove demo file
1 parent a2ada7c commit 28fe67b

File tree

2 files changed

+19
-77
lines changed

2 files changed

+19
-77
lines changed

src/main/java/com/thealgorithms/geometry/RotatingCalipersDemo.java

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/test/java/com/thealgorithms/geometry/RotatingCalipersTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,23 @@ void testRectangleToString() {
168168

169169
assertTrue(rect.toString().contains("Rectangle{area="));
170170
}
171+
172+
@Test
173+
void testRectangleAreaCalculation() {
174+
Point[] vertices = {new Point(0, 0), new Point(1, 0), new Point(1, 1)};
175+
RotatingCalipers.Rectangle rect = new RotatingCalipers.Rectangle(vertices);
176+
assertEquals(0.0, rect.area, EPSILON);
177+
}
178+
179+
@Test
180+
void testDegenerateCase() {
181+
List<Point> samePoints = Arrays.asList(
182+
new Point(1, 1),
183+
new Point(1, 1),
184+
new Point(1, 1)
185+
);
186+
187+
RotatingCalipers.Rectangle rect = RotatingCalipers.minimumBoundingRectangle(samePoints);
188+
assertEquals(0.0, rect.area, EPSILON);
189+
}
171190
}

0 commit comments

Comments
 (0)