detect yaml file output by file name
This commit is contained in:
@ -1009,6 +1009,7 @@ void FixAveTime::options(int iarg, int narg, char **arg)
|
||||
noff = 0;
|
||||
offlist = nullptr;
|
||||
overwrite = 0;
|
||||
yaml_flag = false;
|
||||
format_user = nullptr;
|
||||
format = (char *) " %g";
|
||||
title1 = nullptr;
|
||||
@ -1020,11 +1021,12 @@ void FixAveTime::options(int iarg, int narg, char **arg)
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"file") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/time command");
|
||||
yaml_flag = utils::strmatch(arg[iarg+1],"\\.[yY][aA]?[mM][lL]$");
|
||||
if (me == 0) {
|
||||
fp = fopen(arg[iarg+1],"w");
|
||||
if (fp == nullptr)
|
||||
error->one(FLERR,"Cannot open fix ave/time file {}: {}",
|
||||
arg[iarg+1], utils::getsyserror());
|
||||
arg[iarg+1], utils::getsyserror());
|
||||
}
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"ave") == 0) {
|
||||
|
||||
@ -48,6 +48,7 @@ class FixAveTime : public Fix {
|
||||
int any_variable_length;
|
||||
int all_variable_length;
|
||||
int lockforever;
|
||||
bool yaml_flag;
|
||||
|
||||
int ave, nwindow, startstep, mode;
|
||||
int noff, overwrite;
|
||||
|
||||
@ -519,6 +519,27 @@ TEST(Utils, strmatch_opt_char)
|
||||
ASSERT_FALSE(utils::strmatch("x_name", "^[cfvid]2?_name"));
|
||||
}
|
||||
|
||||
TEST(Utils, strmatch_yaml_suffix)
|
||||
{
|
||||
ASSERT_TRUE(utils::strmatch("test.yaml", "\\.[yY][aA]?[mM][lL]$"));
|
||||
ASSERT_TRUE(utils::strmatch("test.yml", "\\.[yY][aA]?[mM][lL]$"));
|
||||
ASSERT_TRUE(utils::strmatch("TEST.YAML", "\\.[yY][aA]?[mM][lL]$"));
|
||||
ASSERT_TRUE(utils::strmatch("TEST.YML", "\\.[yY][aA]?[mM][lL]$"));
|
||||
ASSERT_FALSE(utils::strmatch("test.yamlx", "\\.[yY][aA]?[mM][lL]$"));
|
||||
ASSERT_FALSE(utils::strmatch("test.ymlx", "\\.[yY][aA]?[mM][lL]$"));
|
||||
ASSERT_FALSE(utils::strmatch("TEST.YAMLX", "\\.[yY][aA]?[mM][lL]$"));
|
||||
ASSERT_FALSE(utils::strmatch("TEST.YMLX", "\\.[yY][aA]?[mM][lL]$"));
|
||||
ASSERT_FALSE(utils::strmatch("testyaml", "\\.[yY][aA]?[mM][lL]$"));
|
||||
ASSERT_FALSE(utils::strmatch("testyml", "\\.[yY][aA]?[mM][lL]$"));
|
||||
ASSERT_FALSE(utils::strmatch("TESTYAML", "\\.[yY][aA]?[mM][lL]$"));
|
||||
ASSERT_FALSE(utils::strmatch("TESTYML", "\\.[yY][aA]?[mM][lL]$"));
|
||||
ASSERT_FALSE(utils::strmatch("yaml.test", "\\.[yY][aA]?[mM][lL]$"));
|
||||
ASSERT_FALSE(utils::strmatch("yml.test", "\\.[yY][aA]?[mM][lL]$"));
|
||||
ASSERT_FALSE(utils::strmatch("YAML.TEST", "\\.[yY][aA]?[mM][lL]$"));
|
||||
ASSERT_FALSE(utils::strmatch("YML.TEST", "\\.[yY][aA]?[mM][lL]$"));
|
||||
ASSERT_FALSE(utils::strmatch("test", "\\.[yY][aA]?[mM][lL]$"));
|
||||
}
|
||||
|
||||
TEST(Utils, strmatch_dot)
|
||||
{
|
||||
ASSERT_TRUE(utils::strmatch("rigid", ".igid"));
|
||||
|
||||
Reference in New Issue
Block a user