Esempio n. 1
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());
  
}
Esempio n. 2
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()));
}