コード例 #1
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());
}