Commit b3f03da3 authored by Sanford Jonathan Edelist's avatar Sanford Jonathan Edelist Committed by Rohan Kumar
Browse files

Upload New File

parent 0466c0d4
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
package object_detection;

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import object_detection.types.*;

class ObjectSetTests {

    private ObjectSet os;

    @BeforeEach
    void setUp() {
        os = new ObjectSet();  // Initialize a new ObjectSet for each test
    }

    @Test
    void testObjectCreation() {
        // Create objects using multiple points
        int objId1 = os.makeObject(new Point(1, 2, 3, 1), new Point(4, 5, 6, 2));
        int objId2 = os.makeObject(new Point(7, 8, 9, 3), new Point(10, 11, 12, 4));

        assertEquals(2, os.objects.size(), "There should be two objects in the set after addition.");
        assertNotNull(os.objects.get(objId1), "The object with objId1 should not be null.");
        assertNotNull(os.objects.get(objId2), "The object with objId2 should not be null.");
    }

    @Test
    void testObjectComparisonAndCombination() {
        // Create two objects that should be similar enough to be considered the same
        int objId1 = os.makeObject(new Point(0, 0, 0, 1));
        int objId2 = os.makeObject(new Point(0, 0, 0, 2));

        assertTrue(os.compareObjects(objId1, objId2), "Identical objects should be considered the same.");

        // Now combine these objects into one
        os.combineObjects(objId1, objId2);
        assertEquals(1, os.objects.size(), "There should be one object left after combining.");
    }

    @Test
    void testEmptyObjectSetCreation() {
        assertTrue(os.objects.isEmpty(), "Newly created ObjectSet should be empty.");
    }
}