TEST_F(UnitsFixture,IPUnit_ArithmeticOperators)
{
    LOG(Debug,"IPUnit_ArithmeticOperators");

    IPUnit u1;
    IPUnit u2 = createIPForce();
    IPUnit u3(IPExpnt(1));

    u1 *= u3;
    testStreamOutput("lb_m",u1);
    Unit u4 = u2*u3;
    ASSERT_TRUE(u4.system() == UnitSystem::IP);
    testStreamOutput("lb_m*lb_f",u4);
    u4.cast<IPUnit>().lbfToLbm();
    testStreamOutput("lb_m^2*ft/s^2",u4);

    Unit u5 = u4/u3;
    EXPECT_TRUE(u5.system() == UnitSystem::IP);
    EXPECT_TRUE(u5 == u2);

    Unit u6 = pow(u5,-6);
    EXPECT_TRUE(u6.system() == UnitSystem::IP);
    testStreamOutput("s^12/lb_m^6*ft^6",u6);
    u6.pow(1,3);
    testStreamOutput("s^4/lb_m^2*ft^2",u6);
}
TEST(Checksum, Streams)
{
  stringstream ss;
  EXPECT_EQ(istream::goodbit, ss.rdstate());
  EXPECT_EQ("00000000", checksum(ss));

  // checksum tried to read from empty stream and both eof and fail bits are set
  EXPECT_EQ(istream::failbit | istream::eofbit, ss.rdstate());

  // need to clear the eofbit that was set when checksum read all the way through
  ss.clear();
  EXPECT_EQ(istream::goodbit, ss.rdstate());

  // write some more to the stringstream
  ss << "Hi there";
  EXPECT_EQ(istream::goodbit, ss.rdstate());
  EXPECT_EQ("1AD514BA", checksum(ss));

  // checksum read all the way through and eofbit is set
  EXPECT_EQ(istream::failbit | istream::eofbit, ss.rdstate());
  EXPECT_EQ("00000000", checksum(ss));
  EXPECT_EQ(istream::failbit | istream::eofbit, ss.rdstate());

  // need to clear the eofbit that was set when checksum read all the way through
  ss.clear();
  EXPECT_EQ(istream::goodbit, ss.rdstate());
  EXPECT_EQ("00000000", checksum(ss));
}
Example #3
0
TEST_F(UnitsFixture,BTUUnit_ArithmeticOperators)
{
  LOG(Debug,"BTUUnit_ArithmeticOperators");

  // /=
  BTUUnit P1(BTUExpnt(1));
  BTUUnit t1(BTUExpnt(0,0,1));
  P1 /= t1;
  EXPECT_EQ("Btu/h",P1.standardString(false));
  EXPECT_EQ(1,P1.baseUnitExponent("Btu"));
  EXPECT_EQ(-1,P1.baseUnitExponent("h"));
  EXPECT_EQ(0,P1.baseUnitExponent("ft"));
  EXPECT_EQ(0,P1.baseUnitExponent("m"));

  // *
  Unit E1 = P1 * t1;
  EXPECT_TRUE(E1.system() == UnitSystem::BTU);
  EXPECT_EQ("Btu",E1.standardString(false));
  EXPECT_EQ("",E1.prettyString());

  // /
  Unit u = P1/E1;
  u /= t1;
  EXPECT_TRUE(u.system() == UnitSystem::BTU);
  EXPECT_EQ("1/h^2",u.standardString(false));
  EXPECT_EQ(-2,u.baseUnitExponent("h"));
  EXPECT_EQ(0,u.baseUnitExponent("Btu"));

  // pow
  u.pow(-1,2);
  EXPECT_EQ("h",u.standardString(false));
  EXPECT_EQ(1,u.baseUnitExponent("h"));

}
TEST_F(UnitsFixture,IPUnit_Constructors)
{
    LOG(Debug,"IPUnit_Constructors");

    IPUnit u1;
    ASSERT_THROW(u1.setBaseUnitExponent("m",1),Exception);
    ASSERT_NO_THROW(u1.setBaseUnitExponent("ft",2));
    testStreamOutput("ft^2",u1);

    IPUnit u2(IPExpnt(1,1,-2));
    testStreamOutput("lb_m*ft/s^2",u2);
    u2.lbmToLbf();
    testStreamOutput("lb_f",u2);
    ASSERT_TRUE(u2.baseUnitExponent("lb_f") == 1);
    ASSERT_TRUE(u2.baseUnitExponent("lb_m") == 0);
    ASSERT_TRUE(u2.baseUnitExponent("m") == 0);
    u2.lbfToLbm();
    testStreamOutput("lb_m*ft/s^2", u2);

    IPUnit u3(IPExpnt(0, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1));
    testStreamOutput("$/ft^2", u3);
    ASSERT_TRUE(u3.baseUnitExponent("$") == 1);
    ASSERT_TRUE(u3.baseUnitExponent("ft") == -2);
    ASSERT_TRUE(u3.baseUnitExponent("s") == 0);
    u3.lbmToLbf();
    testStreamOutput("$/ft^2", u3);
    ASSERT_TRUE(u3.baseUnitExponent("$") == 1);
    ASSERT_TRUE(u3.baseUnitExponent("ft") == -2);
    ASSERT_TRUE(u3.baseUnitExponent("s") == 0);
    u3.lbfToLbm();
    testStreamOutput("$/ft^2", u3);
}
void EnergyPlusFixture::SetUpTestCase() {
  // set up logging
  logFile = FileLogSink(toPath("./EnergyPlusFixture.log"));
  logFile->setLogLevel(Debug);
  openstudio::Logger::instance().standardOutLogger().disable();

  // initialize component paths
  openstudio::path basePath = resourcesPath()/openstudio::toPath("energyplus/Components/");
  // idfComponents consists of .first = path to directory, .second = component type
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_roof_1"),"roof"));
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_roof_2"),"roof"));
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_roof_3"),"roof"));
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_roof_4"),"roof"));
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_roof_5"),"roof"));
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_designday_1"),"designday"));
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_designday_2"),"designday"));
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_designday_3"),"designday"));
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_designday_4"),"designday"));
  idfComponents.push_back(std::pair<openstudio::path,std::string>(basePath/openstudio::toPath("idf_designday_5"),"designday"));

  // delete translated components
  BOOST_FOREACH(const ComponentDirectoryAndType& idfComponent,idfComponents) {
    // delete any *.osc and oscomponent.xml files in the directory
    for (openstudio::directory_iterator it(idfComponent.first), itEnd; it != itEnd; ++it) {
      if (boost::filesystem::is_regular_file(it->status())) {
        std::string ext = openstudio::toString(boost::filesystem::extension(*it));
        if (ext == ".osc") { boost::filesystem::remove(it->path()); }
        if ((ext == ".xml") && (openstudio::toString(it->filename()) == "oscomponent")) { 
          boost::filesystem::remove(it->path()); 
        }
      }
    } // for iterator over directory
  } // foreach component

}
Example #6
0
TEST_F(UnitsFixture,BTUUnit_Constructors)
{
  LOG(Debug,"BTUUnit_Constructors");

  BTUUnit l1(BTUExpnt(0,1));
  BTUUnit P1(BTUExpnt(1,0,-1,0),-3); // mBtu/h
  BTUUnit E1("k",BTUExpnt(1)); // kBtu

  EXPECT_EQ(0,l1.baseUnitExponent("Btu"));
  EXPECT_EQ(1,l1.baseUnitExponent("ft"));
  l1.setBaseUnitExponent("R",-1);
  EXPECT_EQ(-1,l1.baseUnitExponent("R"));
  EXPECT_THROW(l1.setBaseUnitExponent("m",1),Exception);

  EXPECT_EQ("Btu/h",P1.standardString(false));
  EXPECT_EQ("mBtu/h",P1.standardString());
  EXPECT_EQ(UnitSystem::BTU,P1.system().value());
  EXPECT_EQ(0,P1.baseUnitExponent("R"));

  BTUUnit P2(P1);
  EXPECT_EQ(UnitSystem::BTU,P2.system().value());

  EXPECT_EQ("",E1.prettyString());
  EXPECT_EQ("kBtu",E1.standardString());
  EXPECT_EQ(0,E1.baseUnitExponent("ft"));
}
Example #7
0
TEST(Table, Serialization)
{
  // construct table
  openstudio::path p = resourcesPath()/toPath("utilities/Table/EUI.csv");
  Table table = Table::load(p);
  table.setTitle("EUIs");
  table.setCaption("EUIs of several buildings");
  table.setNHead(2);
  table.setNLeft(2);
  p = resourcesPath()/toPath("utilities/Table/EUI.ost");

  // serialize
  openstudio::Time start = openstudio::Time::currentTime();
  table.save(p);
  openstudio::Time totalTime = openstudio::Time::currentTime() - start;
  LOG_FREE(Info, "openstudio.Table", "Time to serialize a small table = " << totalTime);

  // ETH@20100526 Uncommenting this line results in a compiler error that I haven't been
  // able to debug.
  // OptionalTable ot;

  // deserialize
  start = openstudio::Time::currentTime();
  Table loaded = Table::load(p);
  totalTime = openstudio::Time::currentTime() - start;
  LOG_FREE(Info, "openstudio.Table", "Time to deserialize a small table = " << totalTime);
  ASSERT_EQ(static_cast<unsigned>(10),loaded.nRows());
  ASSERT_EQ(static_cast<unsigned>(6),loaded.nCols());
  std::stringstream ss;
  ss << std::fixed << std::setprecision(0) << table[2][2];
  EXPECT_EQ("120",ss.str()); ss.str("");
}
Example #8
0
TEST_F(UnitsFixture,SIUnit_ArithmeticOperators)
{
    LOG(Debug,"SIUnit_ArithmeticOperators");

    SIUnit u1;
    SIUnit u2(SIExpnt(1,1,-2,0),0,"N");
    SIUnit u3(SIExpnt(1)); // kg
    SIUnit u4(SIExpnt(0,1,0,0),-2); // cm

    // multiplication
    u1 *= u3; // kg
    testStreamOutput("kg",u1);
    Unit u5 = u2*u3; // N*kg
    EXPECT_TRUE(u5.system() == UnitSystem::SI);
    testStreamOutput("N*kg",u5);
    Unit u6 = u2*u4; // cJ
    EXPECT_TRUE(u6.system() == UnitSystem::SI);
    testStreamOutput("cJ",u6);

    // division
    u6 /= u4;
    EXPECT_TRUE(u6 == u2);

    // power
    Unit u7 = pow(u4,6); // (cm)^6
    EXPECT_TRUE(u7.system() == UnitSystem::SI);
    testStreamOutput("cm^6",u7);
    EXPECT_EQ("p",u7.scale().abbr);
    u7.pow(1,3); // (cm)^2
    testStreamOutput("m(m^2)",u7); // no 10^-4 scale--moves to 10^-3
}
Example #9
0
TEST(Table, UnitExtraction) {

  openstudio::path p = resourcesPath()/toPath("utilities/Table/HeightWeight.csv");
  Table table = Table::load(p);
  table.setTitle("Height and Weight");
  table.setNHead(1);
  table.setNLeft(1);
  std::string unitStr;
  unitStr = table.units(0);
  EXPECT_TRUE(unitStr.empty());
  unitStr = table.units(1);
  EXPECT_TRUE(unitStr.empty());
  unitStr = table.units(2);
  EXPECT_EQ("lb_m",unitStr);

  p = resourcesPath()/toPath("utilities/Table/EUI.csv");
  table = Table::load(p);
  table.setTitle("EUIs");
  table.setCaption("EUIs of several buildings");
  table.setNHead(2);
  table.setNLeft(2);
  unitStr = table.units(0);
  EXPECT_TRUE(unitStr.empty());
  unitStr = table.units(1);
  EXPECT_TRUE(unitStr.empty());
  unitStr = table.units(2);
  EXPECT_EQ("kBtu/ft^2",unitStr);
  unitStr = table.units(3);
  EXPECT_EQ("MJ/m^2",unitStr);
  unitStr = table.units(4);
  EXPECT_EQ("kBtu/ft^2",unitStr);
  unitStr = table.units(5);
  EXPECT_EQ("MJ/m^2",unitStr);
}
Example #10
0
TEST_F(UnitsFixture,SIUnit_Constructors)
{
    LOG(Debug,"SIUnit_Constructors");

    // default
    SIUnit u1;
    ASSERT_NO_THROW(u1.setBaseUnitExponent("m",1));
    ASSERT_THROW(u1.setBaseUnitExponent("ft",2),Exception);
    testStreamOutput("m",u1);

    // default with pretty string
    SIUnit u2(SIExpnt(1,1,-2,0),0,"N");
    testStreamOutput("N",u2);
    // scale exponent and pretty string
    SIUnit u3(SIExpnt(1,1,-2,0),3,"N");
    testStreamOutput("kN",u3);
    EXPECT_TRUE(u3.baseUnitExponent("kg") == 1);
    EXPECT_TRUE(u3.baseUnitExponent("K") == 0);
    EXPECT_TRUE(u3.baseUnitExponent("ft") == 0);

    u2.setScale("\\mu");
    testStreamOutput("\\muN",u2);

    // scale abbreviation
    SIUnit u4("c",SIExpnt(0,0,0,1));
    testStreamOutput("cK",u4);
    EXPECT_EQ(1,u4.baseUnitExponent("K"));
}
Example #11
0
TEST_F(CoreFixture, PathWatcher_Dir)
{
  Application::instance().application();

  openstudio::path path = toPath("./");
  ASSERT_TRUE(boost::filesystem::exists(path));

  openstudio::path filePath = toPath("./PathWatcher_Dir");
  if (boost::filesystem::exists(filePath)){
    boost::filesystem::remove(filePath);
  }
  ASSERT_FALSE(boost::filesystem::exists(filePath));

  TestPathWatcher watcher(path);
  EXPECT_FALSE(watcher.changed);

  EXPECT_EQ(path.string(), watcher.path().string());

  // catches the file addition
  TestFileWriter w1(filePath, "test 1"); w1.start(); 
  while (!w1.isFinished()){  
    // do not call process events
    QThread::yieldCurrentThread();
  }
  EXPECT_TRUE(boost::filesystem::exists(filePath));

  // calls processEvents
  System::msleep(10);

  EXPECT_TRUE(watcher.changed);
  watcher.changed = false;
  EXPECT_FALSE(watcher.changed);

  // does not catch changes to the file
  TestFileWriter w2(filePath, "test 2"); w2.start(); 
  while (!w2.isFinished()){  
    // do not call process events
    QThread::yieldCurrentThread();
  }
  EXPECT_TRUE(boost::filesystem::exists(filePath));

  // calls processEvents
  System::msleep(10);

  EXPECT_FALSE(watcher.changed);
  
  // catches file removal
  TestFileRemover r1(filePath); r1.start();
  while (!r1.isFinished()){  
    // do not call process events
    QThread::yieldCurrentThread();
  }
  EXPECT_FALSE(boost::filesystem::exists(filePath));

  // calls processEvents
  System::msleep(10);

  EXPECT_TRUE(watcher.changed);
}
Example #12
0
TEST_F(UnitsFixture,QuantityRegex_PumpFields) {

  std::string aUnit;
  // Design Shaft Power per Unit Flow Rate per Unit Head is posing problems
  // After trial and error, I can format the IDD so it works: No parenthesis, one divisor
  // Currently this is the only one that passes
  aUnit = "W*s/m^3*Pa"; EXPECT_TRUE(isUnit(aUnit));
  aUnit = "W*min/gal*ftH_{2}O"; EXPECT_TRUE(isUnit(aUnit));


  std::pair<std::string,int> atomicDecomp;

  aUnit = "ftH_{2}O";
  // this shouldn't be an atomic unit!
  // EXPECT_FALSE(isAtomicUnit(aUnit));

  // But we can at least make sure that the decomposition at least returns the right exponent (1...)
  atomicDecomp = decomposeAtomicUnitString(aUnit);
  EXPECT_EQ("ftH_{2}O", atomicDecomp.first);
  EXPECT_EQ(1, atomicDecomp.second);

  aUnit = "1/ftH_{2}O";
  EXPECT_FALSE(containsScientificNotationValue(aUnit));
  // There is no multiplier (km, ms, etc)
  // This returns TRUE, like above... but we'll make sure it ends up fine...
  // EXPECT_FALSE(containsAtomicUnit(aUnit));

  // 1 over something is a Compound Unit)
  EXPECT_TRUE(containsCompoundUnit(aUnit));

  EXPECT_FALSE(containsScaledUnit(aUnit));
  EXPECT_FALSE(containsDirectScaledUnit(aUnit));
  EXPECT_TRUE(isUnit(aUnit));

  ASSERT_TRUE(isCompoundUnit(aUnit));

  std::pair< std::vector<std::string>,std::vector<std::string> > result;

  result = decomposeCompoundUnitString(aUnit);
  // Nothing on numerator
  ASSERT_EQ(static_cast<size_t>(0),result.first.size());
  // Should have one unit on the denominator
  ASSERT_EQ(static_cast<size_t>(1),result.second.size());
  EXPECT_EQ("ftH_{2}O",result.second[0]);


  // All of these variations do fail
/*
 *  aUnit = "(W*s)/(m^3*Pa)"; EXPECT_TRUE(isUnit(aUnit));
 *  aUnit = "(W*s)/(m^3*Pa)"; EXPECT_TRUE(isUnit(aUnit));
 *
 *  aUnit = "(W*min)/(gal*ftH_{2}O)"; EXPECT_TRUE(isUnit(aUnit));
 *  aUnit = "W*min/(gal*ftH_{2}O)"; EXPECT_TRUE(isUnit(aUnit));
 *
 *  aUnit = "W/((m^3/s)*Pa)"; EXPECT_TRUE(isUnit(aUnit));
 *  aUnit = "W/((gal/min)*ftH_{2}O)"; EXPECT_TRUE(isUnit(aUnit));
 */

}
Example #13
0
TEST(Table, UnitConversion) {

  openstudio::path p = resourcesPath()/toPath("utilities/Table/HeightWeight.csv");
  Table table = Table::load(p);
  table.setTitle("Height and Weight");
  table.setNHead(1);
  table.setNLeft(1);
  EXPECT_FALSE(table.convertUnits(0));
  EXPECT_FALSE(table.convertUnits(1));

  // expanded test to help debug on gcc
  ASSERT_TRUE(table.nRows() >= 2);
  ASSERT_TRUE(table.nCols() >= 3);
  EXPECT_EQ("lb_m",table.units(2));
  std::stringstream ss;
  ss << table[0][2];
  std::string tmp = extractUnitString(ss.str());
  EXPECT_EQ("lb_m",tmp);
  tmp = convertToStandardForm(tmp);
  EXPECT_EQ("lb_m",tmp);
  EXPECT_TRUE(containsRegisteredBaseUnit(tmp));

  ASSERT_TRUE(table[1][2].isInt());
  double d = table[1][2].toDouble();
  Quantity q = createQuantity(d,tmp).get();

  EXPECT_TRUE(table.convertUnits(2));
  std::string unitStr = table.units(2);
  EXPECT_EQ("kg",unitStr);
  p = resourcesPath()/toPath("utilities/Table/HeightWeightSI.csv");
  boost::filesystem::ofstream outFile(p);
  ASSERT_TRUE(outFile);
  table.printToStream(outFile,TableFormat(TableFormat::CSV));
  outFile.close();

  p = resourcesPath()/toPath("utilities/Table/EUI.csv");
  table = Table::load(p);
  table.setTitle("EUIs");
  table.setCaption("EUIs of several buildings");
  table.setNHead(2);
  table.setNLeft(2);
  EXPECT_TRUE(table.convertUnits(2));
  unitStr = table.units(2);
  EXPECT_EQ("kJ/m^2",unitStr);
  // now cols 2 and 3 should be equal except for kJ/m^2 v. MJ/m^2.
  for (unsigned i = 0, n = table.nRows(); i < n; ++i) {
    if (table.isRowIndex(i,Table::BODY)) {
      double d2 = table[i][2].toDouble();
      double d3 = table[i][3].toDouble();
      EXPECT_NEAR((d2-(d3*1000.0))/(d2),0.0,1.0E-3);
    }
  }
  p = resourcesPath()/toPath("utilities/Table/EUISI.csv");
  outFile.open(p);
  ASSERT_TRUE(outFile);
  table.printToStream(outFile,TableFormat(TableFormat::CSV));
  outFile.close();

}
TEST(EnumHelpers, isMember)
{
  openstudio::enums::TestEnum te("third");
  openstudio::StringVector members;
  members.push_back("first");
  members.push_back("elephant"); // bad values are ignored
  EXPECT_FALSE(isMember(te,members));
  members.push_back("third");
  EXPECT_TRUE(isMember(te,members));
}
Example #15
0
void logBeforeAndAfterPathInformation(const std::string& functionName,
                                      const path& before,const path& after) {
  std::stringstream ssb,ssa;
  
  printPathInformation(ssb,before);
  printPathInformation(ssa,after);
  
  LOG_FREE(Debug,"CoreFixture","Before " << functionName << ": " << ssb.str() << std::endl 
           << "After " << functionName << ": " << ssa.str() << std::endl);
}
Example #16
0
void SqlFileFixture::SetUpTestCase()
{
  logFile = FileLogSink(toPath("./SqlFileFixture.log"));
  logFile->setLogLevel(Debug);

  openstudio::path path;
  path = resourcesPath()/toPath("energyplus/5ZoneAirCooled/eplusout.sql");
  sqlFile = openstudio::SqlFile(path);
  ASSERT_TRUE(sqlFile.connectionOpen());
}
Example #17
0
TEST_F(UnitsFixture,SIUnit_LogicalOperators)
{
    LOG(Debug,"SIUnit_LogicalOperators");

    SIUnit u1;
    SIUnit u2(SIExpnt(1,1,-2));
    SIUnit u3(SIExpnt(1,1,-2,0),3);

    EXPECT_TRUE(u2 == u3);
    EXPECT_FALSE(u1 == u3);
}
TEST_F(UnitsFixture,IPUnit_LogicalOperators)
{
    LOG(Debug,"IPUnit_LogicalOperators");

    IPUnit u1 = createIPForce();
    IPUnit u2(IPExpnt(1,1,-2));

    ASSERT_TRUE(u1 == u2);
    u2.setBaseUnitExponent("s",-3);
    ASSERT_TRUE(u1 != u2);
}
Example #19
0
void ProjectFixture::SetUpTestCase() {
  // set up logging
  logFile = FileLogSink(toPath("./ProjectFixture.log"));
  logFile->setLogLevel(Info);
  openstudio::Logger::instance().standardOutLogger().disable();

  // set up data folder
  if (!boost::filesystem::exists(toPath("ProjectFixtureData"))) {
    boost::filesystem::create_directory(toPath("ProjectFixtureData"));
  }

}
Example #20
0
TEST(Compare, EqualityForOneHalfOfPair)
{
  std::pair<std::string,int> p1("Employee",32);
  std::pair<int,bool> p2(-246,true);
  std::pair<bool,std::string> p3(false,"Hello");

  ASSERT_TRUE(firstOfPairEqual(p1,std::string("Employee")));
  ASSERT_FALSE(secondOfPairEqual(p1,55));
  ASSERT_TRUE(secondOfPairEqual(p2,true));
  ASSERT_FALSE(secondOfPairEqual(p3,std::string("World")));
  ASSERT_FALSE(firstOfPairEqual(p2,0));
}
TEST(Checksum, UUIDs) {
  StringVector checksums;
  for (unsigned i = 0, n = 1000; i < n; ++i) {
    checksums.push_back(checksum(toString(createUUID())));
  }
  auto itStart = checksums.begin();
  ++itStart;
  for (auto it = checksums.begin(), itEnd = checksums.end(); 
       itStart != itEnd; ++it, ++itStart) {
    EXPECT_TRUE(std::find(itStart,itEnd,*it) == itEnd);
  }
}
Example #22
0
TEST(Compare, istringEqual)
{
  LOG_FREE(Info, "Compare", "Entering istringEqual")

  // make sure insensitive string compare works
  EXPECT_TRUE(istringEqual("lorem ipsum", "lorem ipsum"));
  EXPECT_TRUE(istringEqual("lorem ipsum", "LOREM IPSUM"));
  EXPECT_TRUE(istringEqual("lorem ipsum", "lOrEm IpsUm"));
  EXPECT_TRUE(istringEqual("lorem ipsum", "LoReM iPSuM"));
  EXPECT_FALSE(istringEqual("lorem ipsum", "dolor sit amet"));

  LOG_FREE(Info, "Compare", "Leaving istringEqual")
}
Example #23
0
void DocumentFixture::SetUpTestCase() {
  // set up logging
  logFile = FileLogSink(toPath("./DocumentFixture.log"));
  logFile->setLogLevel(Info);

  // set up doc
  doc.setTitle("Excerpt from 2009 Grocery TSD");
  doc.addAuthor("Matthew Leach");
  doc.addAuthor("Elaine Hale");
  doc.addAuthor("Adam Hirsch");
  doc.addAuthor("Paul Torcellini");
  doc.setTopHeadingLevel(1u);
  Section section = doc.appendSection("Building Economic Parameters");
  Text txt;
  std::stringstream ss;
  ss << "Our statement of work mandates that the design recommendations be analyzed for cost "
     << "effectiveness based on a five-year analysis period, which is assumed acceptable to a "
     << "majority of developers and owners. The other basic economic parameters required for the "
     << "5-TLCC calculation were taken from RSMeans and the Office of Management and Budget "
     << "(OMB) (CITATIONS).";
  txt.append(ss.str()); ss.str("");
  ss << "This analysis uses the real discount rate, which accounts for the projected rate of "
     << "general inflation found in the Report of the President's Economic Advisors, Analytical "
     << "Perpectives, and is equal to 2.3% for a five-year analysis period (CITATION). By using "
     << "this rate, we do not have to explicitly account for energy and product inflation rates.";
  txt.append(ss.str()); ss.str("");
  ss << "Regional capital cost modifiers are used to convert national averages to regional "
     << "values. These are available from the RSMeans data sets and are applied before any of the "
     << "additional fees listed in TABLE REF, three of which are also provided by RSMeans "
     << "(CITATION).";
  txt.append(ss.str()); ss.str("");
  Table tbl;
  tbl.setTitle("Economic Parameter Values");
  std::vector<std::string> row;
  row.push_back("Economic Parameter");
  row.push_back("Value");
  row.push_back("Data Source");
  tbl.appendRow(row);
  tbl.setNHead(1);
  row[0] = "Analysis Period";            row[1] = "5 Years"; row[2] = "DOE";        tbl.appendRow(row);
  row[0] = "Discount Rate";              row[1] = "2.3%";    row[2] = "OMB";        tbl.appendRow(row);
  row[0] = "O&M Cost Inflation";         row[1] = "0%";      row[2] = "OMB";        tbl.appendRow(row);
  row[0] = "Gas Cost Inflation";         row[1] = "0%";      row[2] = "OMB";        tbl.appendRow(row);
  row[0] = "Electricity Cost Inflation"; row[1] = "0%";      row[2] = "OMB";        tbl.appendRow(row);
  row[0] = "Bond Fee";                   row[1] = "10%";     row[2] = "RSMeans";    tbl.appendRow(row);
  row[0] = "Contractor Fee";             row[1] = "10%";     row[2] = "RSMeans";    tbl.appendRow(row);
  row[0] = "Contingency Fee";            row[1] = "12%";     row[2] = "RSMeans";    tbl.appendRow(row);
  row[0] = "Commissioning Fee";          row[1] = "0.5%";    row[2] = "Assumption"; tbl.appendRow(row);
  section.append(txt);
  section.append(tbl);
}
Example #24
0
// initialize static members
void UnitsFixture::SetUpTestCase() 
{
  logFile = FileLogSink(toPath("./UnitsFixture.log"));
  logFile->setLogLevel(Debug);
  Logger::instance().standardOutLogger().disable();
  
  tol = 1.0E-8;

  openstudio::DoubleVector vals = openstudio::toStandardVector(openstudio::randVector(0.0,1000.0,8760u));
  openstudio::Unit u = openstudio::createSIPower();
  for (double val : vals) {
    testQuantityVector.push_back(openstudio::Quantity(val,u));
  }
  testOSQuantityVector = openstudio::OSQuantityVector(u,vals);
}
TEST_F(UnitsFixture,QuantityRegex_DecomposeAtomicUnits) {
  std::string uStr("m");
  std::pair<std::string,int> result;
  result = decomposeAtomicUnitString(uStr);
  EXPECT_EQ("m",result.first); EXPECT_EQ(1,result.second);

  uStr = "kg^3"; result = decomposeAtomicUnitString(uStr);
  EXPECT_EQ("kg",result.first); EXPECT_EQ(3,result.second);

  uStr = "short^{-3291}"; result = decomposeAtomicUnitString(uStr);
  EXPECT_EQ("short",result.first); EXPECT_EQ(-3291,result.second);

  EXPECT_THROW(decomposeAtomicUnitString("kg^{2}"),openstudio::Exception);
  EXPECT_THROW(decomposeAtomicUnitString("kg/s"),openstudio::Exception);
}
Example #26
0
TEST(Text, ConstructGetSet)
{
  std::string firstParagraph("Let me not stay a jot for dinner; go get it ready.");
  StringVector paragraphs;
  paragraphs.push_back("How now! what art thou?");
  paragraphs.push_back("A man, sir.");
  paragraphs.push_back("What dost thou profess? what wouldst thou with us?");
  std::string lastParagraph("I do profess to be no less than I seem; to serve<br/> \
                            him truly that will put me in trust: to love him<br/> \
                            that is honest; to converse with him that is wise,<br/> \
                            and says little; to fear judgment; to fight when I<br/> \
                            cannot choose; and to eat no fist.");
  
  Text text(firstParagraph);
  StringVector textParagraphs = text.paragraphs();
  ASSERT_EQ(static_cast<unsigned>(1),textParagraphs.size());
  EXPECT_EQ("Let me not stay a jot for dinner; go get it ready.",textParagraphs[0]);

  text = Text(paragraphs);
  text.insert(0,firstParagraph);
  textParagraphs = text.paragraphs();
  EXPECT_EQ(static_cast<unsigned>(4),textParagraphs.size());
  EXPECT_EQ(firstParagraph,textParagraphs[0]);
  text.replace(textParagraphs.size(),lastParagraph);
  textParagraphs = text.paragraphs();
  EXPECT_EQ(static_cast<unsigned>(5),textParagraphs.size());
  EXPECT_ANY_THROW(text.insert(textParagraphs.size() + 2,lastParagraph));
}
TEST_F(UnitsFixture,QuantityRegex_DecomposeCompoundUnits) {
  std::string uStr("1/s");
  std::pair< std::vector<std::string>,std::vector<std::string> > result;
  result = decomposeCompoundUnitString(uStr);
  ASSERT_EQ(static_cast<size_t>(0),result.first.size()); 
  ASSERT_EQ(static_cast<size_t>(1),result.second.size());
  EXPECT_EQ("s",result.second[0]);

  uStr = "kg*m/s^2"; result = decomposeCompoundUnitString(uStr);
  ASSERT_EQ(static_cast<size_t>(2),result.first.size()); 
  ASSERT_EQ(static_cast<size_t>(1),result.second.size());
  EXPECT_EQ("kg",result.first[0]); EXPECT_EQ("m",result.first[1]);
  EXPECT_EQ("s^2",result.second[0]);

  uStr = "s^{-1}/ft^{-1}"; result = decomposeCompoundUnitString(uStr);
  ASSERT_EQ(static_cast<size_t>(1),result.first.size()); 
  ASSERT_EQ(static_cast<size_t>(1),result.second.size());
  EXPECT_EQ("s^{-1}",result.first[0]);
  EXPECT_EQ("ft^{-1}",result.second[0]);

  uStr = "kg"; result = decomposeCompoundUnitString(uStr);
  ASSERT_EQ(static_cast<size_t>(1),result.first.size()); 
  ASSERT_EQ(static_cast<size_t>(0),result.second.size());
  EXPECT_EQ("kg",result.first[0]);

  uStr = "1/s^2*K"; result = decomposeCompoundUnitString(uStr);
  ASSERT_EQ(static_cast<size_t>(0),result.first.size()); 
  ASSERT_EQ(static_cast<size_t>(2),result.second.size());
  EXPECT_EQ("s^2",result.second[0]); EXPECT_EQ("K",result.second[1]);

  EXPECT_THROW(decomposeCompoundUnitString(" kg*m"),openstudio::Exception);
  EXPECT_THROW(decomposeCompoundUnitString("2 1/s"),openstudio::Exception);
}
Example #28
0
TEST_F(CoreFixture, Path_RelativePathToFile) 
{
  path relPath = toPath("energyplus/5ZoneAirCooled/eplusout.sql");
  path fullPath = resourcesPath() / relPath;
  EXPECT_EQ(toString(relPath),toString(relativePath(fullPath,resourcesPath())));

  EXPECT_EQ("eplusout.sql",toString(relativePath(relPath,toPath("energyplus/5ZoneAirCooled/"))));
}
Example #29
0
void IddFixture::SetUpTestCase()
{
  // set up logging
  logFile = FileLogSink(toPath("./IddFixture.log"));
  logFile->setLogLevel(Debug);

  // load from factory and time it
  openstudio::Time start = openstudio::Time::currentTime();
  epIddFile = openstudio::IddFactory::instance().getIddFile(openstudio::IddFileType::EnergyPlus);
  iddLoadTime = openstudio::Time::currentTime() - start;

  LOG(Info, "EnergyPlus IddFile load time (from IddFactory) = " << iddLoadTime);

  start = openstudio::Time::currentTime();
  osIddFile = openstudio::IddFactory::instance().getIddFile(openstudio::IddFileType::OpenStudio);
  iddLoadTime = openstudio::Time::currentTime() - start;

  LOG(Info, "OpenStudio IddFile load time (from IddFactory) = " << iddLoadTime);
}
Example #30
0
TEST_F(UnitsFixture,SIUnit_createFunctions)
{
    SIUnit u;

    u = createSIMass();
    EXPECT_EQ(1,u.baseUnitExponent("kg"));
    EXPECT_EQ(0,u.scale().exponent);
    EXPECT_EQ("kg",u.standardString());
    EXPECT_EQ("",u.prettyString());

    u = createSILength();
    EXPECT_EQ(1,u.baseUnitExponent("m"));
    EXPECT_EQ(0,u.scale().exponent);
    EXPECT_EQ("m",u.standardString());
    EXPECT_EQ("",u.prettyString());

    u = createSITime();
    EXPECT_EQ(1,u.baseUnitExponent("s"));
    EXPECT_EQ(0,u.scale().exponent);
    EXPECT_EQ("s",u.standardString());
    EXPECT_EQ("",u.prettyString());

    u = createSITemperature();
    EXPECT_EQ(1,u.baseUnitExponent("K"));
    EXPECT_EQ(0,u.scale().exponent);
    EXPECT_EQ("K",u.standardString());
    EXPECT_EQ("",u.prettyString());

    u = createSIPeople();
    EXPECT_EQ(1,u.baseUnitExponent("people"));
    EXPECT_EQ(0,u.scale().exponent);
    EXPECT_EQ("people",u.standardString());
    EXPECT_EQ("",u.prettyString());
    u.pow(-1);
    EXPECT_EQ("1/person",u.standardString());

    u = createSIForce();
    EXPECT_EQ(0,u.scale().exponent);
    EXPECT_EQ("kg*m/s^2",u.standardString());
    EXPECT_EQ("N",u.prettyString());

    u = createSIEnergy();
    EXPECT_EQ(0,u.scale().exponent);
    EXPECT_EQ("kg*m^2/s^2",u.standardString());
    EXPECT_EQ("J",u.prettyString());

    u = createSIPower();
    EXPECT_EQ(0,u.scale().exponent);
    EXPECT_EQ("kg*m^2/s^3",u.standardString());
    EXPECT_EQ("W",u.prettyString());

}