Esempio n. 1
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"));
}
Esempio n. 2
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/"))));
}
Esempio n. 3
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());
}
Esempio n. 4
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);
  }
}
Esempio n. 5
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());
}
Esempio n. 6
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")));
}