当前位置: 首页>>代码示例>>C++>>正文


C++ Anonymous::hasAttr方法代码示例

本文整理汇总了C++中Anonymous::hasAttr方法的典型用法代码示例。如果您正苦于以下问题:C++ Anonymous::hasAttr方法的具体用法?C++ Anonymous::hasAttr怎么用?C++ Anonymous::hasAttr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Anonymous的用法示例。


在下文中一共展示了Anonymous::hasAttr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_addToEntity_tree

void Admintest::test_addToEntity_tree()
{
    Anonymous data;

    m_account->addToEntity(data);

    ASSERT_TRUE(data->hasAttr("character_types"));
    ASSERT_EQUAL(data->getAttr("character_types"), ListType());
}
开发者ID:cyclefusion,项目名称:cyphesis,代码行数:9,代码来源:Admintest.cpp

示例2: test_addToEntity

void Playertest::test_addToEntity()
{
    Player::playableTypes.insert("settler");

    Anonymous data;

    m_account->addToEntity(data);

    ASSERT_TRUE(data->hasAttr("character_types"));
    ASSERT_EQUAL(data->getAttr("character_types"), ListType(1, "settler"));
}
开发者ID:9cat,项目名称:cyphesis,代码行数:11,代码来源:Playertest.cpp

示例3: test_addToEntity

void Admintest::test_addToEntity()
{
    Inheritance::instance().addChild(atlasClass("character", "root"));
    Inheritance::instance().addChild(atlasClass("human", "character"));
    Inheritance::instance().addChild(atlasClass("settler", "human"));
    Inheritance::instance().addChild(atlasClass("goblin", "character"));

    Anonymous data;

    m_account->addToEntity(data);

    ListType expected_character_types;
    expected_character_types.push_back("character");
    expected_character_types.push_back("human");
    expected_character_types.push_back("settler");
    expected_character_types.push_back("goblin");

    ASSERT_TRUE(data->hasAttr("character_types"));
    ASSERT_EQUAL(data->getAttr("character_types"),
                 expected_character_types);
}
开发者ID:cyclefusion,项目名称:cyphesis,代码行数:21,代码来源:Admintest.cpp

示例4: main

int main()
{

    {
        // Test constructor
        PropertyBase * pb = new EntityProperty();
        delete pb;
    }

    {
        // Check constructor has set flags correctly to zero
        PropertyBase * pb = new EntityProperty;
        assert(pb->flags().m_flags == 0);
        delete pb;
    }

    {
        // Check getting the value fails when property is unassigned
        Element val;

        PropertyBase * pb = new EntityProperty;
        assert(pb->get(val) == -1);
        delete pb;
    }

    {
        // Check that setting the value to a pointer works
        Entity ent("1", 1);

        PropertyBase * pb = new EntityProperty;
        pb->set(Atlas::Message::Element(&ent));
        delete pb;
    }

    {
        // Check that setting the value to a pointer works can get retrieved
        Entity ent("1", 1);
        Element val;

        PropertyBase * pb = new EntityProperty;
        pb->set(Atlas::Message::Element(&ent));
        assert(pb->get(val) == 0);
        assert(val.isMap());
        assert(val.asMap().find("$eid")->second == ent.getId());
        delete pb;
    }

    {
        // Check that adding the uninitialised value to a message works.
        MapType map;
        static const std::string key = "foo";

        PropertyBase * pb = new EntityProperty;

        MapType::const_iterator I = map.find(key);
        assert(I == map.end());

        pb->add(key, map);

        I = map.find(key);
        assert(I != map.end());
        assert(I->second.isString());
        assert(I->second.String().empty());
        delete pb;
    }

    {
        // Check that adding the uninitialised value to an argument works.
        Anonymous arg;
        static const std::string key = "foo";
        Element val;

        PropertyBase * pb = new EntityProperty;

        assert(!arg->hasAttr(key));
        assert(arg->copyAttr(key, val) != 0);

        pb->add(key, arg);

        assert(arg->hasAttr(key));
        assert(arg->copyAttr(key, val) == 0);
        assert(val.isString());
        assert(val.String().empty());
        delete pb;
    }

    {
        // Check that adding the uninitialised value to an argument as a hard
        // attribute works
        Anonymous arg;
        static const std::string key = "id";
        Element val;

        PropertyBase * pb = new EntityProperty;

        assert(!arg->hasAttr(key));
        // Hard coded attribute ID has not been set, so returns false, but
        // copying it gives us the default
        assert(arg->copyAttr(key, val) == 0);
        assert(val.isString());
//.........这里部分代码省略.........
开发者ID:worldforge,项目名称:cyphesis,代码行数:101,代码来源:EntityPropertyTest.cpp


注:本文中的Anonymous::hasAttr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。