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


C++ ProjectDatabase::includesRecord方法代码示例

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


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

示例1: attribute

// this is a monster test that is more for testing the database than attributes
TEST_F(ProjectFixture, AttributeRecord_LoadSave)
{
  int id;
  UUID handle;
  Attribute attribute("name", 1.0, std::string("m"));
  {
    ProjectDatabase database = getCleanDatabase("AttributeRecord_LoadSave");

    EXPECT_EQ(static_cast<unsigned>(0), AttributeRecord::getAttributeRecords(database).size());

    FileReferenceRecord model(FileReference(toPath("./in.osm")),database);

    AttributeRecord attributeRecord(attribute,model);
    id = attributeRecord.id();
    handle = attributeRecord.handle();
    EXPECT_EQ("name", attributeRecord.name());
    EXPECT_EQ("name", attributeRecord.displayName());
    EXPECT_EQ("", attributeRecord.description());
    EXPECT_EQ(AttributeValueType::Double, attributeRecord.attributeValueType().value());
    EXPECT_EQ(1.0, attributeRecord.attributeValueAsDouble());
    ASSERT_TRUE(attributeRecord.attributeUnits());
    EXPECT_EQ("m", attributeRecord.attributeUnits().get());

    EXPECT_TRUE(database.includesRecord(attributeRecord));
    EXPECT_TRUE(database.isNewRecord(attributeRecord));
    EXPECT_FALSE(database.isDirtyRecord(attributeRecord));
    EXPECT_FALSE(database.isCleanRecord(attributeRecord));
    EXPECT_FALSE(database.isRemovedRecord(attributeRecord));
    EXPECT_EQ(static_cast<unsigned>(2), attributeRecord.useCount());
  }

  {
    // open existing database
    ProjectDatabase database = getExistingDatabase("AttributeRecord_LoadSave");

    // new objects were removed
    EXPECT_EQ(static_cast<unsigned>(0), AnalysisRecord::getAnalysisRecords(database).size());
    EXPECT_EQ(static_cast<unsigned>(0), FileReferenceRecord::getFileReferenceRecords(database).size());
    EXPECT_EQ(static_cast<unsigned>(0), AttributeRecord::getAttributeRecords(database).size());

    FileReferenceRecord model(FileReference(toPath("./in.osm")),database);

    // create AttributeRecord
    AttributeRecord attributeRecord(attribute, model);
    id = attributeRecord.id();
    handle = attributeRecord.handle();
    EXPECT_EQ("name", attributeRecord.name());
    EXPECT_EQ("name", attributeRecord.displayName());
    EXPECT_EQ("", attributeRecord.description());
    EXPECT_EQ(AttributeValueType::Double, attributeRecord.attributeValueType().value());
    EXPECT_EQ(1.0, attributeRecord.attributeValueAsDouble());
    ASSERT_TRUE(attributeRecord.attributeUnits());
    EXPECT_EQ("m", attributeRecord.attributeUnits().get());

    EXPECT_TRUE(database.includesRecord(attributeRecord));
    EXPECT_TRUE(database.isNewRecord(attributeRecord));
    EXPECT_FALSE(database.isDirtyRecord(attributeRecord));
    EXPECT_FALSE(database.isCleanRecord(attributeRecord));
    EXPECT_FALSE(database.isRemovedRecord(attributeRecord));
    EXPECT_EQ(static_cast<unsigned>(2), attributeRecord.useCount());

    // save to database
    EXPECT_TRUE(database.save());

    EXPECT_TRUE(database.includesRecord(attributeRecord));
    EXPECT_FALSE(database.isNewRecord(attributeRecord));
    EXPECT_FALSE(database.isDirtyRecord(attributeRecord));
    EXPECT_TRUE(database.isCleanRecord(attributeRecord));
    EXPECT_FALSE(database.isRemovedRecord(attributeRecord));
    EXPECT_EQ(static_cast<unsigned>(2), attributeRecord.useCount());
  }

  {
    // open existing database
    ProjectDatabase database = getExistingDatabase("AttributeRecord_LoadSave");

    // saved objects were not removed
    ASSERT_EQ(static_cast<unsigned>(1), FileReferenceRecord::getFileReferenceRecords(database).size());
    ASSERT_EQ(static_cast<unsigned>(1), AttributeRecord::getAttributeRecords(database).size());

    std::vector<FileReferenceRecord> fileReferenceRecords = FileReferenceRecord::getFileReferenceRecords(database);
    FileReferenceRecord model = fileReferenceRecords.at(0);
    EXPECT_EQ(static_cast<unsigned>(1), model.attributeRecords().size());
    AttributeRecord attributeRecord = model.attributeRecords()[0];

    EXPECT_EQ(id, attributeRecord.id());
    EXPECT_EQ(handle, attributeRecord.handle());
    EXPECT_EQ("name", attributeRecord.name());
    EXPECT_EQ("name", attributeRecord.displayName());
    EXPECT_EQ("", attributeRecord.description());
    EXPECT_EQ(AttributeValueType::Double, attributeRecord.attributeValueType().value());
    EXPECT_EQ(1.0, attributeRecord.attributeValueAsDouble());
    ASSERT_TRUE(attributeRecord.attributeUnits());
    EXPECT_EQ("m", attributeRecord.attributeUnits().get());

    EXPECT_TRUE(database.includesRecord(attributeRecord));
    EXPECT_FALSE(database.isNewRecord(attributeRecord));
    EXPECT_FALSE(database.isDirtyRecord(attributeRecord));
    EXPECT_TRUE(database.isCleanRecord(attributeRecord));
//.........这里部分代码省略.........
开发者ID:Rahjou,项目名称:OpenStudio,代码行数:101,代码来源:AttributeRecord_GTest.cpp


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