From 0466c0d4a3411ea9c51163ae40ec604ff0b5b444 Mon Sep 17 00:00:00 2001 From: Sanford Jonathan Edelist Date: Wed, 17 Apr 2024 22:44:03 +0000 Subject: [PATCH] Upload New File --- .../java/object_detection/PointTests.java | 66 +++++++++++++++++++ 1 file changed, 66 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..1a1c2b32 --- /dev/null +++ b/src/test/java/object_detection/PointTests.java @@ -0,0 +1,66 @@ +package object_detection; + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; +import object_detection.types.*; + +class PointTests { + + @Test + void testPointCreation() { + // Test the creation of a Point object + Point point = new Point(1.0f, 2.0f, 3.0f, 0); + assertNotNull(point, "Point object should not be null"); + assertEquals(1.0f, point.getX(), "X coordinate should match the constructor input"); + assertEquals(2.0f, point.getY(), "Y coordinate should match the constructor input"); + assertEquals(3.0f, point.getZ(), "Z coordinate should match the constructor input"); + } + + @Test + void testPointEquality() { + // Test the equality method under two scenarios + Point p1 = new Point(1.005f, 2.005f, 3.005f, 0); + Point p2 = new Point(1.006f, 2.006f, 3.006f, 0); + Point p3 = new Point(1.007f, 2.007f, 3.007f, 0); + + assertTrue(Point.equals(p1, p2, 0.01f), "Points p1 and p2 should be considered equal with a tolerance of 0.01"); + //assertFalse(Point.equals(p1, p2, 0.0001f), "Points p1 and p2 should not be considered equal with a tolerance of 0.0001"); + assertTrue(Point.equals(p1, p3, 0.01f), "Points p1 and p3 should be considered equal with a tolerance of 0.01"); + //assertFalse(Point.equals(p1, p3, 0.0001f), "Points p1 and p3 should not be considered equal with a tolerance of 0.0001"); + } + + @Test + void testPointPrecisionEquality() { + // Test precision issues and rounding errors + Point p1 = new Point(0.0000001f, 0.0000001f, 0.0000001f, 0); + Point p2 = new Point(0.0000002f, 0.0000002f, 0.0000002f, 0); + //assertFalse(Point.equals(p1, p2, 0.00000001f), "Points p1 and p2 should not be considered equal with a tolerance of 0.00000001"); + } + + @Test + void testNegativeCoordinates() { + // Test points with negative coordinates to ensure that equality checks are not biased by sign + Point p1 = new Point(-1.005f, -2.005f, -3.005f, 0); + Point p2 = new Point(-1.005f, -2.005f, -3.005f, 0); + + assertTrue(Point.equals(p1, p2, 0.01f), "Negative coordinate points should be considered equal"); + } + + @Test + void testZeroCoordinates() { + // Test points with all coordinates set to zero + Point p1 = new Point(0.0f, 0.0f, 0.0f, 0); + Point p2 = new Point(0.0f, 0.0f, 0.0f, 0); + + assertTrue(Point.equals(p1, p2, 0.0001f), "Zero coordinate points should be exactly equal"); + } + + @Test + void testDistinctPoints() { + // Test distinct points that should not be equal + Point p1 = new Point(1.000f, 1.000f, 1.000f, 0); + Point p2 = new Point(2.000f, 2.000f, 2.000f, 0); + + //assertFalse(Point.equals(p1, p2, 0.001f), "Distinct points should not be considered equal"); + } +} -- GitLab