Example #1
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 #2
0
TEST_F(CoreFixture, Path_CompletePathToFile)
{
  path p = resourcesPath()/toPath("energyplus/5ZoneAirCooled/eplusout");
  path result = completePathToFile(p,path(),"sql");
  logBeforeAndAfterPathInformation("completePathToFile with ext=\"sql\"",p,result);
  path tmp = p.replace_extension(toPath("sql").string());
  EXPECT_TRUE(result == tmp);

  p = toPath("energyplus/5ZoneAirCooled/eplusout");
  path base = resourcesPath();
  result = completePathToFile(p,base,"sql");
  logBeforeAndAfterPathInformation("completePathToFile with base=resourcesPath() and ext=\"sql\"",p,result);
  EXPECT_TRUE(result == tmp);

  p = resourcesPath()/toPath("energyplus/5ZoneAirCooled.idf");
  result = completePathToFile(p,path(),"sql",true);
  logBeforeAndAfterPathInformation("completePathToFile with ext=\"sql\"",p,result);
  EXPECT_TRUE(result.empty());

  p = resourcesPath()/toPath("energyplus/5ZoneAirCooled");
  result = completePathToFile(p);
  logBeforeAndAfterPathInformation("completePathToFile",p,result);
  EXPECT_TRUE(result.empty());
  
}
Example #3
0
TEST_F(CoreFixture, Path_SetFileExtension)
{
  // example usage for assigning proper file extension
  path p = resourcesPath()/toPath("energyplus/5ZoneAirCooled/in");
  path result = setFileExtension(p,"idf");
  EXPECT_TRUE(boost::filesystem::extension(p).empty());
  EXPECT_TRUE(toString(boost::filesystem::extension(result)) == std::string(".idf"));
  EXPECT_TRUE(boost::filesystem::exists(result));
  EXPECT_TRUE(boost::filesystem::is_regular_file(result));

  // passes out path as is if file extension already set
  p = resourcesPath()/toPath("energyplus/5ZoneAirCooled/in.idf");
  result = setFileExtension(p,"idf");
  EXPECT_TRUE(toString(boost::filesystem::extension(p)) == std::string(".idf"));
  EXPECT_TRUE(toString(boost::filesystem::extension(result)) == std::string(".idf"));

  // will not replace extension, but will log warning and alert user by returning empty path
  p = toPath("energyplus/5ZoneAirCooled/in.osm");
  result = setFileExtension(p,"idf",false);
  EXPECT_TRUE(result == p);

  // will replace extension if asked
  p = toPath("energyplus/5ZoneAirCooled/in.osm");
  result = setFileExtension(p,"idf",true,false);
  EXPECT_TRUE(toString(boost::filesystem::extension(result)) == std::string(".idf"));

  // setFileExtension does not care about existence
  p = toPath("fakeDir/fakeDirOrFile");
  result = setFileExtension(p,"jjj",true);
  EXPECT_TRUE(toString(boost::filesystem::extension(result)) == std::string(".jjj"));
}
Example #4
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);
}
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 #6
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();

}
Example #7
0
TEST(EEFG, DummyTest)
{
  openstudio::path iddPath = resourcesPath()/toPath("eefg/dummy.idd");

  openstudio::path idfPath = resourcesPath()/toPath("eefg/dummy.idf");
  openstudio::path outPath = resourcesPath()/toPath("eefg/eefg.idf");
  eefgValidateIdf(toString(iddPath).c_str(), toString(idfPath).c_str(), toString(outPath).c_str());
}
Example #8
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 #9
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 #10
0
TEST_F(CoreFixture, Path_MakeParentFolder)
{
  // path to directory
  // add one folder
  path p = resourcesPath()/toPath("energyplus/5ZoneAirCooled/MyTestFolder/");
  EXPECT_FALSE(boost::filesystem::is_directory(p));
  EXPECT_FALSE(boost::filesystem::exists(p));
  EXPECT_TRUE(makeParentFolder(p));
  EXPECT_TRUE(boost::filesystem::is_directory(p));
  EXPECT_TRUE(boost::filesystem::exists(p));
  EXPECT_EQ(static_cast<unsigned>(1),boost::filesystem::remove_all(p));

  // path to file
  // add parent folder
  p = resourcesPath()/toPath("energyplus/5ZoneAirCooled/MyTestFolder/in.idf");
  EXPECT_FALSE(boost::filesystem::is_directory(p.parent_path()));
  EXPECT_FALSE(boost::filesystem::exists(p.parent_path()));
  EXPECT_FALSE(boost::filesystem::is_regular_file(p));
  EXPECT_TRUE(makeParentFolder(p));
  EXPECT_TRUE(boost::filesystem::is_directory(p.parent_path()));
  EXPECT_TRUE(boost::filesystem::exists(p.parent_path()));
  EXPECT_FALSE(boost::filesystem::is_regular_file(p));
  EXPECT_EQ(static_cast<unsigned>(1),boost::filesystem::remove_all(p.parent_path()));

  // path to directory/directory
  // do not add any folders
  p = resourcesPath()/toPath("energyplus/5ZoneAirCooled/MyTestFolder1/MyTestFolder2/MyTestFolder3/");
  EXPECT_FALSE(boost::filesystem::is_directory(p));
  EXPECT_FALSE(boost::filesystem::exists(p));
  EXPECT_FALSE(makeParentFolder(p));
  EXPECT_FALSE(boost::filesystem::is_directory(p));
  EXPECT_FALSE(boost::filesystem::exists(p));

  // path to directory/directory
  // add folders recursively
  p = resourcesPath()/toPath("energyplus/5ZoneAirCooled/MyTestFolder1/MyTestFolder2/MyTestFolder3/");
  EXPECT_FALSE(boost::filesystem::is_directory(p));
  EXPECT_TRUE(makeParentFolder(p,path(),true));
  EXPECT_TRUE(boost::filesystem::is_directory(p));
  EXPECT_EQ(static_cast<unsigned>(3),boost::filesystem::remove_all(p.parent_path().parent_path().parent_path()));

  // path to directory/directory/file
  // use base
  // add folders recursively
  p = toPath("energyplus/5ZoneAirCooled/MyTestFolder1/MyTestFolder2/MyTestFolder3/in.idf");
  path base = resourcesPath();
  path tmp = base/p;
  EXPECT_FALSE(boost::filesystem::is_directory(tmp.parent_path()));
  EXPECT_FALSE(boost::filesystem::is_regular_file(tmp));
  EXPECT_TRUE(makeParentFolder(p,base,true));
  EXPECT_TRUE(boost::filesystem::is_directory(tmp.parent_path()));
  EXPECT_FALSE(boost::filesystem::is_regular_file(tmp));
  EXPECT_EQ(static_cast<unsigned>(3),boost::filesystem::remove_all(tmp.parent_path().parent_path().parent_path()));
}
Example #11
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 #12
0
TEST(EEFG, Test)
{
  openstudio::path iddPath = resourcesPath()/toPath("energyplus/Energy+.idd");

  openstudio::path idfPath = resourcesPath()/toPath("energyplus/5ZoneAirCooled/in.idf");
  openstudio::path outPath = resourcesPath()/toPath("energyplus/5ZoneAirCooled/eefg.idf");
  eefgValidateIdf(toString(iddPath).c_str(), toString(idfPath).c_str(), toString(outPath).c_str());

  idfPath = resourcesPath()/toPath("energyplus/Daylighting_School/in.idf");
  outPath = resourcesPath()/toPath("energyplus/Daylighting_School/eefg.idf");
  eefgValidateIdf(toString(iddPath).c_str(), toString(idfPath).c_str(), toString(outPath).c_str());
}
TEST(FileReference,Constructor) {
  FileReference fileReference(resourcesPath() / toPath("energyplus/5ZoneAirCooled/dummyname.osm"));
  EXPECT_TRUE(fileReference.fileType() == FileReferenceType::OSM);

  fileReference = FileReference(resourcesPath() / toPath("energyplus/5ZoneAirCooled/eplusout.sql"));
  EXPECT_TRUE(fileReference.fileType() == FileReferenceType::SQL);

  fileReference = FileReference(resourcesPath() / toPath("energyplus/5ZoneAirCooled/in.epw"));
  EXPECT_TRUE(fileReference.fileType() == FileReferenceType::EPW);

  fileReference = FileReference(resourcesPath() / toPath("energyplus/5ZoneAirCooled/in.idf"));
  EXPECT_TRUE(fileReference.fileType() == FileReferenceType::IDF);
}
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

}
TEST(Checksum, Paths)
{
  // read a file, contents are "Hi there"
  path p = resourcesPath() / toPath("utilities/Checksum/Checksum.txt");
  EXPECT_EQ("1AD514BA", checksum(p));

  // read a file, contents are "Hi there\r\nGoodbye" on Windows and "Hi there\nGoodbye" otherwise
  p = resourcesPath() / toPath("utilities/Checksum/Checksum2.txt");
  EXPECT_EQ("17B88D3A", checksum(p));

  // checksum of a directory is "00000000"
  p = resourcesPath() / toPath("utilities/Checksum/");
  EXPECT_EQ("00000000", checksum(p));

  // if can't find file return "00000000"
  p = resourcesPath() / toPath("utilities/Checksum/NotAFile.txt");
  EXPECT_EQ("00000000", checksum(p));
}
void SqlFileLargeFixture::SetUpTestCase()
{
  openstudio::Logger::instance().disableStandardOut();
  openstudio::Logger::instance().logLevel(Debug);
  logFile = openstudio::Logger::instance().addLogFile(openstudio::toPath("./SqlFileLargeFixture.log"));

  openstudio::path path;
  path = resourcesPath()/toPath("utilities/eplusout.sql");
  sqlFile = openstudio::SqlFile(path);
  ASSERT_TRUE(sqlFile.connectionOpen());
}
Example #17
0
openstudio::project::ProjectDatabase ProjectFixture::getDatabase(
    const std::string& projectDatabaseName,
    bool getCleanDatabase)
{
  openstudio::path projectDir = toPath("ProjectFixtureData") / toPath(projectDatabaseName);
  if (getCleanDatabase) {
    boost::filesystem::remove_all(projectDir);
  }
  if (!boost::filesystem::exists(projectDir)) {
    boost::filesystem::create_directory(projectDir);
    databaseDirs.push_back(projectDir);
  }

  openstudio::path runPath = projectDir / toPath("run.db");
  openstudio::path projectPath = projectDir / toPath("project.osp");

  openstudio::runmanager::RunManager runManager(runPath, true, false, false);
  openstudio::project::ProjectDatabase database(projectPath, runManager, getCleanDatabase);

  return database;
}
TEST(AnnotatedTimeline, StockPrices)
{
  // make two time series with random data
  unsigned N = 1000;
  TimeSeries t1(Date::currentDate(), Time(0,1), cumsum(randVector(-1,1.1,N), 100), "pesos");
  TimeSeries t2(Date::currentDate(), Time(0,1), cumsum(randVector(-1,1.1,N)), "dollars");

  AnnotatedTimeline::Ptr timeline = AnnotatedTimeline::create();
  timeline->addTimeSeries("Mexican Stocks", t1);
  timeline->addTimeSeries("US Stocks", t2);
  timeline->save(toPath("./StockPrices.htm"));
}
Example #19
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 #20
0
TEST(Table, ConstructFromCSV)
{
  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);
  ASSERT_EQ(static_cast<unsigned>(6),table.nRows());
  ASSERT_EQ(static_cast<unsigned>(3),table.nCols());
  std::stringstream ss;
  ss << table[3][1];
  EXPECT_EQ("4'11\"",ss.str()); ss.str("");
  ss << table[5][2];
  EXPECT_EQ("95",ss.str()); ss.str("");

  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);
  ASSERT_EQ(static_cast<unsigned>(10),table.nRows());
  ASSERT_EQ(static_cast<unsigned>(6),table.nCols());
  ss << std::fixed << std::setprecision(0) << table[2][2];
  EXPECT_EQ("120",ss.str()); ss.str("");

  p = resourcesPath()/toPath("utilities/Table/OddlyShaped.csv");
  table = Table::load(p);
  table.setCaption("An Oddly Shaped Table");
  table.setNHead(1);
  table.setNLeft(1);
  ASSERT_EQ(static_cast<unsigned>(6),table.nRows());
  ASSERT_EQ(static_cast<unsigned>(6),table.nCols());
  ss << table[2][0];
  EXPECT_EQ("Row 2",ss.str()); ss.str("");
}
Example #21
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);
}
Example #22
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 #23
0
void CoreFixture::SetUpTestCase()
{
  // set up logging
  logFile = FileLogSink(toPath("./CoreFixture.log"));
  logFile->setLogLevel(Info);
}
Example #24
0
// initiallize static members
void DataFixture::SetUpTestCase() {
    logFile = FileLogSink(toPath("./DataFixture.log"));
    logFile->setLogLevel(Info);
}
Example #25
0
// initialize static members
void GeometryFixture::SetUpTestCase()
{
  logFile = FileLogSink(toPath("./GeometryFixture.log"));
  logFile->setLogLevel(Debug);
}
Example #26
0
void AnalysisFixture::SetUpTestCase() {
  // set up logging
  logFile = FileLogSink(toPath("./AnalysisFixture.log"));
  logFile->setLogLevel(Debug);  
  openstudio::Logger::instance().standardOutLogger().disable();
}
void RunManagerTestFixture::SetUpTestCase() {
  // set up logging
  logFile = FileLogSink(toPath("./RunManagerTestFixture.log"));
  logFile->setLogLevel(Trace);
  openstudio::Logger::instance().standardOutLogger().disable();
}
Example #28
0
TEST_F(CoreFixture, Path_toString) 
{
  EXPECT_EQ("energyplus/5ZoneAirCooled/eplusout.sql", toString(toPath("energyplus/5ZoneAirCooled/eplusout.sql")));
  EXPECT_EQ("energyplus/5ZoneAirCooled/eplusout.sql", toString(toPath("energyplus\\5ZoneAirCooled\\eplusout.sql")));
  EXPECT_EQ("/energyplus/5ZoneAirCooled/eplusout.sql", toString(toPath("/energyplus/5ZoneAirCooled/eplusout.sql")));
  EXPECT_EQ("/energyplus/5ZoneAirCooled/eplusout.sql", toString(toPath("/energyplus\\5ZoneAirCooled\\eplusout.sql")));
  EXPECT_EQ("energyplus/5ZoneAirCooled/", toString(toPath("energyplus/5ZoneAirCooled/")));
  EXPECT_EQ("energyplus/5ZoneAirCooled/", toString(toPath("energyplus\\5ZoneAirCooled\\")));
  EXPECT_EQ("/energyplus/5ZoneAirCooled/", toString(toPath("/energyplus/5ZoneAirCooled/")));
  EXPECT_EQ("/energyplus/5ZoneAirCooled/", toString(toPath("\\energyplus\\5ZoneAirCooled\\")));
  EXPECT_EQ("energyplus/5ZoneAirCooled", toString(toPath("energyplus/5ZoneAirCooled")));
  EXPECT_EQ("energyplus/5ZoneAirCooled", toString(toPath("energyplus\\5ZoneAirCooled")));
  EXPECT_EQ("/energyplus/5ZoneAirCooled", toString(toPath("/energyplus/5ZoneAirCooled")));
  EXPECT_EQ("/energyplus/5ZoneAirCooled", toString(toPath("\\energyplus\\5ZoneAirCooled")));
}