示例#1
0
bool operator==(const Quantity& lQuantity,const Quantity& rQuantity) {
  if ((lQuantity.system() == rQuantity.system()) && (lQuantity.units() == rQuantity.units())) {
    Quantity wl(lQuantity), wr(rQuantity);
    wl.setScale(0);
    wr.setScale(0);
    return equal(wl.value(),wr.value());
  }
  return false;
}
示例#2
0
TEST_F(UnitsFixture,Quantity_MixedTypeOperations) {
  openstudio::SIUnit siu(SIExpnt(0,1), 0, "");
  Quantity l1(3.0, siu);
  openstudio::IPUnit ipu(IPExpnt(0,1), 0, "");
  Quantity l2(2.0, ipu);
  openstudio::BTUUnit btuu(BTUExpnt(0,1), 0, "");
  Quantity l3(0.5, btuu);

  Quantity r;
  r = l1*l2;
  EXPECT_EQ(UnitSystem(UnitSystem::Mixed),r.system());
  r = l1 / l2;
  EXPECT_EQ(UnitSystem(UnitSystem::Mixed),r.system());
  l3 *= l1;
  EXPECT_EQ(UnitSystem(UnitSystem::Mixed),l3.system());
  ASSERT_THROW(l1 + l2,Exception);

}
示例#3
0
TEST_F(IdfFixture, IdfObject_GetQuantity)
{
    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);

  // Test get.
  OSOptionalQuantity ooq = oObj->getQuantity (4);
  ASSERT_TRUE(ooq.isSet());
  Quantity q = ooq.get();
  EXPECT_TRUE(q.value() == 0.4);
  EXPECT_TRUE(q.system() == UnitSystem::SI);
  EXPECT_TRUE(q.standardUnitsString() == "K");

  // Test set.
  OptionalQuantity oq = convert(q,UnitSystem(UnitSystem::IP));
  ASSERT_TRUE(oq);
  EXPECT_TRUE(oq->system() == UnitSystem::IP);
  EXPECT_DOUBLE_EQ(0.72,oq->value());
  oq->setValue(1.5);

  EXPECT_TRUE(oObj->setQuantity(4, *oq));
  ooq = oObj->getQuantity(4);
  ASSERT_TRUE(ooq.isSet());
  q = ooq.get();
  EXPECT_DOUBLE_EQ(0.83333333333333333,q.value());
  EXPECT_TRUE(q.system() == UnitSystem::SI);
  EXPECT_TRUE(q.standardUnitsString() == "K");
}
示例#4
0
Quantity operator/(double d,const Quantity& rQuantity) {
  Quantity result(d,rQuantity.system());
  result /= rQuantity;
  return result;
}