Commit 8a65e137 authored by Sanford Jonathan Edelist's avatar Sanford Jonathan Edelist
Browse files

Upload New File

parent 0ffb64c5
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
class BoundingBoxTests {

    @Test
    void testPointWithinBoundingBox() {
        Point2D tr = new Point2D(10, 10);
        Point2D tl = new Point2D(0, 10);
        Point2D br = new Point2D(10, 0);
        Point2D bl = new Point2D(0, 0);
        BoundingBox box = new BoundingBox(tr, tl, br, bl);

        assertTrue(box.within(new Point2D(5, 5)));
        assertFalse(box.within(new Point2D(10, 10))); // edge case: point on the boundary
        assertFalse(box.within(new Point2D(-1, 5))); // outside box
    }
}