예제 #1
0
std::vector<Quantity> OSQuantityVector::quantities() const {
  QuantityVector result;
  for (double value : values()) {
    result.push_back(Quantity(value,units()));
  }
  return result;
}
TEST_F(UnitsFixture,OSQuantityVector_Constructors) {
  SIUnit u = createSILength();
  OSQuantityVector qvec(u);
  EXPECT_TRUE(qvec.empty());
  qvec.push_back(Quantity(1.0,u));
  qvec.push_back(Quantity(5.5,u));
  EXPECT_ANY_THROW(qvec.push_back(Quantity(1.0,createSIPower())));
  EXPECT_EQ(2u,qvec.size());
  EXPECT_FALSE(qvec.empty());
  qvec.resize(5u,3.0);
  EXPECT_EQ(5u,qvec.size());
  QuantityVector qs = qvec.quantities();
  ASSERT_EQ(5u,qs.size());
  EXPECT_EQ(3.0,qs[3].value());
  EXPECT_EQ("m",qs[3].standardUnitsString());

  qvec = OSQuantityVector(createSIPower(),50u,100.0);
  EXPECT_EQ("W",qvec.units().prettyString());
  qs = qvec.quantities();
  ASSERT_EQ(50u,qs.size());
  EXPECT_DOUBLE_EQ(100.0,qs[31].value());
  EXPECT_EQ("W",qs[25].prettyUnitsString());
  EXPECT_EQ("kg*m^2/s^3",qs[2].standardUnitsString());

  OSQuantityVector qvec2(createSIPower(),DoubleVector(50u,100.0));
  EXPECT_TRUE(qvec2 == qvec);
}
TEST_F(UnitsFixture,OSQuantityVector_Profiling_Construction_QuantityVectorBaseCase) {
  for (unsigned i = 0, n = 100; i < n; ++i) {
    DoubleVector vals = toStandardVector(randVector(0.0,1.0,8760u));
    Unit u = createSIForce();
    QuantityVector result;
    BOOST_FOREACH(double val,vals) {
      result.push_back(Quantity(val,u));
    }
  }
예제 #4
0
std::vector<Quantity> OSArgument::domainAsQuantity() const {
  if (!hasDomain()) {
    LOG_AND_THROW("No domain set for OSArgument '" << name() << "'.");
  }
  QuantityVector result;
  for (const QVariant& value : m_domain) {
    result.push_back(value.value<openstudio::Quantity>());
  }
  return result;
}