update tests for variable commands
This commit is contained in:
@ -333,7 +333,7 @@ void Variable::set(int narg, char **arg)
|
|||||||
int ivar = find(arg[0]);
|
int ivar = find(arg[0]);
|
||||||
if (ivar >= 0) {
|
if (ivar >= 0) {
|
||||||
if (style[ivar] != STRING)
|
if (style[ivar] != STRING)
|
||||||
error->all(FLERR, 1, "Cannot redefine variable {} as a different style", arg[0]);
|
error->all(FLERR, 1, "Cannot redefine variable {} with a different style", arg[0]);
|
||||||
delete[] data[ivar][0];
|
delete[] data[ivar][0];
|
||||||
copy(1, &scopy, data[ivar]);
|
copy(1, &scopy, data[ivar]);
|
||||||
replaceflag = 1;
|
replaceflag = 1;
|
||||||
@ -359,7 +359,7 @@ void Variable::set(int narg, char **arg)
|
|||||||
utils::errorurl(3));
|
utils::errorurl(3));
|
||||||
if (find(arg[0]) >= 0) {
|
if (find(arg[0]) >= 0) {
|
||||||
if (style[find(arg[0])] != GETENV)
|
if (style[find(arg[0])] != GETENV)
|
||||||
error->all(FLERR, 1, "Cannot redefine variable {} as a different style", arg[0]);
|
error->all(FLERR, 1, "Cannot redefine variable {} with a different style", arg[0]);
|
||||||
remove(find(arg[0]));
|
remove(find(arg[0]));
|
||||||
}
|
}
|
||||||
if (nvar == maxvar) grow();
|
if (nvar == maxvar) grow();
|
||||||
@ -431,7 +431,7 @@ void Variable::set(int narg, char **arg)
|
|||||||
error->all(FLERR, "Variable {}: format variable {} has incompatible style", arg[0], arg[2]);
|
error->all(FLERR, "Variable {}: format variable {} has incompatible style", arg[0], arg[2]);
|
||||||
if (ivar >= 0) {
|
if (ivar >= 0) {
|
||||||
if (style[ivar] != FORMAT)
|
if (style[ivar] != FORMAT)
|
||||||
error->all(FLERR, 1, "Cannot redefine variable {} as a different style", arg[0]);
|
error->all(FLERR, 1, "Cannot redefine variable {} with a different style", arg[0]);
|
||||||
if (!utils::strmatch(arg[3], validfmt))
|
if (!utils::strmatch(arg[3], validfmt))
|
||||||
error->all(FLERR, "Incorrect conversion in format string");
|
error->all(FLERR, "Incorrect conversion in format string");
|
||||||
delete[] data[ivar][0];
|
delete[] data[ivar][0];
|
||||||
@ -471,7 +471,7 @@ void Variable::set(int narg, char **arg)
|
|||||||
int ivar = find(arg[0]);
|
int ivar = find(arg[0]);
|
||||||
if (ivar >= 0) {
|
if (ivar >= 0) {
|
||||||
if (style[ivar] != EQUAL)
|
if (style[ivar] != EQUAL)
|
||||||
error->all(FLERR, 1, "Cannot redefine variable {} as a different style", arg[0]);
|
error->all(FLERR, 1, "Cannot redefine variable {} with a different style", arg[0]);
|
||||||
delete[] data[ivar][0];
|
delete[] data[ivar][0];
|
||||||
data[ivar][0] = utils::strdup(combined);
|
data[ivar][0] = utils::strdup(combined);
|
||||||
replaceflag = 1;
|
replaceflag = 1;
|
||||||
@ -505,7 +505,7 @@ void Variable::set(int narg, char **arg)
|
|||||||
int ivar = find(arg[0]);
|
int ivar = find(arg[0]);
|
||||||
if (ivar >= 0) {
|
if (ivar >= 0) {
|
||||||
if (style[ivar] != ATOM)
|
if (style[ivar] != ATOM)
|
||||||
error->all(FLERR, 1, "Cannot redefine variable {} as a different style", arg[0]);
|
error->all(FLERR, 1, "Cannot redefine variable {} with a different style", arg[0]);
|
||||||
delete[] data[ivar][0];
|
delete[] data[ivar][0];
|
||||||
data[ivar][0] = utils::strdup(combined);
|
data[ivar][0] = utils::strdup(combined);
|
||||||
replaceflag = 1;
|
replaceflag = 1;
|
||||||
@ -539,7 +539,7 @@ void Variable::set(int narg, char **arg)
|
|||||||
int ivar = find(arg[0]);
|
int ivar = find(arg[0]);
|
||||||
if (ivar >= 0) {
|
if (ivar >= 0) {
|
||||||
if (style[ivar] != VECTOR)
|
if (style[ivar] != VECTOR)
|
||||||
error->all(FLERR, 1, "Cannot redefine variable {} as a different style", arg[0]);
|
error->all(FLERR, 1, "Cannot redefine variable {} with a different style", arg[0]);
|
||||||
delete[] data[ivar][0];
|
delete[] data[ivar][0];
|
||||||
delete[] data[ivar][1];
|
delete[] data[ivar][1];
|
||||||
data[ivar][0] = utils::strdup(combined);
|
data[ivar][0] = utils::strdup(combined);
|
||||||
@ -584,7 +584,7 @@ void Variable::set(int narg, char **arg)
|
|||||||
int ivar = find(arg[0]);
|
int ivar = find(arg[0]);
|
||||||
if (ivar >= 0) {
|
if (ivar >= 0) {
|
||||||
if (style[ivar] != PYTHON)
|
if (style[ivar] != PYTHON)
|
||||||
error->all(FLERR, 1, "Cannot redefine variable {} as a different style", arg[0]);
|
error->all(FLERR, 1, "Cannot redefine variable {} with a different style", arg[0]);
|
||||||
delete[] data[ivar][0];
|
delete[] data[ivar][0];
|
||||||
data[ivar][0] = utils::strdup(arg[2]);
|
data[ivar][0] = utils::strdup(arg[2]);
|
||||||
replaceflag = 1;
|
replaceflag = 1;
|
||||||
@ -612,7 +612,7 @@ void Variable::set(int narg, char **arg)
|
|||||||
int ivar = find(arg[0]);
|
int ivar = find(arg[0]);
|
||||||
if (ivar >= 0) {
|
if (ivar >= 0) {
|
||||||
if (style[ivar] != TIMER)
|
if (style[ivar] != TIMER)
|
||||||
error->all(FLERR, 1, "Cannot redefine variable {} as a different style", arg[0]);
|
error->all(FLERR, 1, "Cannot redefine variable {} with a different style", arg[0]);
|
||||||
dvalue[ivar] = platform::walltime();
|
dvalue[ivar] = platform::walltime();
|
||||||
replaceflag = 1;
|
replaceflag = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -638,7 +638,7 @@ void Variable::set(int narg, char **arg)
|
|||||||
int ivar = find(arg[0]);
|
int ivar = find(arg[0]);
|
||||||
if (ivar >= 0) {
|
if (ivar >= 0) {
|
||||||
if (style[ivar] != INTERNAL)
|
if (style[ivar] != INTERNAL)
|
||||||
error->all(FLERR, 1, "Cannot redefine variable {} as a different style", arg[0]);
|
error->all(FLERR, 1, "Cannot redefine variable {} with a different style", arg[0]);
|
||||||
dvalue[nvar] = utils::numeric(FLERR, arg[2], false, lmp);
|
dvalue[nvar] = utils::numeric(FLERR, arg[2], false, lmp);
|
||||||
replaceflag = 1;
|
replaceflag = 1;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -207,19 +207,19 @@ TEST_F(VariableTest, CreateDelete)
|
|||||||
command("variable dummy loop -1"););
|
command("variable dummy loop -1"););
|
||||||
TEST_FAILURE(".*ERROR: Illegal variable loop command.*", command("variable dummy loop 10 1"););
|
TEST_FAILURE(".*ERROR: Illegal variable loop command.*", command("variable dummy loop 10 1"););
|
||||||
TEST_FAILURE(".*ERROR: Unknown variable style: xxx.*", command("variable dummy xxxx"););
|
TEST_FAILURE(".*ERROR: Unknown variable style: xxx.*", command("variable dummy xxxx"););
|
||||||
TEST_FAILURE(".*ERROR: Cannot redefine variable as a different style.*",
|
TEST_FAILURE(".*ERROR: Cannot redefine variable two with a different style.*",
|
||||||
command("variable two string xxx"););
|
command("variable two string xxx"););
|
||||||
TEST_FAILURE(".*ERROR: Cannot redefine variable as a different style.*",
|
TEST_FAILURE(".*ERROR: Cannot redefine variable two with a different style.*",
|
||||||
command("variable two getenv xxx"););
|
command("variable two getenv xxx"););
|
||||||
TEST_FAILURE(".*ERROR: Cannot redefine variable as a different style.*",
|
TEST_FAILURE(".*ERROR: Cannot redefine variable one with a different style.*",
|
||||||
command("variable one equal 2"););
|
command("variable one equal 2"););
|
||||||
TEST_FAILURE(".*ERROR: Cannot redefine variable as a different style.*",
|
TEST_FAILURE(".*ERROR: Cannot redefine variable one with a different style.*",
|
||||||
command("variable one internal 2"););
|
command("variable one internal 2"););
|
||||||
TEST_FAILURE(".*ERROR: Cannot use atomfile-style variable unless an atom map exists.*",
|
TEST_FAILURE(".*ERROR: Cannot use atomfile-style variable unless an atom map exists.*",
|
||||||
command("variable eleven atomfile test_variable.atomfile"););
|
command("variable eleven atomfile test_variable.atomfile"););
|
||||||
TEST_FAILURE(".*ERROR on proc 0: Cannot open file variable nine1 file test_variable.xxx.*",
|
TEST_FAILURE(".*ERROR on proc 0: Cannot open file variable nine1 file test_variable.xxx.*",
|
||||||
command("variable nine1 file test_variable.xxx"););
|
command("variable nine1 file test_variable.xxx"););
|
||||||
TEST_FAILURE(".*ERROR: World variable count doesn't match # of partitions.*",
|
TEST_FAILURE(".*ERROR: World variable count 2 doesn't match # of partitions.*",
|
||||||
command("variable ten10 world xxx xxx"););
|
command("variable ten10 world xxx xxx"););
|
||||||
TEST_FAILURE(".*ERROR: All universe/uloop variables must have same # of values.*",
|
TEST_FAILURE(".*ERROR: All universe/uloop variables must have same # of values.*",
|
||||||
command("variable ten6 uloop 2"););
|
command("variable ten6 uloop 2"););
|
||||||
@ -291,9 +291,9 @@ TEST_F(VariableTest, AtomicSystem)
|
|||||||
ASSERT_DOUBLE_EQ(variable->compute_equal("1.5+3.25"), 4.75);
|
ASSERT_DOUBLE_EQ(variable->compute_equal("1.5+3.25"), 4.75);
|
||||||
ASSERT_DOUBLE_EQ(variable->compute_equal("-2.5*1.5"), -3.75);
|
ASSERT_DOUBLE_EQ(variable->compute_equal("-2.5*1.5"), -3.75);
|
||||||
|
|
||||||
TEST_FAILURE(".*ERROR: Cannot redefine variable as a different style.*",
|
TEST_FAILURE(".*ERROR: Cannot redefine variable one with a different style.*",
|
||||||
command("variable one atom x"););
|
command("variable one atom x"););
|
||||||
TEST_FAILURE(".*ERROR: Cannot redefine variable as a different style.*",
|
TEST_FAILURE(".*ERROR: Cannot redefine variable id with a different style.*",
|
||||||
command("variable id vector f_press"););
|
command("variable id vector f_press"););
|
||||||
TEST_FAILURE(".*ERROR on proc 0: Cannot open atomfile variable ten1 file test_variable.xxx.*",
|
TEST_FAILURE(".*ERROR on proc 0: Cannot open atomfile variable ten1 file test_variable.xxx.*",
|
||||||
command("variable ten1 atomfile test_variable.xxx"););
|
command("variable ten1 atomfile test_variable.xxx"););
|
||||||
@ -341,7 +341,8 @@ TEST_F(VariableTest, Expressions)
|
|||||||
command("variable ten8 equal 1|^0");
|
command("variable ten8 equal 1|^0");
|
||||||
command("variable ten9 equal v_one-v_ten9");
|
command("variable ten9 equal v_one-v_ten9");
|
||||||
command("variable ten10 internal 100.0");
|
command("variable ten10 internal 100.0");
|
||||||
command("variable ten11 equal (1 != 1)+(2 < 1)+(2<=1)+(1>2)+(1>=2)+(1&&0)+(0||0)+(1|^1)+10^0");
|
command(
|
||||||
|
"variable ten11 equal (1 != 1)+(2 < 1)+(2<=1)+(1>2)+(1>=2)+(1&&0)+(0||0)+(1|^1)+10^0");
|
||||||
command("variable ten12 equal yes+no+on+off+true+false");
|
command("variable ten12 equal yes+no+on+off+true+false");
|
||||||
command("variable err1 equal v_one/v_ten7");
|
command("variable err1 equal v_one/v_ten7");
|
||||||
command("variable err2 equal v_one%v_ten7");
|
command("variable err2 equal v_one%v_ten7");
|
||||||
@ -626,7 +627,8 @@ TEST_F(VariableTest, NextCommand)
|
|||||||
|
|
||||||
TEST_FAILURE(".*ERROR: Illegal next command.*", command("next"););
|
TEST_FAILURE(".*ERROR: Illegal next command.*", command("next"););
|
||||||
TEST_FAILURE(".*ERROR: Invalid variable 'xxx' in next command.*", command("next xxx"););
|
TEST_FAILURE(".*ERROR: Invalid variable 'xxx' in next command.*", command("next xxx"););
|
||||||
TEST_FAILURE(".*ERROR: Invalid variable style with next command.*", command("next two"););
|
TEST_FAILURE(".*ERROR: Variable two has invalid style equal for next command.*",
|
||||||
|
command("next two"););
|
||||||
TEST_FAILURE(".*ERROR: All variables in next command must have same style.*",
|
TEST_FAILURE(".*ERROR: All variables in next command must have same style.*",
|
||||||
command("next five four"););
|
command("next five four"););
|
||||||
}
|
}
|
||||||
@ -792,7 +794,7 @@ TEST_F(VariableTest, Format)
|
|||||||
command("variable f1idx format yyy %8.4f"););
|
command("variable f1idx format yyy %8.4f"););
|
||||||
TEST_FAILURE(".*ERROR: Variable f1three: format variable three does not exist.*",
|
TEST_FAILURE(".*ERROR: Variable f1three: format variable three does not exist.*",
|
||||||
variable->retrieve("f1three"););
|
variable->retrieve("f1three"););
|
||||||
TEST_FAILURE(".*ERROR: Cannot redefine variable as a different style.*",
|
TEST_FAILURE(".*ERROR: Cannot redefine variable f2one with a different style.*",
|
||||||
command("variable f2one equal 0.5"););
|
command("variable f2one equal 0.5"););
|
||||||
TEST_FAILURE(".*ERROR: Illegal variable command.*", command("variable xxx format \"xxx\""););
|
TEST_FAILURE(".*ERROR: Illegal variable command.*", command("variable xxx format \"xxx\""););
|
||||||
TEST_FAILURE(".*ERROR: Incorrect conversion in format string.*",
|
TEST_FAILURE(".*ERROR: Incorrect conversion in format string.*",
|
||||||
|
|||||||
Reference in New Issue
Block a user