more test coverage for utils::bounds()

This commit is contained in:
Axel Kohlmeyer
2025-07-16 12:50:42 -04:00
parent 3daa0c0726
commit 13d3cfa2b6
2 changed files with 19 additions and 0 deletions

View File

@ -91,6 +91,10 @@ TEST_F(AdvancedUtils, bounds_int_fail)
utils::bounds(FLERR, "?", -10, 5, nlo, nhi, error););
TEST_FAILURE("ERROR: Invalid range string: 3\\*:2 ",
utils::bounds(FLERR, "3*:2", -10, 5, nlo, nhi, error););
TEST_FAILURE("ERROR: Numeric index 1 is out of bounds \\(5-6\\).*",
utils::bounds(FLERR, "1*4", 5, 6, nlo, nhi, error););
TEST_FAILURE("ERROR: Numeric index 4 is out of bounds \\(1-3\\).*",
utils::bounds(FLERR, "1*4", 1, 3, nlo, nhi, error););
}
TEST_F(AdvancedUtils, bounds_bigint_fail)
@ -108,6 +112,10 @@ TEST_F(AdvancedUtils, bounds_bigint_fail)
utils::bounds(FLERR, "?", -10, 5, nlo, nhi, error););
TEST_FAILURE("ERROR: Invalid range string: 3\\*:2 ",
utils::bounds(FLERR, "3*:2", -10, 5, nlo, nhi, error););
TEST_FAILURE("ERROR: Numeric index 1 is out of bounds \\(5-6\\).*",
utils::bounds(FLERR, "1*4", 5, 6, nlo, nhi, error););
TEST_FAILURE("ERROR: Numeric index 4 is out of bounds \\(1-3\\).*",
utils::bounds(FLERR, "1*4", 1, 3, nlo, nhi, error););
}
TEST_F(AdvancedUtils, expand_args)

View File

@ -11,6 +11,7 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "atom.h"
#include "lmptype.h"
#include "pointers.h"
#include "tokenizer.h"
@ -989,6 +990,16 @@ TEST(Utils, boundsbig_case3)
ASSERT_EQ(nhi, -1);
}
TEST(Utils, bounds_typelabel_forward)
{
int nlo, nhi;
nlo = nhi = -1;
utils::bounds_typelabel(FLERR, "2*9", 0, 10, nlo, nhi, nullptr, Atom::ATOM);
ASSERT_EQ(nlo, 2);
ASSERT_EQ(nhi, 9);
}
TEST(Utils, parse_grid_id)
{
auto words = utils::parse_grid_id(FLERR, "c_1:full:density", nullptr);