示例#1
0
TEST_F(IdfFixture, IdfObject_CopyConstructor)
{
  std::string text = "Building,                !- Building \n\
                      Building,                !- Name \n\
                      30.,                     !- North Axis {deg} \n\
                      City,                    !- Terrain \n\
                      0.04,                    !- Loads Convergence Tolerance Value \n\
                      0.4,                     !- Temperature Convergence Tolerance Value {deltaC} \n\
                      FullExterior,            !- Solar Distribution \n\
                      25;                      !- Maximum Number of Warmup Days";

  // make an idf object
  OptionalIdfObject oObj = IdfObject::load(text);
  ASSERT_TRUE(oObj);
  IdfObject building = *oObj;
  EXPECT_TRUE(building.iddObject().type() == IddObjectType::Building);
  EXPECT_TRUE(building.isValid(StrictnessLevel::Final));
  ASSERT_TRUE(building.name());
  EXPECT_EQ("Building", *(building.name()));

  // copy idf object
  IdfObject building2(building);
  EXPECT_TRUE(building2.isValid(StrictnessLevel::Final));
  ASSERT_TRUE(building2.name());
  EXPECT_EQ("Building", *(building2.name()));

  // change building2's name
  building2.setString(0, "New Building");
  EXPECT_TRUE(building2.isValid(StrictnessLevel::Final));
  ASSERT_TRUE(building2.name());
  EXPECT_EQ("New Building", *(building2.name()));

  // also changed first building's name
  EXPECT_TRUE(building.isValid(StrictnessLevel::Final));
  ASSERT_TRUE(building.name());
  EXPECT_EQ("New Building", *(building.name()));
}
示例#2
0
TEST_F(IdfFixture, IdfObject_ConstructFromText_Comments)
{
  std::string singleLineComment = "! Single line comment";
  std::string multiLineComment = "! Multi" + idfRegex::newLinestring() +
                                 "! line " + idfRegex::newLinestring() +
                                 "!comment";

  // single line comment above object
  std::string text = singleLineComment + idfRegex::newLinestring() + iddRegex::commentOnlyObjectName() + ";";
  IdfObject object = IdfObject::load(text).get();
  EXPECT_TRUE(object.iddObject().type() == IddObjectType::CommentOnly);
  EXPECT_TRUE(object.isValid(StrictnessLevel::Final));
  EXPECT_EQ(singleLineComment, object.comment());

  // single line comment after object
  text = iddRegex::commentOnlyObjectName() + ";" + singleLineComment;
  object = IdfObject::load(text).get();
  EXPECT_TRUE(object.iddObject().type() == IddObjectType::CommentOnly);
  EXPECT_TRUE(object.isValid(StrictnessLevel::Final));
  EXPECT_EQ(singleLineComment, object.comment());

  // single line comment below object
  text = iddRegex::commentOnlyObjectName() + ";" + idfRegex::newLinestring() + singleLineComment;
  object = IdfObject::load(text).get();
  EXPECT_TRUE(object.iddObject().type() == IddObjectType::CommentOnly);
  EXPECT_TRUE(object.isValid(StrictnessLevel::Final));
  EXPECT_EQ(singleLineComment, object.comment());

  // multi line comment above object
  text = multiLineComment + idfRegex::newLinestring() + iddRegex::commentOnlyObjectName() + ";";
  object = IdfObject::load(text).get();
  EXPECT_TRUE(object.iddObject().type() == IddObjectType::CommentOnly);
  EXPECT_TRUE(object.isValid(StrictnessLevel::Final));
  EXPECT_EQ(multiLineComment, object.comment());

  // multi line comment after object
  text = iddRegex::commentOnlyObjectName() + ";" + multiLineComment;
  object = IdfObject::load(text).get();
  EXPECT_TRUE(object.iddObject().type() == IddObjectType::CommentOnly);
  EXPECT_TRUE(object.isValid(StrictnessLevel::Final));
  EXPECT_EQ(multiLineComment, object.comment());

  // multi line comment below object
  text = iddRegex::commentOnlyObjectName() + ";" + idfRegex::newLinestring() + multiLineComment;
  object = IdfObject::load(text).get();
  EXPECT_TRUE(object.iddObject().type() == IddObjectType::CommentOnly);
  EXPECT_TRUE(object.isValid(StrictnessLevel::Final));
  EXPECT_EQ(multiLineComment, object.comment());
}