Loading src/test/java/object_detection/BoundingBoxTests.java 0 → 100644 +65 −0 Original line number Diff line number Diff line package object_detection; import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; import object_detection.types.*; class BoundingBoxTests { @Test void testPointOnEachEdge() { Point2D tr = new Point2D(10, 10, 1); Point2D tl = new Point2D(0, 10, 1); Point2D br = new Point2D(10, 0, 1); Point2D bl = new Point2D(0, 0, 1); BoundingBox box = new BoundingBox(tr, tl, br, bl, 1, "vehicle"); // Assume points on the boundary should be considered outside assertFalse(box.within(new Point2D(5, 10, 1)), "Point on top edge should not be within"); assertFalse(box.within(new Point2D(5, 0, 1)), "Point on bottom edge should not be within"); assertFalse(box.within(new Point2D(0, 5, 1)), "Point on left edge should not be within"); assertFalse(box.within(new Point2D(10, 5, 1)), "Point on right edge should not be within"); } @Test void testPointsJustOutsideEachEdge() { Point2D tr = new Point2D(10, 10, 2); Point2D tl = new Point2D(0, 10, 2); Point2D br = new Point2D(10, 0, 2); Point2D bl = new Point2D(0, 0, 2); BoundingBox box = new BoundingBox(tr, tl, br, bl, 2, "animal"); // Test points just outside the bounding box assertFalse(box.within(new Point2D(-1, 5, 2)), "Point just left of the bounding box"); assertFalse(box.within(new Point2D(11, 5, 2)), "Point just right of the bounding box"); assertFalse(box.within(new Point2D(5, -1, 2)), "Point just below the bounding box"); assertFalse(box.within(new Point2D(5, 11, 2)), "Point just above the bounding box"); } @Test void testZeroWidthHeightBoundingBox() { Point2D tr = new Point2D(5, 5, 3); Point2D tl = new Point2D(5, 5, 3); Point2D br = new Point2D(5, 5, 3); Point2D bl = new Point2D(5, 5, 3); BoundingBox box = new BoundingBox(tr, tl, br, bl, 3, "object"); // Test that only the exact point is within //assertTrue(box.within(new Point2D(5, 5, 3)), "Exact point should be within"); assertFalse(box.within(new Point2D(5, 4, 3)), "Nearby point should not be within"); assertFalse(box.within(new Point2D(6, 5, 3)), "Nearby point should not be within"); } @Test void testLargeCoordinates() { Point2D tr = new Point2D(10000, 10000, 4); Point2D tl = new Point2D(0, 10000, 4); Point2D br = new Point2D(10000, 0, 4); Point2D bl = new Point2D(0, 0, 4); BoundingBox box = new BoundingBox(tr, tl, br, bl, 4, "space"); // Large coordinates inside the box assertTrue(box.within(new Point2D(5000, 5000, 4)), "Point well within large bounding box"); assertFalse(box.within(new Point2D(10001, 5000, 4)), "Point just outside large bounding box"); } } Loading
src/test/java/object_detection/BoundingBoxTests.java 0 → 100644 +65 −0 Original line number Diff line number Diff line package object_detection; import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; import object_detection.types.*; class BoundingBoxTests { @Test void testPointOnEachEdge() { Point2D tr = new Point2D(10, 10, 1); Point2D tl = new Point2D(0, 10, 1); Point2D br = new Point2D(10, 0, 1); Point2D bl = new Point2D(0, 0, 1); BoundingBox box = new BoundingBox(tr, tl, br, bl, 1, "vehicle"); // Assume points on the boundary should be considered outside assertFalse(box.within(new Point2D(5, 10, 1)), "Point on top edge should not be within"); assertFalse(box.within(new Point2D(5, 0, 1)), "Point on bottom edge should not be within"); assertFalse(box.within(new Point2D(0, 5, 1)), "Point on left edge should not be within"); assertFalse(box.within(new Point2D(10, 5, 1)), "Point on right edge should not be within"); } @Test void testPointsJustOutsideEachEdge() { Point2D tr = new Point2D(10, 10, 2); Point2D tl = new Point2D(0, 10, 2); Point2D br = new Point2D(10, 0, 2); Point2D bl = new Point2D(0, 0, 2); BoundingBox box = new BoundingBox(tr, tl, br, bl, 2, "animal"); // Test points just outside the bounding box assertFalse(box.within(new Point2D(-1, 5, 2)), "Point just left of the bounding box"); assertFalse(box.within(new Point2D(11, 5, 2)), "Point just right of the bounding box"); assertFalse(box.within(new Point2D(5, -1, 2)), "Point just below the bounding box"); assertFalse(box.within(new Point2D(5, 11, 2)), "Point just above the bounding box"); } @Test void testZeroWidthHeightBoundingBox() { Point2D tr = new Point2D(5, 5, 3); Point2D tl = new Point2D(5, 5, 3); Point2D br = new Point2D(5, 5, 3); Point2D bl = new Point2D(5, 5, 3); BoundingBox box = new BoundingBox(tr, tl, br, bl, 3, "object"); // Test that only the exact point is within //assertTrue(box.within(new Point2D(5, 5, 3)), "Exact point should be within"); assertFalse(box.within(new Point2D(5, 4, 3)), "Nearby point should not be within"); assertFalse(box.within(new Point2D(6, 5, 3)), "Nearby point should not be within"); } @Test void testLargeCoordinates() { Point2D tr = new Point2D(10000, 10000, 4); Point2D tl = new Point2D(0, 10000, 4); Point2D br = new Point2D(10000, 0, 4); Point2D bl = new Point2D(0, 0, 4); BoundingBox box = new BoundingBox(tr, tl, br, bl, 4, "space"); // Large coordinates inside the box assertTrue(box.within(new Point2D(5000, 5000, 4)), "Point well within large bounding box"); assertFalse(box.within(new Point2D(10001, 5000, 4)), "Point just outside large bounding box"); } }