示例#1
0
TEST_F(IdfFixture, IdfObject_UnsignedFieldGetterWithReturnDefaultOption) {
  std::stringstream text;
  text << "ZoneGroup," << std::endl
       << "  MyGroup," << std::endl
       << "  MyList;";
    // default 1
  OptionalIdfObject oObj = IdfObject::load(text.str());
  ASSERT_TRUE(oObj);
  IdfObject object = *oObj;

  // is able to cast default value
  OptionalUnsigned uIdfField = object.getUnsigned(2,true);
  ASSERT_TRUE(uIdfField);
  EXPECT_EQ(static_cast<unsigned>(1),*uIdfField);
  EXPECT_FALSE(object.getUnsigned(2));

  EXPECT_TRUE(object.setString(object.numFields(),"3"));

  // returns set values
  uIdfField = object.getUnsigned(2,true);
  ASSERT_TRUE(uIdfField);
  EXPECT_EQ(static_cast<unsigned>(3),*uIdfField);
  EXPECT_TRUE(object.getUnsigned(2));
}