added some death tests and more readable code for some error messages

This commit is contained in:
vpalkar
2022-08-15 16:16:48 -04:00
parent 000c63a7ce
commit bec86f3f04
3 changed files with 20 additions and 5 deletions

View File

@ -39,8 +39,7 @@ RegCone::RegCone(LAMMPS *lmp, int narg, char **arg) :
if (openflag)
for (int i=3; i<6; i++)
if (open_faces[i])
error->all(FLERR,"Illegal region cone open face: {}", i);
if (open_faces[i]) error->all(FLERR,"Illegal region cone open face: {}", i+1);
if (strcmp(arg[2],"x") != 0 && strcmp(arg[2],"y") != 0 && strcmp(arg[2],"z") != 0)
error->all(FLERR,"Illegal region cone axis: {}", arg[2]);

View File

@ -39,8 +39,7 @@ RegCylinder::RegCylinder(LAMMPS *lmp, int narg, char **arg) :
if (openflag)
for (int i=3; i<6; i++)
if (open_faces[i])
error->all(FLERR,"Illegal region cylinder open face: {}", i);
if (open_faces[i]) error->all(FLERR,"Illegal region cylinder open face: {}", i+1);
if (strcmp(arg[2],"x") != 0 && strcmp(arg[2],"y") != 0 && strcmp(arg[2],"z") != 0)
error->all(FLERR,"Illegal region cylinder axis: {}", arg[2]);

View File

@ -184,10 +184,27 @@ TEST_F(RegionTest, NoBox)
reg = domain->get_region_by_id("reg7");
TEST_FAILURE(".*ERROR: Region intersect region reg1 does not exist.*", reg->init(););
TEST_FAILURE(".*ERROR: Delete region reg3 does not exist.*", command("region reg3 delete"););
}
TEST_F(RegionTest, DeathTests)
{
atomic_system();
auto list = domain->get_region_list();
ASSERT_EQ(list.size(), 1);
TEST_FAILURE(".*ERROR: Illegal region block xlo: 1 >= xhi: 0.*", command("region reg1 block 1 0 0 1 0 1"););
TEST_FAILURE(".*ERROR: Illegal region cone open face: 4.*", command("region reg2 cone x 0 0 2 1 0 1 open 4"););
TEST_FAILURE(".*ERROR: Illegal region plane normal vector: 0 0 0.*", command("region reg3 plane 0 0 0 0 0 0 side out"););
TEST_FAILURE(".*ERROR: Illegal region prism non-zero xy tilt with infinite x size.*", command("region reg4 prism INF INF 0 1 0 1 0.1 0.2 0.3"););
TEST_FAILURE(".*ERROR: Illegal region sphere radius: -1.*", command("region reg5 sphere 0 0 0 -1"););
TEST_FAILURE(".*ERROR: Illegal region ellipsoid c: -2.*", command("region reg8 ellipsoid 0 0 0 2 1 -2"););
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: Delete region reg3 does not exist.*", command("region reg3 delete"););
TEST_FAILURE(".*ERROR: Delete region new3 does not exist.*", command("region new3 delete"););
}
TEST_F(RegionTest, Counts)