TEST_F(IdfFixture, IdfObject_IntFieldGetterWithReturnDefaultOption) {
  std::stringstream text;
  text << "Daylighting:DELight:Controls," << std::endl
       << "  MyControl," << std::endl
       << "  MyZone," << std::endl
       << "  ," << std::endl // default 1
       << "  ," << std::endl // default 0.3
       << "  ," << std::endl // default 0.2
       << "  ," << std::endl // default 1 (any integer but 0)
       << "  ," << std::endl // default 0.0
       << "  1.0;";
  OptionalIdfObject oObj = IdfObject::load(text.str());
  ASSERT_TRUE(oObj);
  IdfObject object = *oObj;
  // is able to cast default value
  OptionalInt iIdfField = object.getInt(5,true);
  ASSERT_TRUE(iIdfField);
  EXPECT_EQ(1,*iIdfField);
  EXPECT_FALSE(object.getInt(5));

  // returns set values
  object.setInt(5,-3);
  iIdfField = object.getInt(5,true);
  ASSERT_TRUE(iIdfField);
  EXPECT_EQ(-3,*iIdfField);
  EXPECT_TRUE(object.getInt(5));
}
Exemple #2
0
TEST_F(IdfFixture, IdfObject_IntFieldGetterWithReturnDefaultOption) {
  std::stringstream text;
  text << "Building," << std::endl
       << "  Building," << std::endl
       << "  ," << std::endl // default 0.0
       << "  ," << std::endl // default Suburbs
       << "  ," << std::endl // default 0.04
       << "  ," << std::endl // default 0.4
       << "  ," << std::endl // default FullExterior
       << "  ," << std::endl // default 25
       << "  6;"; // default 25
  OptionalIdfObject oObj = IdfObject::load(text.str());
  ASSERT_TRUE(oObj);
  IdfObject object = *oObj;
  // is able to cast default value
  OptionalInt iIdfField = object.getInt(6,true);
  ASSERT_TRUE(iIdfField);
  EXPECT_EQ(25,*iIdfField);
  EXPECT_FALSE(object.getInt(5));

  // returns set values
  object.setInt(5,-3);
  iIdfField = object.getInt(5,true);
  ASSERT_TRUE(iIdfField);
  EXPECT_EQ(-3,*iIdfField);
  EXPECT_TRUE(object.getInt(5));
}