From 4c062003acf7db82179abbd8c322b6a71bb82824 Mon Sep 17 00:00:00 2001 From: Sanford Jonathan Edelist Date: Wed, 17 Apr 2024 20:47:19 +0000 Subject: [PATCH] Upload New File --- .../java/object_detection/PointTests.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/test/java/object_detection/PointTests.java diff --git a/src/test/java/object_detection/PointTests.java b/src/test/java/object_detection/PointTests.java new file mode 100644 index 00000000..9a8e64c7 --- /dev/null +++ b/src/test/java/object_detection/PointTests.java @@ -0,0 +1,51 @@ +package object_detection; + +import static org.junit.jupiter.api.Assertions.*; +import object_detection.types.*; +import org.junit.jupiter.api.Test; + +class PointTests { + + @Test + void testPointCreation() { + Point point = new Point(1.0f, 2.0f, 3.0f); + assertNotNull(point); + assertEquals(1.0f, point.getX()); + assertEquals(2.0f, point.getY()); + assertEquals(3.0f, point.getZ()); + } + + // @Test + // void testPointEquality() { + // Point p1 = new Point(1.005f, 2.005f, 3.005f); + // Point p2 = new Point(1.006f, 2.006f, 3.006f); + // assertTrue(Point.equals(p1, p2, 0.01f)); + // assertFalse(Point.equals(p1, p2, 0.0001f)); + // } + + // @Test + // void testPointPrecisionEquality() { + // Point p1 = new Point(0.0000001f, 0.0000001f, 0.0000001f); + // Point p2 = new Point(0.0000002f, 0.0000002f, 0.0000002f); + // assertFalse(Point.equals(p1, p2, 0.00000001f)); + // } + + @Test + void testMultiplePointsAddition() { + PointSet ps = new PointSet(); + ps.addPoint(new Point(1.0f, 2.0f, 3.0f)); + ps.addPoint(new Point(4.0f, 5.0f, 6.0f)); + assertEquals(2, ps.getPoints().size()); + } + + @Test + void testDuplicatePointsHandling() { + PointSet ps = new PointSet(); + Point p = new Point(1.0f, 2.0f, 3.0f); + ps.addPoint(p); + ps.addPoint(p); // Attempt to add the same point + assertEquals(1, ps.getPoints().size()); // Assuming duplicates are not allowed + } + + +} -- GitLab