Ejemplo n.º 1
0
    private bool TestInsertValuesFromMap()
    {
        bool   success  = true;
        string messages = "";

        int size   = 4;
        int height = 2;

        int[,] imageMap = new int[, ] {
            { 0, 0, 1, 1 },
            { 0, 0, 1, 1 },
            { 0, 1, 0, 0 },
            { 1, 1, 0, 1 },
        };

        LinkedQuadTree linkedQuadTree = new LinkedQuadTree(Vector2.zero, size, height);

        linkedQuadTree.InsertValuesFromMap(imageMap);

        TestAssert(linkedQuadTree.Nodes[1].Value == 3, "Expected value 3!", ref success, ref messages);
        TestAssert(linkedQuadTree.Nodes[2].Value == 2, "Expected value 2!", ref success, ref messages);
        TestAssert(linkedQuadTree.Nodes[4].Value == 4, "Expected value 4!", ref success, ref messages);

        TestAssert(linkedQuadTree.IsEmpty(linkedQuadTree.Nodes[1]) == false, "Not expected empty in node 1!", ref success, ref messages);
        TestAssert(linkedQuadTree.IsFull(linkedQuadTree.Nodes[1]) == false, "Not expected full in node 1!", ref success, ref messages);

        TestAssert(linkedQuadTree.IsEmpty(linkedQuadTree.Nodes[3]) == true, "Expected empty in node 3!", ref success, ref messages);
        TestAssert(linkedQuadTree.IsFull(linkedQuadTree.Nodes[4]) == true, "Expected full in node 4!", ref success, ref messages);

        return(success);
    }
Ejemplo n.º 2
0
    private bool TestEmptyAndFull()
    {
        int size   = 128;
        int height = 2;

        LinkedQuadTree linkedQuadTree = new LinkedQuadTree(new Vector2(-size / 2, -size / 2), size, height);

        LinkedQuadTreeNode lastNode = linkedQuadTree.Nodes[linkedQuadTree.Nodes.Length - 1];

        linkedQuadTree.InsertValue(1, lastNode);

        bool   success  = true;
        string messages = "";

        TestAssert(linkedQuadTree.IsFull(linkedQuadTree.Nodes[4]) == true, "Expected cell 4 to be full!", ref success, ref messages);
        TestAssert(linkedQuadTree.IsFull(linkedQuadTree.Nodes[0]) == false, "Expected cell 0 not to be full!", ref success, ref messages);
        TestAssert(linkedQuadTree.IsEmpty(linkedQuadTree.Nodes[4]) == false, "Expected cell 4 not to be empty!", ref success, ref messages);
        TestAssert(linkedQuadTree.IsEmpty(linkedQuadTree.Nodes[0]) == false, "Expected cell 0 to be empty!", ref success, ref messages);
        TestAssert(linkedQuadTree.IsEmpty(linkedQuadTree.Nodes[1]) == true, "Expected cell 1 to be emtpy!", ref success, ref messages);

        return(success);
    }