Exemplo n.º 1
0
int main()
{
    {
        std::string id;
        IdProperty * ip = new IdProperty(id);

        PropertyCoverage pc(ip);

        // Coverage is complete, but it wouldn't hurt to add some bad data here.

        pc.basicCoverage();
    }

    {
        NameProperty * np = new NameProperty(0);

        PropertyCoverage pc(np);

        // Coverage is complete, but it wouldn't hurt to add some bad data here.

        pc.basicCoverage();
    }

    {
        LocatedEntitySet les;
        ContainsProperty * cp = new ContainsProperty(les);

        PropertyCoverage pc(cp);

        // Now the world context has been set up, add some entities.
        les.insert(new Entity("2", 2));

        // Coverage is complete, but it wouldn't hurt to add some bad data here.

        pc.basicCoverage();
    }



    return 0;
}
void ProvidersTest::setup()
{
    //Make a barrel with mass and burn speed properties
    m_b1 = new Entity("1", 1);
    m_barrelType = new TypeNode("barrel");
    types["barrel"] = m_barrelType;
    m_b1->setType(m_barrelType);
    m_b1->setProperty("mass", new SoftProperty(Element(30)));
    m_b1->setProperty("burn_speed", new SoftProperty(Element(0.3)));
    m_b1->setProperty("isVisible", new SoftProperty(Element(true)));

    //List properties for testing list operators
    SoftProperty* prop1 = new SoftProperty();
    prop1->set(std::vector<Element> { 25.0, 20.0 });
    m_b1->setProperty("float_list", prop1);

    SoftProperty* list_prop2 = new SoftProperty();
    list_prop2->set(std::vector<Element> { "foo", "bar" });
    m_b1->setProperty("string_list", list_prop2);

    //Make a second barrel
    m_b2 = new Entity("2", 2);
    m_b2->setProperty("mass", new SoftProperty(Element(20)));
    m_b2->setProperty("burn_speed", new SoftProperty(0.25));
    m_b2->setType(m_barrelType);
    m_b2->setProperty("isVisible", new SoftProperty(Element(false)));

    //Make first barrel contain the second barrel
    m_b1_container = new LocatedEntitySet;
    m_b1_container->insert(m_b2);
    m_b1->m_contains = m_b1_container;

    //Set bounding box properties for barrels
    BBoxProperty* bbox1 = new BBoxProperty;
    //Specify two corners of bbox in form of x, y, z coordinates
    bbox1->set((std::vector<Element> { -1, -2, -3, 1, 2, 3 }));
    m_b1->setProperty("bbox", bbox1);

    BBoxProperty* bbox2 = new BBoxProperty;
    bbox2->set(std::vector<Element> { -3, -1, -2, 1, 2, 3 });
    m_b2->setProperty("bbox", bbox2);

    ///Set up outfit testing

    //Green Cloth serves as outfit for gloves
    m_clothType = new TypeNode("cloth");
    types["cloth"] = m_clothType;

    m_cloth = new Entity("3", 3);
    m_cloth->setType(m_clothType);
    m_cloth->setProperty("color", new SoftProperty("green"));

    //Create outfit map where "thumb" outfit contains cloth
    std::map<std::string, Element> outfitMap1;
    outfitMap1.insert(std::make_pair("thumb", Element(m_cloth)));
    OutfitProperty* outfit2 = new OutfitProperty;
    outfit2->set(outfitMap1);
    m_glovesEntity = new Entity("4", 4);
    m_glovesEntity->setProperty("color", new SoftProperty("brown"));
    m_glovesEntity->setProperty("outfit", outfit2);

    //Create outfit map where hands of character contain brown gloves
    std::map<std::string, Element> outfitMap;
    outfitMap.insert(std::make_pair("hands", Element(m_glovesEntity)));
    OutfitProperty* outfit1 = new OutfitProperty;
    outfit1->set(outfitMap);

    //Create the character for testing
    m_characterType = new TypeNode("character");
    types["character"] = m_characterType;
    m_ch1 = new Entity("5", 5);
    m_ch1->setType(m_characterType);
    m_ch1->setProperty("outfit", outfit1);

    //Make second barrel contain the character
    m_b2_container = new LocatedEntitySet;
    m_b2_container->insert(m_ch1);
    m_b2->m_contains = m_b2_container;
}
Exemplo n.º 3
0
void EntityFilterTest::setup()
{
//Set up testing environment for Type/Soft properties
    m_b1 = new Entity("1", 1);
    m_barrelType = new TypeNode("barrel");
    types["barrel"] = m_barrelType;
    m_b1->setType(m_barrelType);
    m_b1->setProperty("mass", new SoftProperty(Element(30)));
    m_b1->setProperty("burn_speed", new SoftProperty(Element(0.3)));
    m_b1->setProperty("isVisible", new SoftProperty(Element(true)));

    m_b2 = new Entity("2", 2);
    m_b2->setProperty("mass", new SoftProperty(Element(20)));
    m_b2->setProperty("burn_speed", new SoftProperty(0.25));
    m_b2->setType(m_barrelType);
    m_b2->setProperty("isVisible", new SoftProperty(Element(false)));

    m_b3 = new Entity("3", 3);
    m_b3->setProperty("mass", new SoftProperty(Element(25)));
    m_b3->setProperty("burn_speed", new SoftProperty(Element(0.25)));
    m_b3->setType(m_barrelType);

    m_boulderType = new TypeNode("boulder");
    types["boulder"] = m_boulderType;
    m_bl1 = new Entity("4", 4);
    m_bl1->setProperty("mass", new SoftProperty(Element(25)));
    m_bl1->setType(m_boulderType);

    SoftProperty* prop1 = new SoftProperty();
    prop1->set(std::vector<Element> { 25.0, 20.0 });
    m_bl1->setProperty("float_list", prop1);

    SoftProperty* list_prop2 = new SoftProperty();
    list_prop2->set(std::vector<Element> { "foo", "bar" });
    m_bl1->setProperty("string_list", list_prop2);

// Create an entity-related memory map
    std::map<std::string, Element> entity_memory_map;
    entity_memory_map.insert(std::make_pair("disposition", Element(25)));
    Element memory_map_element(entity_memory_map);

    std::map<std::string, Element> memory;
    memory.insert(std::make_pair("1", memory_map_element));

//b1 contains bl1 which contains b3
    m_b1_container = new LocatedEntitySet;
    m_b1_container->insert(m_bl1);
    m_b1->m_contains = m_b1_container;

    m_bl1_container = new LocatedEntitySet;
    m_bl1_container->insert(m_b3);
    m_bl1->m_contains = m_bl1_container;

//Set up testing environment for Outfit property
    m_glovesType = new TypeNode("gloves");
    types["gloves"] = m_glovesType;
    m_bootsType = new TypeNode("boots");
    m_characterType = new TypeNode("character");
    types["character"] = m_characterType;
    TypeNode* m_clothType = new TypeNode("cloth");
    types["cloth"] = m_clothType;
    TypeNode* m_leatherType = new TypeNode("leather");

    m_glovesEntity = new Entity("5", 5);
    m_glovesEntity->setType(m_glovesType);
    m_glovesEntity->setProperty("color", new SoftProperty("brown"));
    m_glovesEntity->setProperty("mass", new SoftProperty(5));

    m_bootsEntity = new Entity("6", 6);
    m_bootsEntity->setType(m_bootsType);
    m_bootsEntity->setProperty("color", new SoftProperty("black"));
    m_bootsEntity->setProperty("mass", new SoftProperty(10));

    std::map<std::string, Element> outfitMap;
    outfitMap.insert(std::make_pair("feet", Element(m_bootsEntity)));
    outfitMap.insert(std::make_pair("hands", Element(m_glovesEntity)));
    OutfitProperty* outfit1 = new OutfitProperty;
    outfit1->set(outfitMap);

    m_cloth = new Entity("8", 8);
    m_cloth->setType(m_clothType);
    m_cloth->setProperty("color", new SoftProperty("green"));

    m_leather = new Entity("9", 9);
    m_leather->setType(m_leatherType);
    m_leather->setProperty("color", new SoftProperty("pink"));

    std::map<std::string, Element> outfitMap1;
    outfitMap1.insert(std::make_pair("thumb", Element(m_cloth)));
    OutfitProperty* outfit2 = new OutfitProperty;
    outfit2->set(outfitMap1);
    m_glovesEntity->setProperty("outfit", outfit2);

    m_ch1 = new Entity("7", 7);
    m_ch1->setType(m_characterType);
    m_ch1->setProperty("outfit", outfit1);

    BBoxProperty* bbox1 = new BBoxProperty;
    bbox1->set((std::vector<Element> { -1, -2, -3, 1, 2, 3 }));
    m_b1->setProperty("bbox", bbox1);

    BBoxProperty* bbox2 = new BBoxProperty;
    bbox2->set(std::vector<Element> { -3, -1, -2, 1, 2, 3 });
    m_bl1->setProperty("bbox", bbox2);

    m_cloth->setProperty("bbox", bbox1->copy());
}
Exemplo n.º 4
0
    void setup()
    {
        m_inheritance = new Inheritance();
//Set up testing environment for Type/Soft properties
        m_b1 = new TestEntity("1", 1);
        add_entity(m_b1);

        m_thingType = new TypeNode("thing");
        types["thing"] = m_thingType;

        m_barrelType = new TypeNode("barrel");
        m_barrelType->setParent(m_thingType);
        types["barrel"] = m_barrelType;
        m_b1->setType(m_barrelType);
        m_b1->setProperty("mass", new SoftProperty(Element(30)));
        m_b1->setProperty("burn_speed", new SoftProperty(Element(0.3)));
        m_b1->setProperty("isVisible", new SoftProperty(Element(true)));

        m_b2 = new Entity("2", 2);
        add_entity(m_b2);
        m_b2->setProperty("mass", new SoftProperty(Element(20)));
        m_b2->setProperty("burn_speed", new SoftProperty(0.25));
        m_b2->setType(m_barrelType);
        m_b2->setProperty("isVisible", new SoftProperty(Element(false)));

        m_b3 = new Entity("3", 3);
        add_entity(m_b3);
        m_b3->setProperty("mass", new SoftProperty(Element(25)));
        m_b3->setProperty("burn_speed", new SoftProperty(Element(0.25)));
        m_b3->setType(m_barrelType);

        m_boulderType = new TypeNode("boulder");
        types["boulder"] = m_boulderType;
        m_bl1 = new Entity("4", 4);
        add_entity(m_bl1);
        m_bl1->setProperty("mass", new SoftProperty(Element(25)));
        m_bl1->setType(m_boulderType);

        SoftProperty* prop1 = new SoftProperty();
        prop1->set(std::vector<Element>{25.0, 20.0});
        m_bl1->setProperty("float_list", prop1);

        SoftProperty* list_prop2 = new SoftProperty();
        list_prop2->set(std::vector<Element>{"foo", "bar"});
        m_bl1->setProperty("string_list", list_prop2);

// Create an entity-related memory map
        Atlas::Message::MapType entity_memory_map{{"disposition", 25}};

        m_memory.emplace("1", entity_memory_map);

//b1 contains bl1 which contains b3
        m_b1_container = new LocatedEntitySet;
        m_b1_container->insert(m_bl1);
        m_bl1->m_location.m_parent = m_b1;
        m_b1->m_contains = m_b1_container;
        m_b1->test_setDomain(new TestDomain(*m_b1));

        m_bl1_container = new LocatedEntitySet;
        m_bl1_container->insert(m_b3);
        m_b3->m_location.m_parent = m_bl1;

        m_bl1->m_contains = m_bl1_container;

//Set up testing environment for Outfit property
        m_glovesType = new TypeNode("gloves");
        types["gloves"] = m_glovesType;
        m_bootsType = new TypeNode("boots");
        m_characterType = new TypeNode("character");
        types["character"] = m_characterType;
        TypeNode* m_clothType = new TypeNode("cloth");
        types["cloth"] = m_clothType;
        TypeNode* m_leatherType = new TypeNode("leather");

        m_glovesEntity = new Entity("5", 5);
        add_entity(m_glovesEntity);
        m_glovesEntity->setType(m_glovesType);
        m_glovesEntity->setProperty("color", new SoftProperty("brown"));
        m_glovesEntity->setProperty("mass", new SoftProperty(5));
        //Mark it with a "reach" so we can use it in the "can_reach ... with" tests
        auto reachProp = new Property<double>();
        reachProp->data() = 10.0f;
        m_glovesEntity->setProperty("reach", reachProp);

        m_bootsEntity = new Entity("6", 6);
        add_entity(m_bootsEntity);
        m_bootsEntity->setType(m_bootsType);
        m_bootsEntity->setProperty("color", new SoftProperty("black"));
        m_bootsEntity->setProperty("mass", new SoftProperty(10));


        m_cloth = new Entity("8", 8);
        add_entity(m_cloth);
        m_cloth->setType(m_clothType);
        m_cloth->setProperty("color", new SoftProperty("green"));

        m_leather = new Entity("9", 9);
        add_entity(m_leather);
        m_leather->setType(m_leatherType);
        m_leather->setProperty("color", new SoftProperty("pink"));

        //The m_cloth entity is attached to the gloves by the "thumb" attachment
        {
            auto attachedProp = new SoftProperty();
            attachedProp->data() = Atlas::Message::MapType{{"$eid", m_cloth->getId()}};
            m_glovesEntity->setProperty("attached_thumb", attachedProp);

            auto plantedOnProp = new PlantedOnProperty();
            plantedOnProp->data().entity = WeakEntityRef(m_glovesEntity.get());
            m_cloth->setProperty("planted_on", plantedOnProp);
        }

        m_ch1 = new Entity("7", 7);
        add_entity(m_ch1);
        m_ch1->setType(m_characterType);

        //The m_glovesEntity entity is attached to the m_ch1 by the "hand_primary" attachment
        {
            auto attachedHandPrimaryProp = new SoftProperty();
            attachedHandPrimaryProp->data() = Atlas::Message::MapType{{"$eid", m_glovesEntity->getId()}};
            m_ch1->setProperty("attached_hand_primary", attachedHandPrimaryProp);
        }

        {
            auto plantedOnProp = new PlantedOnProperty();
            plantedOnProp->data().entity = WeakEntityRef(m_ch1.get());
            m_glovesEntity->setProperty("planted_on", plantedOnProp);
        }

        BBoxProperty* bbox1 = new BBoxProperty;
        bbox1->set((std::vector<Element>{-1, -3, -2, 1, 3, 2}));
        m_b1->setProperty("bbox", bbox1);

        BBoxProperty* bbox2 = new BBoxProperty;
        bbox2->set(std::vector<Element>{-3, -2, -1, 1, 3, 2});
        m_bl1->setProperty("bbox", bbox2);

        m_cloth->setProperty("bbox", bbox1->copy());
    }