updated error messages and test for region.cpp

This commit is contained in:
vpalkar
2022-08-16 16:52:19 -04:00
parent bec86f3f04
commit 559ced9869
2 changed files with 15 additions and 15 deletions

View File

@ -302,7 +302,7 @@ void Region::rotate(double &x, double &y, double &z, double angle)
void Region::options(int narg, char **arg)
{
if (narg < 0) error->all(FLERR, "Illegal region command");
if (narg < 0) utils::missing_cmd_args(FLERR, "region", error);
// option defaults
@ -316,46 +316,46 @@ void Region::options(int narg, char **arg)
int iarg = 0;
while (iarg < narg) {
if (strcmp(arg[iarg], "units") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal region command");
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "region units", error);
if (strcmp(arg[iarg + 1], "box") == 0)
scaleflag = 0;
else if (strcmp(arg[iarg + 1], "lattice") == 0)
scaleflag = 1;
else
error->all(FLERR, "Illegal region command");
error->all(FLERR, "Illegal region units: {}", arg[iarg+1]);
iarg += 2;
} else if (strcmp(arg[iarg], "side") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal region command");
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "region side", error);
if (strcmp(arg[iarg + 1], "in") == 0)
interior = 1;
else if (strcmp(arg[iarg + 1], "out") == 0)
interior = 0;
else
error->all(FLERR, "Illegal region command");
error->all(FLERR, "Illegal region side: {}", arg[iarg+1]);
iarg += 2;
} else if (strcmp(arg[iarg], "move") == 0) {
if (iarg + 4 > narg) error->all(FLERR, "Illegal region command");
if (iarg + 4 > narg) utils::missing_cmd_args(FLERR, "region move", error);
if (strcmp(arg[iarg + 1], "NULL") != 0) {
if (strstr(arg[iarg + 1], "v_") != arg[iarg + 1])
error->all(FLERR, "Illegal region command");
error->all(FLERR, "Illegal region move x displacement variable: {}", arg[iarg+1]);
xstr = utils::strdup(&arg[iarg + 1][2]);
}
if (strcmp(arg[iarg + 2], "NULL") != 0) {
if (strstr(arg[iarg + 2], "v_") != arg[iarg + 2])
error->all(FLERR, "Illegal region command");
error->all(FLERR, "Illegal region move y displacement variable: {}", arg[iarg+2]);
ystr = utils::strdup(&arg[iarg + 2][2]);
}
if (strcmp(arg[iarg + 3], "NULL") != 0) {
if (strstr(arg[iarg + 3], "v_") != arg[iarg + 3])
error->all(FLERR, "Illegal region command");
error->all(FLERR, "Illegal region move z displacement variable: {}", arg[iarg+3]);
zstr = utils::strdup(&arg[iarg + 3][2]);
}
moveflag = 1;
iarg += 4;
} else if (strcmp(arg[iarg], "rotate") == 0) {
if (iarg + 8 > narg) error->all(FLERR, "Illegal region command");
if (iarg + 8 > narg) utils::missing_cmd_args(FLERR, "region rotate", error);
if (strstr(arg[iarg + 1], "v_") != arg[iarg + 1]) error->all(FLERR, "Illegal region command");
tstr = utils::strdup(&arg[iarg + 1][2]);
point[0] = utils::numeric(FLERR, arg[iarg + 2], false, lmp);
@ -368,15 +368,14 @@ void Region::options(int narg, char **arg)
iarg += 8;
} else if (strcmp(arg[iarg], "open") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal region command");
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "region open", error);
int iface = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
if (iface < 1 || iface > 6) error->all(FLERR, "Illegal region command");
if (iface < 1 || iface > 6) error->all(FLERR, "Illegal region open face index: {}", iface);
// additional checks on valid face index are done by region classes
open_faces[iface - 1] = 1;
openflag = 1;
iarg += 2;
} else
error->all(FLERR, "Illegal region command");
} else error->all(FLERR, "Illegal region command argument: {}", arg[iarg]);
}
// error check

View File

@ -203,7 +203,8 @@ TEST_F(RegionTest, DeathTests)
TEST_FAILURE(".*ERROR: Illegal region cylinder axis: xx.*", command("region reg9 cylinder xx 0 0 1 0 1 open 1 units box"););
TEST_FAILURE(".*ERROR: Unrecognized region style 'xxx'.*", command("region new1 xxx"););
TEST_FAILURE(".*ERROR: Illegal region command.*", command("region new1 block 0 1"););
//TEST_FAILURE(".*ERROR: Illegal region command.*", command("region new1 block 0 1"););
TEST_FAILURE(".*ERROR: Illegal region command: missing argument\\(s\\).*", command("region new1 block 0 1"););
TEST_FAILURE(".*ERROR: Delete region new3 does not exist.*", command("region new3 delete"););
}