simplify and apply clang-format

This commit is contained in:
Axel Kohlmeyer 2021-03-24 11:24:55 -04:00
parent b6a030532d
commit 487c55edf0
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
21 changed files with 983 additions and 1016 deletions

View File

@ -191,7 +191,7 @@ TEST(MPI, multi_partition)
EXPECT_EQ(lammps_extract_setting(lmp, "world_rank"), 0);
char *part_id = (char *)lammps_extract_variable(lmp, "partition", nullptr);
ASSERT_THAT(part_id, StrEq(std::to_string(me+1)));
ASSERT_THAT(part_id, StrEq(std::to_string(me + 1)));
lammps_close(lmp);
};

View File

@ -73,7 +73,7 @@ protected:
if (!verbose) ::testing::internal::CaptureStdout();
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
if (!verbose) ::testing::internal::GetCapturedStdout();
group = lmp->group;
group = lmp->group;
domain = lmp->domain;
}

View File

@ -59,6 +59,7 @@ using ::testing::StrEq;
class KimCommandsTest : public ::testing::Test {
protected:
LAMMPS *lmp;
Variable *variable;
void SetUp() override
{
@ -68,6 +69,7 @@ protected:
if (!verbose) ::testing::internal::CaptureStdout();
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
if (!verbose) ::testing::internal::GetCapturedStdout();
variable = lmp->input->variable;
}
void TearDown() override
@ -76,53 +78,45 @@ protected:
delete lmp;
if (!verbose) ::testing::internal::GetCapturedStdout();
}
void command(const std::string &cmd) { lmp->input->one(cmd); }
};
TEST_F(KimCommandsTest, kim)
{
if (!LAMMPS::is_installed_pkg("KIM")) GTEST_SKIP();
TEST_FAILURE(".*ERROR: Illegal kim command.*",
lmp->input->one("kim"););
TEST_FAILURE(".*ERROR: Unknown kim subcommand.*",
lmp->input->one("kim unknown"););
TEST_FAILURE(".*kim_init.*has been renamed to.*",
lmp->input->one("kim_init"););
TEST_FAILURE(".*kim_interactions.*has been renamed to.*",
lmp->input->one("kim_interactions"););
TEST_FAILURE(".*kim_param.*has been renamed to.*",
lmp->input->one("kim_param"););
TEST_FAILURE(".*kim_property.*has been renamed to.*",
lmp->input->one("kim_property"););
TEST_FAILURE(".*kim_query.*has been renamed to.*",
lmp->input->one("kim_query"););
TEST_FAILURE(".*ERROR: Illegal kim command.*", command("kim"););
TEST_FAILURE(".*ERROR: Unknown kim subcommand.*", command("kim unknown"););
TEST_FAILURE(".*kim_init.*has been renamed to.*", command("kim_init"););
TEST_FAILURE(".*kim_interactions.*has been renamed to.*", command("kim_interactions"););
TEST_FAILURE(".*kim_param.*has been renamed to.*", command("kim_param"););
TEST_FAILURE(".*kim_property.*has been renamed to.*", command("kim_property"););
TEST_FAILURE(".*kim_query.*has been renamed to.*", command("kim_query"););
}
TEST_F(KimCommandsTest, kim_init)
{
if (!LAMMPS::is_installed_pkg("KIM")) GTEST_SKIP();
TEST_FAILURE(".*ERROR: Illegal 'kim init' command.*", command("kim init"););
TEST_FAILURE(".*ERROR: Illegal 'kim init' command.*",
lmp->input->one("kim init"););
TEST_FAILURE(".*ERROR: Illegal 'kim init' command.*",
lmp->input->one("kim init LennardJones_Ar real si"););
command("kim init LennardJones_Ar real si"););
TEST_FAILURE(".*ERROR: LAMMPS unit_style lj not supported by KIM models.*",
lmp->input->one("kim init LennardJones_Ar lj"););
command("kim init LennardJones_Ar lj"););
TEST_FAILURE(".*ERROR: LAMMPS unit_style micro not supported by KIM models.*",
lmp->input->one("kim init LennardJones_Ar micro"););
command("kim init LennardJones_Ar micro"););
TEST_FAILURE(".*ERROR: LAMMPS unit_style nano not supported by KIM models.*",
lmp->input->one("kim init LennardJones_Ar nano"););
TEST_FAILURE(".*ERROR: Unknown unit_style.*",
lmp->input->one("kim init LennardJones_Ar new_style"););
TEST_FAILURE(".*ERROR: KIM Model name not found.*",
lmp->input->one("kim init Unknown_Model real"););
command("kim init LennardJones_Ar nano"););
TEST_FAILURE(".*ERROR: Unknown unit_style.*", command("kim init LennardJones_Ar new_style"););
TEST_FAILURE(".*ERROR: KIM Model name not found.*", command("kim init Unknown_Model real"););
TEST_FAILURE(".*ERROR: Incompatible units for KIM Simulator Model, required units = metal.*",
lmp->input->one("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu real"););
command("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu real"););
// TEST_FAILURE(".*ERROR: KIM Model does not support the requested unit system.*",
// lmp->input->one("kim init ex_model_Ar_P_Morse real"););
// command("kim init ex_model_Ar_P_Morse real"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("kim init LennardJones_Ar real");
command("kim init LennardJones_Ar real");
if (!verbose) ::testing::internal::GetCapturedStdout();
int ifix = lmp->modify->find_fix("KIM_MODEL_STORE");
@ -133,124 +127,122 @@ TEST_F(KimCommandsTest, kim_interactions)
{
if (!LAMMPS::is_installed_pkg("KIM")) GTEST_SKIP();
TEST_FAILURE(".*ERROR: Illegal 'kim interactions' command.*",
lmp->input->one("kim interactions"););
TEST_FAILURE(".*ERROR: Illegal 'kim interactions' command.*", command("kim interactions"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("kim init LennardJones_Ar real");
command("kim init LennardJones_Ar real");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Must use 'kim interactions' command "
"after simulation box is defined.*",
lmp->input->one("kim interactions Ar"););
command("kim interactions Ar"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("kim init LennardJones_Ar real");
lmp->input->one("lattice fcc 4.4300");
lmp->input->one("region box block 0 10 0 10 0 10");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 box");
command("kim init LennardJones_Ar real");
command("lattice fcc 4.4300");
command("region box block 0 10 0 10 0 10");
command("create_box 1 box");
command("create_atoms 1 box");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Illegal 'kim interactions' command.*",
lmp->input->one("kim interactions Ar Ar"););
command("kim interactions Ar Ar"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("lattice fcc 4.4300");
lmp->input->one("region box block 0 20 0 20 0 20");
lmp->input->one("create_box 4 box");
lmp->input->one("create_atoms 4 box");
command("clear");
command("lattice fcc 4.4300");
command("region box block 0 20 0 20 0 20");
command("create_box 4 box");
command("create_atoms 4 box");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Illegal 'kim interactions' command.*",
lmp->input->one("kim interactions Ar Ar"););
command("kim interactions Ar Ar"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("lattice fcc 4.4300");
lmp->input->one("region box block 0 10 0 10 0 10");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 box");
command("clear");
command("lattice fcc 4.4300");
command("region box block 0 10 0 10 0 10");
command("create_box 1 box");
command("create_atoms 1 box");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Must use 'kim init' before 'kim interactions'.*",
lmp->input->one("kim interactions Ar"););
command("kim interactions Ar"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("kim init LennardJones_Ar real");
lmp->input->one("lattice fcc 4.4300");
lmp->input->one("region box block 0 10 0 10 0 10");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 box");
command("clear");
command("kim init LennardJones_Ar real");
command("lattice fcc 4.4300");
command("region box block 0 10 0 10 0 10");
command("create_box 1 box");
command("create_atoms 1 box");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: fixed_types cannot be used with a KIM Portable Model.*",
lmp->input->one("kim interactions fixed_types"););
command("kim interactions fixed_types"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("pair_style kim LennardJones_Ar");
lmp->input->one("region box block 0 1 0 1 0 1");
lmp->input->one("create_box 4 box");
lmp->input->one("pair_coeff * * Ar Ar Ar Ar");
command("clear");
command("units real");
command("pair_style kim LennardJones_Ar");
command("region box block 0 1 0 1 0 1");
command("create_box 4 box");
command("pair_coeff * * Ar Ar Ar Ar");
if (!verbose) ::testing::internal::GetCapturedStdout();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu metal");
lmp->input->one("lattice fcc 4.920");
lmp->input->one("region box block 0 10 0 10 0 10");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 box");
command("clear");
command("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu metal");
command("lattice fcc 4.920");
command("region box block 0 10 0 10 0 10");
command("create_box 1 box");
command("create_atoms 1 box");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Species 'Ar' is not supported by this KIM Simulator Model.*",
lmp->input->one("kim interactions Ar"););
command("kim interactions Ar"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu metal");
lmp->input->one("lattice fcc 4.08");
lmp->input->one("region box block 0 10 0 10 0 10");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 box");
lmp->input->one("kim interactions Au");
command("clear");
command("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu metal");
command("lattice fcc 4.08");
command("region box block 0 10 0 10 0 10");
command("create_box 1 box");
command("create_atoms 1 box");
command("kim interactions Au");
if (!verbose) ::testing::internal::GetCapturedStdout();
// ASSERT_EQ(lmp->output->var_kim_periodic, 1);
// TEST_FAILURE(".*ERROR: Incompatible units for KIM Simulator Model.*",
// lmp->input->one("kim interactions Au"););
// command("kim interactions Au"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("kim init LennardJones_Ar real");
lmp->input->one("lattice fcc 4.4300");
lmp->input->one("region box block 0 10 0 10 0 10");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 box");
lmp->input->one("kim interactions Ar");
lmp->input->one("mass 1 39.95");
command("clear");
command("kim init LennardJones_Ar real");
command("lattice fcc 4.4300");
command("region box block 0 10 0 10 0 10");
command("create_box 1 box");
command("create_atoms 1 box");
command("kim interactions Ar");
command("mass 1 39.95");
if (!verbose) ::testing::internal::GetCapturedStdout();
int ifix = lmp->modify->find_fix("KIM_MODEL_STORE");
ASSERT_GE(ifix, 0);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("kim init LennardJones_Ar real");
lmp->input->one("lattice fcc 4.4300");
lmp->input->one("region box block 0 10 0 10 0 10");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 box");
lmp->input->one("kim interactions Ar");
lmp->input->one("mass 1 39.95");
lmp->input->one("run 1");
lmp->input->one("kim interactions Ar");
lmp->input->one("run 1");
command("clear");
command("kim init LennardJones_Ar real");
command("lattice fcc 4.4300");
command("region box block 0 10 0 10 0 10");
command("create_box 1 box");
command("create_atoms 1 box");
command("kim interactions Ar");
command("mass 1 39.95");
command("run 1");
command("kim interactions Ar");
command("run 1");
if (!verbose) ::testing::internal::GetCapturedStdout();
}
@ -258,189 +250,188 @@ TEST_F(KimCommandsTest, kim_param)
{
if (!LAMMPS::is_installed_pkg("KIM")) GTEST_SKIP();
TEST_FAILURE(".*ERROR: Illegal 'kim param' command.*",
lmp->input->one("kim param"););
TEST_FAILURE(".*ERROR: Illegal 'kim param' command.*", command("kim param"););
TEST_FAILURE(".*ERROR: Incorrect arguments in 'kim param' command.\n"
"'kim param get/set' is mandatory.*",
lmp->input->one("kim param unknown shift 1 shift"););
command("kim param unknown shift 1 shift"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu metal");
command("clear");
command("kim init Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu metal");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: 'kim param' can only be used with a KIM Portable Model.*",
lmp->input->one("kim param get shift 1 shift"););
command("kim param get shift 1 shift"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("kim init LennardJones612_UniversalShifted__MO_959249795837_003 real");
command("clear");
command("kim init LennardJones612_UniversalShifted__MO_959249795837_003 real");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Illegal 'kim param get' command.\nTo get the new "
"parameter values, pair style must be assigned.\nMust use 'kim"
" interactions' or 'pair_style kim' before 'kim param get'.*",
lmp->input->one("kim param get shift 1 shift"););
command("kim param get shift 1 shift"););
TEST_FAILURE(".*ERROR: Illegal 'kim param set' command.\nTo set the new "
"parameter values, pair style must be assigned.\nMust use 'kim"
" interactions' or 'pair_style kim' before 'kim param set'.*",
lmp->input->one("kim param set shift 1 2"););
command("kim param set shift 1 2"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("kim init LennardJones612_UniversalShifted__MO_959249795837_003 real");
lmp->input->one("lattice fcc 4.4300");
lmp->input->one("region box block 0 10 0 10 0 10");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 box");
lmp->input->one("kim interactions Ar");
lmp->input->one("mass 1 39.95");
command("clear");
command("kim init LennardJones612_UniversalShifted__MO_959249795837_003 real");
command("lattice fcc 4.4300");
command("region box block 0 10 0 10 0 10");
command("create_box 1 box");
command("create_atoms 1 box");
command("kim interactions Ar");
command("mass 1 39.95");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Illegal index '0' for "
"'shift' parameter with the extent of '1'.*",
lmp->input->one("kim param get shift 0 shift"););
command("kim param get shift 0 shift"););
TEST_FAILURE(".*ERROR: Illegal index '2' for "
"'shift' parameter with the extent of '1'.*",
lmp->input->one("kim param get shift 2 shift"););
command("kim param get shift 2 shift"););
TEST_FAILURE(".*ERROR: Illegal index_range.\nExpected integer "
"parameter\\(s\\) instead of '1.' in index_range.*",
lmp->input->one("kim param get shift 1. shift"););
command("kim param get shift 1. shift"););
TEST_FAILURE(".*ERROR: Illegal index_range '1-2' for 'shift' "
"parameter with the extent of '1'.*",
lmp->input->one("kim param get shift 1:2 shift"););
command("kim param get shift 1:2 shift"););
TEST_FAILURE(".*ERROR: Illegal index_range.\nExpected integer "
"parameter\\(s\\) instead of '1-2' in index_range.*",
lmp->input->one("kim param get shift 1-2 shift"););
command("kim param get shift 1-2 shift"););
TEST_FAILURE(".*ERROR: Wrong number of arguments in 'kim param "
"get' command.\nThe LAMMPS '3' variable names or "
"'s1 split' is mandatory.*",
lmp->input->one("kim param get sigmas 1:3 s1 s2"););
command("kim param get sigmas 1:3 s1 s2"););
TEST_FAILURE(".*ERROR: Wrong argument in 'kim param get' command.\nThis "
"Model does not have the requested 'unknown' parameter.*",
lmp->input->one("kim param get unknown 1 unknown"););
command("kim param get unknown 1 unknown"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("kim param get shift 1 shift");
command("kim param get shift 1 shift");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_FALSE(lmp->input->variable->find("shift") == -1);
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("shift")) == "1");
ASSERT_FALSE(variable->find("shift") == -1);
ASSERT_THAT(variable->retrieve("shift"), StrEq("1"));
TEST_FAILURE(".*ERROR: Illegal index '2' for "
"'shift' parameter with the extent of '1'.*",
lmp->input->one("kim param set shift 2 2"););
command("kim param set shift 2 2"););
TEST_FAILURE(".*ERROR: Illegal index_range.\nExpected integer "
"parameter\\(s\\) instead of '1.' in index_range.*",
lmp->input->one("kim param set shift 1. shift"););
command("kim param set shift 1. shift"););
TEST_FAILURE(".*ERROR: Illegal index_range '1-2' for "
"'shift' parameter with the extent of '1'.*",
lmp->input->one("kim param set shift 1:2 2"););
command("kim param set shift 1:2 2"););
TEST_FAILURE(".*ERROR: Wrong number of variable values for pair coefficients.*",
lmp->input->one("kim param set sigmas 1:3 0.5523570 0.4989030"););
command("kim param set sigmas 1:3 0.5523570 0.4989030"););
TEST_FAILURE(".*ERROR: Wrong argument for pair coefficients.\nThis "
"Model does not have the requested '0.4989030' parameter.*",
lmp->input->one("kim param set sigmas 1:1 0.5523570 0.4989030"););
command("kim param set sigmas 1:1 0.5523570 0.4989030"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("variable new_shift equal 2");
lmp->input->one("kim param set shift 1 ${new_shift}");
lmp->input->one("kim param get shift 1 shift");
command("variable new_shift equal 2");
command("kim param set shift 1 ${new_shift}");
command("kim param get shift 1 shift");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("shift")) == "2");
ASSERT_THAT(variable->retrieve("shift"), StrEq("2"));
TEST_FAILURE(".*ERROR: Illegal variable name in 'kim param get'.*",
lmp->input->one("kim param get cutoffs 1:3 list"););
command("kim param get cutoffs 1:3 list"););
TEST_FAILURE(".*ERROR: Illegal variable name in 'kim param get'.*",
lmp->input->one("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 list"););
command("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 list"););
TEST_FAILURE(".*ERROR: Illegal variable name in 'kim param get'.*",
lmp->input->one("kim param get cutoffs 1:3 split"););
command("kim param get cutoffs 1:3 split"););
TEST_FAILURE(".*ERROR: Illegal variable name in 'kim param get'.*",
lmp->input->one("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 split"););
command("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 split"););
TEST_FAILURE(".*ERROR: Illegal variable name in 'kim param get'.*",
lmp->input->one("kim param get cutoffs 1:3 explicit"););
command("kim param get cutoffs 1:3 explicit"););
TEST_FAILURE(".*ERROR: Illegal variable name in 'kim param get'.*",
lmp->input->one("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 explicit"););
command("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 explicit"););
TEST_FAILURE(".*ERROR: Wrong number of arguments in 'kim param get' "
"command.\nThe LAMMPS '3' variable names or 'cutoffs "
"split/list' is mandatory.*",
lmp->input->one("kim param get cutoffs 1:3 cutoffs"););
command("kim param get cutoffs 1:3 cutoffs"););
TEST_FAILURE(".*ERROR: Wrong number of arguments in 'kim param get' "
"command.\nThe LAMMPS '3' variable names or 'cutoffs_1 "
"split' is mandatory.*",
lmp->input->one("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2"););
command("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 cutoffs_3");
command("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 cutoffs_3");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs_1")) == "2.20943");
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs_2")) == "2.10252");
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs_3")) == "5.666115");
ASSERT_THAT(variable->retrieve("cutoffs_1"), StrEq("2.20943"));
ASSERT_THAT(variable->retrieve("cutoffs_2"), StrEq("2.10252"));
ASSERT_THAT(variable->retrieve("cutoffs_3"), StrEq("5.666115"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 cutoffs_3 explicit");
command("kim param get cutoffs 1:3 cutoffs_1 cutoffs_2 cutoffs_3 explicit");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs_1")) == "2.20943");
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs_2")) == "2.10252");
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs_3")) == "5.666115");
ASSERT_THAT(variable->retrieve("cutoffs_1"), StrEq("2.20943"));
ASSERT_THAT(variable->retrieve("cutoffs_2"), StrEq("2.10252"));
ASSERT_THAT(variable->retrieve("cutoffs_3"), StrEq("5.666115"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("kim param get cutoffs 1:3 cutoffs split");
command("kim param get cutoffs 1:3 cutoffs split");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs_1")) == "2.20943");
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs_2")) == "2.10252");
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs_3")) == "5.666115");
ASSERT_THAT(variable->retrieve("cutoffs_1"), StrEq("2.20943"));
ASSERT_THAT(variable->retrieve("cutoffs_2"), StrEq("2.10252"));
ASSERT_THAT(variable->retrieve("cutoffs_3"), StrEq("5.666115"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("kim param get cutoffs 1:3 cutoffs list");
command("kim param get cutoffs 1:3 cutoffs list");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs")) == "2.20943 2.10252 5.666115");
ASSERT_THAT(variable->retrieve("cutoffs"), StrEq("2.20943 2.10252 5.666115"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("kim param set cutoffs 1 2.21 cutoffs 2 2.11");
lmp->input->one("kim param get cutoffs 1:2 cutoffs list");
command("kim param set cutoffs 1 2.21 cutoffs 2 2.11");
command("kim param get cutoffs 1:2 cutoffs list");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs")) == "2.21 2.11");
ASSERT_THAT(variable->retrieve("cutoffs"), StrEq("2.21 2.11"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("kim param set cutoffs 1:3 2.3 2.2 5.7");
lmp->input->one("kim param get cutoffs 1:3 cutoffs list");
command("kim param set cutoffs 1:3 2.3 2.2 5.7");
command("kim param get cutoffs 1:3 cutoffs list");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("cutoffs")) == "2.3 2.2 5.7");
ASSERT_THAT(variable->retrieve("cutoffs"), StrEq("2.3 2.2 5.7"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("lattice fcc 4.4300");
lmp->input->one("region box block 0 10 0 10 0 10");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 box");
lmp->input->one("mass 1 39.95");
lmp->input->one("pair_style kim LennardJones612_UniversalShifted__MO_959249795837_003");
lmp->input->one("pair_coeff * * Ar");
command("clear");
command("units real");
command("lattice fcc 4.4300");
command("region box block 0 10 0 10 0 10");
command("create_box 1 box");
command("create_atoms 1 box");
command("mass 1 39.95");
command("pair_style kim LennardJones612_UniversalShifted__MO_959249795837_003");
command("pair_coeff * * Ar");
if (!verbose) ::testing::internal::GetCapturedStdout();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("kim param get shift 1 shift");
command("kim param get shift 1 shift");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("shift")) == "1");
ASSERT_THAT(variable->retrieve("shift"), StrEq("1"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("variable new_shift equal 2");
lmp->input->one("kim param set shift 1 ${new_shift}");
lmp->input->one("kim param get shift 1 shift");
command("variable new_shift equal 2");
command("kim param set shift 1 ${new_shift}");
command("kim param get shift 1 shift");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_TRUE(std::string(lmp->input->variable->retrieve("shift")) == "2");
ASSERT_THAT(variable->retrieve("shift"), StrEq("2"));
}
TEST_F(KimCommandsTest, kim_property)
@ -452,38 +443,36 @@ TEST_F(KimCommandsTest, kim_property)
TEST_FAILURE(".*ERROR: Invalid Python version.\n"
"The kim-property Python package requires Python "
"3 >= 3.6 support.*",
lmp->input->one("kim property"););
command("kim property"););
} else {
TEST_FAILURE(".*ERROR: Invalid 'kim property' command.*",
lmp->input->one("kim property"););
TEST_FAILURE(".*ERROR: Invalid 'kim property' command.*",
lmp->input->one("kim property create"););
TEST_FAILURE(".*ERROR: Invalid 'kim property' command.*", command("kim property"););
TEST_FAILURE(".*ERROR: Invalid 'kim property' command.*", command("kim property create"););
TEST_FAILURE(".*ERROR: Incorrect arguments in 'kim property' command."
"\n'kim property create/destroy/modify/remove/dump' "
"is mandatory.*",
lmp->input->one("kim property unknown 1 atomic-mass"););
command("kim property unknown 1 atomic-mass"););
}
#if defined(KIM_EXTRA_UNITTESTS)
TEST_FAILURE(".*ERROR: Invalid 'kim property create' command.*",
lmp->input->one("kim property create 1"););
command("kim property create 1"););
TEST_FAILURE(".*ERROR: Invalid 'kim property destroy' command.*",
lmp->input->one("kim property destroy 1 cohesive-potential-energy-cubic-crystal"););
command("kim property destroy 1 cohesive-potential-energy-cubic-crystal"););
TEST_FAILURE(".*ERROR: Invalid 'kim property modify' command.*",
lmp->input->one("kim property modify 1 key short-name"););
command("kim property modify 1 key short-name"););
TEST_FAILURE(".*ERROR: There is no property instance to modify the content.*",
lmp->input->one("kim property modify 1 key short-name source-value 1 fcc"););
command("kim property modify 1 key short-name source-value 1 fcc"););
TEST_FAILURE(".*ERROR: Invalid 'kim property remove' command.*",
lmp->input->one("kim property remove 1 key"););
command("kim property remove 1 key"););
TEST_FAILURE(".*ERROR: There is no property instance to remove the content.*",
lmp->input->one("kim property remove 1 key short-name"););
command("kim property remove 1 key short-name"););
TEST_FAILURE(".*ERROR: There is no property instance to dump the content.*",
lmp->input->one("kim property dump results.edn"););
command("kim property dump results.edn"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("kim init LennardJones612_UniversalShifted__MO_959249795837_003 real");
lmp->input->one("kim property create 1 cohesive-potential-energy-cubic-crystal");
lmp->input->one("kim property modify 1 key short-name source-value 1 fcc");
lmp->input->one("kim property destroy 1");
command("clear");
command("kim init LennardJones612_UniversalShifted__MO_959249795837_003 real");
command("kim property create 1 cohesive-potential-energy-cubic-crystal");
command("kim property modify 1 key short-name source-value 1 fcc");
command("kim property destroy 1");
if (!verbose) ::testing::internal::GetCapturedStdout();
#endif
}
@ -492,264 +481,233 @@ TEST_F(KimCommandsTest, kim_query)
{
if (!LAMMPS::is_installed_pkg("KIM")) GTEST_SKIP();
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.*",
lmp->input->one("kim query"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.*", command("kim query"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe keyword 'split' "
"must be followed by the name of the query function.*",
lmp->input->one("kim query a0 split"););
command("kim query a0 split"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe keyword 'list' "
"must be followed by the name of the query function.*",
lmp->input->one("kim query a0 list"););
command("kim query a0 list"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe keyword 'index' "
"must be followed by the name of the query function.*",
lmp->input->one("kim query a0 index"););
command("kim query a0 index"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe 'list' keyword "
"can not be used after 'split'.*",
lmp->input->one("kim query a0 split list"););
command("kim query a0 split list"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe 'index' keyword "
"can not be used after 'split'.*",
lmp->input->one("kim query a0 split index"););
command("kim query a0 split index"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe 'split' keyword "
"can not be used after 'list'.*",
lmp->input->one("kim query a0 list split"););
command("kim query a0 list split"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe 'index' keyword "
"can not be used after 'list'.*",
lmp->input->one("kim query a0 list index"););
command("kim query a0 list index"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe 'list' keyword "
"can not be used after 'index'.*",
lmp->input->one("kim query a0 index list"););
command("kim query a0 index list"););
TEST_FAILURE(".*ERROR: Illegal 'kim query' command.\nThe 'split' keyword "
"can not be used after 'index'.*",
lmp->input->one("kim query a0 index split"););
command("kim query a0 index split"););
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `crystal` "
"to 'kim query' is wrong. The query format is the "
"keyword=\\[value\\], where value is always an array of one "
"or more comma-separated items.*",
lmp->input->one("kim query a0 get_lattice_constant_cubic "
"crystal"););
command("kim query a0 get_lattice_constant_cubic "
"crystal"););
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `"
"crystal=fcc` to 'kim query' is wrong. The query format is the "
"keyword=\\[value\\], where value is always an array of one "
"or more comma-separated items.*",
lmp->input->one("kim query a0 get_lattice_constant_cubic "
"crystal=fcc"););
command("kim query a0 get_lattice_constant_cubic "
"crystal=fcc"););
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `"
"crystal=\\[fcc` to 'kim query' is wrong. The query format is "
"the keyword=\\[value\\], where value is always an array of "
"one or more comma-separated items.*",
lmp->input->one("kim query a0 get_lattice_constant_cubic "
"crystal=[fcc"););
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `"
command("kim query a0 get_lattice_constant_cubic "
"crystal=[fcc"););
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `"
"crystal=fcc\\]` to 'kim query' is wrong. The query format is "
"the keyword=\\[value\\], where value is always an array of "
"one or more comma-separated items.*",
lmp->input->one("kim query a0 get_lattice_constant_cubic "
"crystal=fcc]"););
command("kim query a0 get_lattice_constant_cubic "
"crystal=fcc]"););
std::string squery("kim query a0 get_lattice_constant_cubic ");
squery += "crystal=[\"fcc\"] species=\"Al\",\"Ni\" units=[\"angstrom\"]";
std::string squery = "kim query a0 get_lattice_constant_cubic "
"crystal=[\"fcc\"] species=\"Al\",\"Ni\" units=[\"angstrom\"]";
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
"\"Al\",\"Ni\"` to 'kim query' is wrong. The query format is "
"the keyword=\\[value\\], where value is always an array of "
"one or more comma-separated items.*",
lmp->input->one(squery););
command(squery););
squery = "kim query a0 get_lattice_constant_cubic ";
squery += "crystal=[fcc] species=Al,Ni units=[angstrom]";
squery = "kim query a0 get_lattice_constant_cubic crystal=[fcc] species=Al,Ni units=[angstrom]";
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
"Al,Ni` to 'kim query' is wrong. The query format is "
"the keyword=\\[value\\], where value is always an array of "
"one or more comma-separated items.*",
lmp->input->one(squery););
command(squery););
squery = "kim query a0 get_lattice_constant_cubic ";
squery += "crystal=[fcc] species=Al,Ni, units=[angstrom]";
squery =
"kim query a0 get_lattice_constant_cubic crystal=[fcc] species=Al,Ni, units=[angstrom]";
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
"Al,Ni,` to 'kim query' is wrong. The query format is "
"the keyword=\\[value\\], where value is always an array of "
"one or more comma-separated items.*",
lmp->input->one(squery););
command(squery););
squery = "kim query a0 get_lattice_constant_cubic ";
squery += "crystal=[fcc] species=[Al,Ni, units=[angstrom]";
squery =
"kim query a0 get_lattice_constant_cubic crystal=[fcc] species=[Al,Ni, units=[angstrom]";
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
"\\[Al,Ni,` to 'kim query' is wrong. The query format is "
"the keyword=\\[value\\], where value is always an array of "
"one or more comma-separated items.*",
lmp->input->one(squery););
command(squery););
squery = "kim query a0 get_lattice_constant_cubic ";
squery += "crystal=[fcc] species=Al,Ni], units=[angstrom]";
squery =
"kim query a0 get_lattice_constant_cubic crystal=[fcc] species=Al,Ni], units=[angstrom]";
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
"Al,Ni\\],` to 'kim query' is wrong. The query format is "
"the keyword=\\[value\\], where value is always an array of "
"one or more comma-separated items.*",
lmp->input->one(squery););
command(squery););
squery = "kim query a0 get_lattice_constant_cubic ";
squery += "crystal=[fcc] species=Al,\"Ni\"], units=[angstrom]";
squery = "kim query a0 get_lattice_constant_cubic crystal=[fcc] species=Al,\"Ni\"], "
"units=[angstrom]";
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
"Al,\"Ni\"\\],` to 'kim query' is wrong. The query format is "
"the keyword=\\[value\\], where value is always an array of "
"one or more comma-separated items.*",
lmp->input->one(squery););
command(squery););
squery = "kim query a0 get_lattice_constant_cubic ";
squery += "crystal=[fcc] species=\"Al\",Ni], units=[angstrom]";
squery = "kim query a0 get_lattice_constant_cubic crystal=[fcc] species=\"Al\",Ni], "
"units=[angstrom]";
TEST_FAILURE(".*ERROR: Illegal query format.\nInput argument of `species="
"\"Al\",Ni\\],` to 'kim query' is wrong. The query format is "
"the keyword=\\[value\\], where value is always an array of "
"one or more comma-separated items.*",
lmp->input->one(squery););
command(squery););
squery = "kim query a0 get_lattice_constant_cubic crystal=[\"fcc\"] "
"species=[\"Al\"]";
squery = "kim query a0 get_lattice_constant_cubic crystal=[\"fcc\"] species=[\"Al\"]";
TEST_FAILURE(".*ERROR: Illegal query format.\nMust use 'kim init' before "
"'kim query' or must provide the model name after query "
"function with the format of 'model=\\[model_name\\]'.*",
lmp->input->one(squery););
command(squery););
squery = "kim query a0 get_lattice_constant_cubic crystal=[fcc] "
"species=[Al]";
squery = "kim query a0 get_lattice_constant_cubic crystal=[fcc] species=[Al]";
TEST_FAILURE(".*ERROR: Illegal query format.\nMust use 'kim init' before "
"'kim query' or must provide the model name after query "
"function with the format of 'model=\\[model_name\\]'.*",
lmp->input->one(squery););
command(squery););
squery = "kim query a0 get_lattice_constant_cubic crystal=[\"fcc\"] "
"species=[Al]";
squery = "kim query a0 get_lattice_constant_cubic crystal=[\"fcc\"] species=[Al]";
TEST_FAILURE(".*ERROR: Illegal query format.\nMust use 'kim init' before "
"'kim query' or must provide the model name after query "
"function with the format of 'model=\\[model_name\\]'.*",
lmp->input->one(squery););
command(squery););
#if defined(KIM_EXTRA_UNITTESTS)
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
squery = "kim query latconst_1 get_lattice_constant_cubic ";
squery += "crystal=[fcc] species=[Al] units=[angstrom] ";
squery += "model=[EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005]";
lmp->input->one(squery);
command("clear");
command("kim query latconst_1 get_lattice_constant_cubic "
"crystal=[fcc] species=[Al] units=[angstrom] "
"model=[EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005]");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst_1")) ==
"4.032082033157349"));
ASSERT_THAT(variable->retrieve("latconst_1"), StrEq("4.032082033157349"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("kim init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal");
command("clear");
command("kim init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal");
command("kim query latconst_1 get_lattice_constant_cubic crystal=[fcc] species=[Al] "
"units=[angstrom]");
squery = "kim query latconst_1 get_lattice_constant_cubic ";
squery += "crystal=[fcc] species=[Al] units=[angstrom]";
lmp->input->one(squery);
squery = "kim query latconst_2 get_lattice_constant_cubic ";
squery += "crystal=[fcc] species=[Al] units=[angstrom] ";
squery += "model=[LennardJones612_UniversalShifted__MO_959249795837_003]";
lmp->input->one(squery);
command("kim query latconst_2 get_lattice_constant_cubic crystal=[fcc] species=[Al] "
"units=[angstrom] "
"model=[LennardJones612_UniversalShifted__MO_959249795837_003]");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst_1")) ==
"4.032082033157349"));
ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst_2")) ==
"3.328125931322575"));
ASSERT_THAT(variable->retrieve("latconst_1"), StrEq("4.032082033157349"));
ASSERT_THAT(variable->retrieve("latconst_2"), StrEq("3.328125931322575"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("kim init EAM_Dynamo_MendelevAckland_2007v3_Zr__MO_004835508849_000 metal");
command("clear");
command("kim init EAM_Dynamo_MendelevAckland_2007v3_Zr__MO_004835508849_000 metal");
squery = "kim query latconst split get_lattice_constant_hexagonal ";
squery += "crystal=[hcp] species=[Zr] units=[angstrom]";
lmp->input->one(squery);
command("kim query latconst split get_lattice_constant_hexagonal crystal=[hcp] species=[Zr] "
"units=[angstrom]");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst_1")) ==
"3.234055244384789"));
ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst_2")) ==
"5.167650199630013"));
ASSERT_THAT(variable->retrieve("latconst_1"), StrEq("3.234055244384789"));
ASSERT_THAT(variable->retrieve("latconst_2"), StrEq("5.167650199630013"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
command("clear");
squery = "kim query latconst index get_lattice_constant_hexagonal ";
squery += "crystal=[hcp] species=[Zr] units=[angstrom] ";
squery += "model=[EAM_Dynamo_MendelevAckland_2007v3_Zr__MO_004835508849_000]";
lmp->input->one(squery);
command("kim query latconst index get_lattice_constant_hexagonal "
"crystal=[hcp] species=[Zr] units=[angstrom] "
"model=[EAM_Dynamo_MendelevAckland_2007v3_Zr__MO_004835508849_000]");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst")) ==
"3.234055244384789"));
ASSERT_THAT(variable->retrieve("latconst"), StrEq("3.234055244384789"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("variable latconst delete");
lmp->input->one("clear");
lmp->input->one("kim init EAM_Dynamo_MendelevAckland_2007v3_Zr__MO_004835508849_000 metal");
command("variable latconst delete");
command("clear");
command("kim init EAM_Dynamo_MendelevAckland_2007v3_Zr__MO_004835508849_000 metal");
squery = "kim query latconst list get_lattice_constant_hexagonal ";
squery += "crystal=[hcp] species=[Zr] units=[angstrom]";
lmp->input->one(squery);
command("kim query latconst list get_lattice_constant_hexagonal crystal=[hcp] species=[Zr] "
"units=[angstrom]");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_TRUE((std::string(lmp->input->variable->retrieve("latconst")) ==
"3.234055244384789 5.167650199630013"));
ASSERT_THAT(variable->retrieve("latconst"), StrEq("3.234055244384789 5.167650199630013"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("kim init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal");
command("clear");
command("kim init EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005 metal");
squery = "kim query alpha get_linear_thermal_expansion_coefficient_cubic ";
squery += "crystal=[fcc] species=[Al] units=[1/K] temperature=[293.15] ";
squery += "temperature_units=[K]";
lmp->input->one(squery);
command("kim query alpha get_linear_thermal_expansion_coefficient_cubic "
"crystal=[fcc] species=[Al] units=[1/K] temperature=[293.15] "
"temperature_units=[K]");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_TRUE((std::string(lmp->input->variable->retrieve("alpha")) ==
"1.654960564704273e-05"));
ASSERT_THAT(variable->retrieve("alpha"), StrEq("1.654960564704273e-05"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
command("clear");
squery = "kim query model_list list get_available_models ";
squery += "species=[Al]";
lmp->input->one(squery);
command("kim query model_list list get_available_models species=[Al]");
if (!verbose) ::testing::internal::GetCapturedStdout();
std::string model_list = lmp->input->variable->retrieve("model_list");
std::string model_list = variable->retrieve("model_list");
auto n = model_list.find("EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005");
ASSERT_TRUE(n != std::string::npos);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
command("clear");
squery = "kim query model_name index get_available_models ";
squery += "species=[Al]";
lmp->input->one(squery);
lmp->input->one("variable model_name delete");
command("kim query model_name index get_available_models species=[Al]");
command("variable model_name delete");
if (!verbose) ::testing::internal::GetCapturedStdout();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
command("clear");
squery = "kim query model_name index get_available_models ";
squery += "species=[Al] potential_type=[eam,meam]";
lmp->input->one(squery);
lmp->input->one("variable model_name delete");
command("kim query model_name index get_available_models "
"species=[Al] potential_type=[eam,meam]");
command("variable model_name delete");
squery = "kim query model_name index get_available_models ";
squery += "species=[Al] potential_type=[\"eam\",\"meam\"]";
lmp->input->one(squery);
lmp->input->one("variable model_name delete");
command("kim query model_name index get_available_models "
"species=[Al] potential_type=[\"eam\",\"meam\"]");
command("variable model_name delete");
squery = "kim query model_name index get_available_models ";
squery += "species=[Al] potential_type=[eam,\"meam\"]";
lmp->input->one(squery);
lmp->input->one("variable model_name delete");
command("kim query model_name index get_available_models "
"species=[Al] potential_type=[eam,\"meam\"]");
command("variable model_name delete");
squery = "kim query model_name index get_available_models ";
squery += "species=[Al] potential_type=[\"eam\",meam]";
lmp->input->one(squery);
lmp->input->one("variable model_name delete");
command("kim query model_name index get_available_models "
"species=[Al] potential_type=[\"eam\",meam]");
command("variable model_name delete");
if (!verbose) ::testing::internal::GetCapturedStdout();
#endif
}

View File

@ -81,12 +81,14 @@ protected:
delete lmp;
if (!verbose) ::testing::internal::GetCapturedStdout();
}
void command(const std::string &cmd) { lmp->input->one(cmd); }
};
TEST_F(LatticeRegionTest, lattice_none)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("lattice none 2.0");
command("lattice none 2.0");
if (!verbose) ::testing::internal::GetCapturedStdout();
auto lattice = lmp->domain->lattice;
ASSERT_EQ(lattice->style, Lattice::NONE);
@ -96,14 +98,14 @@ TEST_F(LatticeRegionTest, lattice_none)
ASSERT_EQ(lattice->nbasis, 0);
ASSERT_EQ(lattice->basis, nullptr);
TEST_FAILURE(".*ERROR: Illegal lattice command.*", lmp->input->one("lattice"););
TEST_FAILURE(".*ERROR: Illegal lattice command.*", lmp->input->one("lattice xxx"););
TEST_FAILURE(".*ERROR: Illegal lattice command.*", lmp->input->one("lattice none 1.0 origin"););
TEST_FAILURE(".*ERROR: Expected floating point.*", lmp->input->one("lattice none xxx"););
TEST_FAILURE(".*ERROR: Illegal lattice command.*", command("lattice"););
TEST_FAILURE(".*ERROR: Illegal lattice command.*", command("lattice xxx"););
TEST_FAILURE(".*ERROR: Illegal lattice command.*", command("lattice none 1.0 origin"););
TEST_FAILURE(".*ERROR: Expected floating point.*", command("lattice none xxx"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units lj");
lmp->input->one("lattice none 1.0");
command("units lj");
command("lattice none 1.0");
if (!verbose) ::testing::internal::GetCapturedStdout();
lattice = lmp->domain->lattice;
ASSERT_EQ(lattice->xlattice, 1.0);
@ -114,7 +116,7 @@ TEST_F(LatticeRegionTest, lattice_none)
TEST_F(LatticeRegionTest, lattice_sc)
{
::testing::internal::CaptureStdout();
lmp->input->one("lattice sc 1.0 spacing 1.5 2.0 3.0");
command("lattice sc 1.0 spacing 1.5 2.0 3.0");
auto output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
ASSERT_THAT(output, MatchesRegex(".*Lattice spacing in x,y,z = 1.50* 2.0* 3.0*.*"));
@ -125,7 +127,7 @@ TEST_F(LatticeRegionTest, lattice_sc)
ASSERT_EQ(lattice->zlattice, 3.0);
::testing::internal::CaptureStdout();
lmp->input->one("lattice sc 2.0");
command("lattice sc 2.0");
output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
ASSERT_THAT(output, MatchesRegex(".*Lattice spacing in x,y,z = 2.0* 2.0* 2.0*.*"));
@ -151,25 +153,24 @@ TEST_F(LatticeRegionTest, lattice_sc)
ASSERT_EQ(lattice->basis[0][2], 0.0);
TEST_FAILURE(".*ERROR: Illegal lattice command.*",
lmp->input->one("lattice sc 1.0 origin 1.0 1.0 1.0"););
command("lattice sc 1.0 origin 1.0 1.0 1.0"););
TEST_FAILURE(".*ERROR: Illegal lattice command.*", command("lattice sc 1.0 origin 1.0"););
TEST_FAILURE(".*ERROR: Illegal lattice command.*",
lmp->input->one("lattice sc 1.0 origin 1.0"););
TEST_FAILURE(".*ERROR: Illegal lattice command.*",
lmp->input->one("lattice sc 1.0 origin 0.0 0.0 0.0 xxx"););
command("lattice sc 1.0 origin 0.0 0.0 0.0 xxx"););
TEST_FAILURE(".*ERROR: Expected floating point.*",
lmp->input->one("lattice sc 1.0 origin xxx 1.0 1.0"););
command("lattice sc 1.0 origin xxx 1.0 1.0"););
TEST_FAILURE(".*ERROR: Lattice orient vectors are not orthogonal.*",
lmp->input->one("lattice sc 1.0 orient x 2 2 0"););
command("lattice sc 1.0 orient x 2 2 0"););
TEST_FAILURE(".*ERROR: Lattice orient vectors are not right-handed.*",
lmp->input->one("lattice sc 1.0 orient y 0 -1 0"););
command("lattice sc 1.0 orient y 0 -1 0"););
TEST_FAILURE(".*ERROR: Lattice spacings are invalid.*",
lmp->input->one("lattice sc 1.0 spacing 0.0 1.0 1.0"););
command("lattice sc 1.0 spacing 0.0 1.0 1.0"););
TEST_FAILURE(".*ERROR: Lattice spacings are invalid.*",
lmp->input->one("lattice sc 1.0 spacing 1.0 -0.1 1.0"););
command("lattice sc 1.0 spacing 1.0 -0.1 1.0"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units lj");
lmp->input->one("lattice sc 2.0");
command("units lj");
command("lattice sc 2.0");
if (!verbose) ::testing::internal::GetCapturedStdout();
lattice = lmp->domain->lattice;
ASSERT_DOUBLE_EQ(lattice->xlattice, pow(0.5, 1.0 / 3.0));
@ -177,16 +178,16 @@ TEST_F(LatticeRegionTest, lattice_sc)
ASSERT_DOUBLE_EQ(lattice->zlattice, pow(0.5, 1.0 / 3.0));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("dimension 2");
command("dimension 2");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Lattice style incompatible with simulation dimension.*",
lmp->input->one("lattice sc 1.0"););
command("lattice sc 1.0"););
}
TEST_F(LatticeRegionTest, lattice_bcc)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("lattice bcc 4.2 orient x 1 1 0 orient y -1 1 0");
command("lattice bcc 4.2 orient x 1 1 0 orient y -1 1 0");
if (!verbose) ::testing::internal::GetCapturedStdout();
auto lattice = lmp->domain->lattice;
ASSERT_EQ(lattice->style, Lattice::BCC);
@ -202,16 +203,16 @@ TEST_F(LatticeRegionTest, lattice_bcc)
ASSERT_EQ(lattice->basis[1][2], 0.5);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("dimension 2");
command("dimension 2");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Lattice style incompatible with simulation dimension.*",
lmp->input->one("lattice bcc 1.0"););
command("lattice bcc 1.0"););
}
TEST_F(LatticeRegionTest, lattice_fcc)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("lattice fcc 3.5 origin 0.5 0.5 0.5");
command("lattice fcc 3.5 origin 0.5 0.5 0.5");
if (!verbose) ::testing::internal::GetCapturedStdout();
auto lattice = lmp->domain->lattice;
ASSERT_EQ(lattice->style, Lattice::FCC);
@ -233,23 +234,22 @@ TEST_F(LatticeRegionTest, lattice_fcc)
ASSERT_EQ(lattice->basis[3][2], 0.5);
TEST_FAILURE(".*ERROR: Invalid option in lattice command for non-custom style.*",
lmp->input->one("lattice fcc 1.0 basis 0.0 0.0 0.0"););
command("lattice fcc 1.0 basis 0.0 0.0 0.0"););
TEST_FAILURE(".*ERROR: Invalid option in lattice command for non-custom style.*",
lmp->input->one("lattice fcc 1.0 a1 0.0 1.0 0.0"););
TEST_FAILURE(".*ERROR: Illegal lattice command.*",
lmp->input->one("lattice fcc 1.0 orient w 1 0 0"););
command("lattice fcc 1.0 a1 0.0 1.0 0.0"););
TEST_FAILURE(".*ERROR: Illegal lattice command.*", command("lattice fcc 1.0 orient w 1 0 0"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("dimension 2");
command("dimension 2");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Lattice style incompatible with simulation dimension.*",
lmp->input->one("lattice fcc 1.0"););
command("lattice fcc 1.0"););
}
TEST_F(LatticeRegionTest, lattice_hcp)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("lattice hcp 3.0 orient z 0 0 1");
command("lattice hcp 3.0 orient z 0 0 1");
if (!verbose) ::testing::internal::GetCapturedStdout();
auto lattice = lmp->domain->lattice;
ASSERT_EQ(lattice->style, Lattice::HCP);
@ -280,20 +280,20 @@ TEST_F(LatticeRegionTest, lattice_hcp)
ASSERT_DOUBLE_EQ(lattice->a3[2], sqrt(8.0 / 3.0));
TEST_FAILURE(".*ERROR: Invalid option in lattice command for non-custom style.*",
lmp->input->one("lattice hcp 1.0 a2 0.0 1.0 0.0"););
command("lattice hcp 1.0 a2 0.0 1.0 0.0"););
TEST_FAILURE(".*ERROR: Invalid option in lattice command for non-custom style.*",
lmp->input->one("lattice hcp 1.0 a3 0.0 1.0 0.0"););
command("lattice hcp 1.0 a3 0.0 1.0 0.0"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("dimension 2");
command("dimension 2");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Lattice style incompatible with simulation dimension.*",
lmp->input->one("lattice hcp 1.0"););
command("lattice hcp 1.0"););
}
TEST_F(LatticeRegionTest, lattice_diamond)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("lattice diamond 4.1 orient x 1 1 2 orient y -1 1 0 orient z -1 -1 1");
command("lattice diamond 4.1 orient x 1 1 2 orient y -1 1 0 orient z -1 -1 1");
if (!verbose) ::testing::internal::GetCapturedStdout();
auto lattice = lmp->domain->lattice;
ASSERT_EQ(lattice->style, Lattice::DIAMOND);
@ -336,17 +336,17 @@ TEST_F(LatticeRegionTest, lattice_diamond)
ASSERT_EQ(lattice->a3[2], 1.0);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("dimension 2");
command("dimension 2");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Lattice style incompatible with simulation dimension.*",
lmp->input->one("lattice diamond 1.0"););
command("lattice diamond 1.0"););
}
TEST_F(LatticeRegionTest, lattice_sq)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("dimension 2");
lmp->input->one("lattice sq 3.0");
command("dimension 2");
command("lattice sq 3.0");
if (!verbose) ::testing::internal::GetCapturedStdout();
auto lattice = lmp->domain->lattice;
ASSERT_EQ(lattice->style, Lattice::SQ);
@ -358,22 +358,21 @@ TEST_F(LatticeRegionTest, lattice_sq)
ASSERT_EQ(lattice->basis[0][1], 0.0);
ASSERT_EQ(lattice->basis[0][2], 0.0);
TEST_FAILURE(
".*ERROR: Lattice settings are not compatible with 2d simulation.*",
lmp->input->one("lattice sq 1.0 orient x 1 1 2 orient y -1 1 0 orient z -1 -1 1"););
TEST_FAILURE(".*ERROR: Lattice settings are not compatible with 2d simulation.*",
command("lattice sq 1.0 orient x 1 1 2 orient y -1 1 0 orient z -1 -1 1"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("dimension 3");
command("dimension 3");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Lattice style incompatible with simulation dimension.*",
lmp->input->one("lattice sq 1.0"););
command("lattice sq 1.0"););
}
TEST_F(LatticeRegionTest, lattice_sq2)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("dimension 2");
lmp->input->one("lattice sq2 2.0");
command("dimension 2");
command("lattice sq2 2.0");
if (!verbose) ::testing::internal::GetCapturedStdout();
auto lattice = lmp->domain->lattice;
ASSERT_EQ(lattice->style, Lattice::SQ2);
@ -389,17 +388,17 @@ TEST_F(LatticeRegionTest, lattice_sq2)
ASSERT_EQ(lattice->basis[1][2], 0.0);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("dimension 3");
command("dimension 3");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Lattice style incompatible with simulation dimension.*",
lmp->input->one("lattice sq2 1.0"););
command("lattice sq2 1.0"););
}
TEST_F(LatticeRegionTest, lattice_hex)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("dimension 2");
lmp->input->one("lattice hex 2.0");
command("dimension 2");
command("lattice hex 2.0");
if (!verbose) ::testing::internal::GetCapturedStdout();
auto lattice = lmp->domain->lattice;
ASSERT_EQ(lattice->style, Lattice::HEX);
@ -424,32 +423,32 @@ TEST_F(LatticeRegionTest, lattice_hex)
ASSERT_EQ(lattice->a3[2], 1.0);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("dimension 3");
command("dimension 3");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Lattice style incompatible with simulation dimension.*",
lmp->input->one("lattice hex 1.0"););
command("lattice hex 1.0"););
}
TEST_F(LatticeRegionTest, lattice_custom)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("variable a equal 4.34");
lmp->input->one("variable b equal $a*sqrt(3.0)");
lmp->input->one("variable c equal $a*sqrt(8.0/3.0)");
lmp->input->one("variable t equal 1.0/3.0");
lmp->input->one("variable f equal 5.0/6.0");
lmp->input->one("lattice custom 1.0 "
"a1 $a 0.0 0.0 "
"a2 0.0 $b 0.0 "
"a3 0.0 0.0 $c "
"basis 0.0 0.0 0.0 "
"basis 0.5 0.5 0.0 "
"basis $t 0.0 0.5 "
"basis $f 0.5 0.5 "
"basis 0.0 0.0 0.625 "
"basis 0.5 0.5 0.625 "
"basis $t 0.0 0.125 "
"basis $f 0.5 0.125 ");
command("variable a equal 4.34");
command("variable b equal $a*sqrt(3.0)");
command("variable c equal $a*sqrt(8.0/3.0)");
command("variable t equal 1.0/3.0");
command("variable f equal 5.0/6.0");
command("lattice custom 1.0 "
"a1 $a 0.0 0.0 "
"a2 0.0 $b 0.0 "
"a3 0.0 0.0 $c "
"basis 0.0 0.0 0.0 "
"basis 0.5 0.5 0.0 "
"basis $t 0.0 0.5 "
"basis $f 0.5 0.5 "
"basis 0.0 0.0 0.625 "
"basis 0.5 0.5 0.625 "
"basis $t 0.0 0.125 "
"basis $f 0.5 0.125 ");
if (!verbose) ::testing::internal::GetCapturedStdout();
auto lattice = lmp->domain->lattice;
ASSERT_EQ(lattice->style, Lattice::CUSTOM);
@ -492,47 +491,47 @@ TEST_F(LatticeRegionTest, lattice_custom)
ASSERT_DOUBLE_EQ(lattice->a3[2], 4.34 * sqrt(8.0 / 3.0));
TEST_FAILURE(".*ERROR: Illegal lattice command.*",
lmp->input->one("lattice custom 1.0 basis -0.1 0 0"););
command("lattice custom 1.0 basis -0.1 0 0"););
TEST_FAILURE(".*ERROR: Illegal lattice command.*",
lmp->input->one("lattice custom 1.0 basis 0.0 1.0 0"););
command("lattice custom 1.0 basis 0.0 1.0 0"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("dimension 2");
command("dimension 2");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: No basis atoms in lattice.*", lmp->input->one("lattice custom 1.0"););
TEST_FAILURE(".*ERROR: No basis atoms in lattice.*", command("lattice custom 1.0"););
TEST_FAILURE(".*ERROR: Lattice settings are not compatible with 2d simulation.*",
lmp->input->one("lattice custom 1.0 origin 0.5 0.5 0.5 basis 0.0 0.0 0.0"););
command("lattice custom 1.0 origin 0.5 0.5 0.5 basis 0.0 0.0 0.0"););
TEST_FAILURE(".*ERROR: Lattice settings are not compatible with 2d simulation.*",
lmp->input->one("lattice custom 1.0 a1 1.0 1.0 1.0 basis 0.0 0.0 0.0"););
command("lattice custom 1.0 a1 1.0 1.0 1.0 basis 0.0 0.0 0.0"););
TEST_FAILURE(".*ERROR: Lattice settings are not compatible with 2d simulation.*",
lmp->input->one("lattice custom 1.0 a2 1.0 1.0 1.0 basis 0.0 0.0 0.0"););
command("lattice custom 1.0 a2 1.0 1.0 1.0 basis 0.0 0.0 0.0"););
TEST_FAILURE(".*ERROR: Lattice settings are not compatible with 2d simulation.*",
lmp->input->one("lattice custom 1.0 a3 1.0 1.0 1.0 basis 0.0 0.0 0.0"););
command("lattice custom 1.0 a3 1.0 1.0 1.0 basis 0.0 0.0 0.0"););
}
TEST_F(LatticeRegionTest, region_fail)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("lattice none 2.0");
lmp->input->one("region box block 0 1 0 1 0 1");
command("lattice none 2.0");
command("region box block 0 1 0 1 0 1");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Create_atoms command before simulation box is defined.*",
lmp->input->one("create_atoms 1 box"););
command("create_atoms 1 box"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("create_box 1 box");
command("create_box 1 box");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Cannot create atoms with undefined lattice.*",
lmp->input->one("create_atoms 1 box"););
command("create_atoms 1 box"););
}
TEST_F(LatticeRegionTest, region_block_lattice)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("lattice sc 1.5");
lmp->input->one("region box block 0 2 0 2 0 2 units lattice");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 box");
command("lattice sc 1.5");
command("region box block 0 2 0 2 0 2 units lattice");
command("create_box 1 box");
command("create_atoms 1 box");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->domain->triclinic, 0);
@ -555,10 +554,10 @@ TEST_F(LatticeRegionTest, region_block_lattice)
TEST_F(LatticeRegionTest, region_block_box)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("lattice sc 1.5 origin 0.75 0.75 0.75");
lmp->input->one("region box block 0 2 0 2 0 2 units box");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 box");
command("lattice sc 1.5 origin 0.75 0.75 0.75");
command("region box block 0 2 0 2 0 2 units box");
command("create_box 1 box");
command("create_atoms 1 box");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->domain->triclinic, 0);
@ -572,11 +571,11 @@ TEST_F(LatticeRegionTest, region_block_box)
TEST_F(LatticeRegionTest, region_cone)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("lattice fcc 2.5 origin 0.5 0.5 0.5");
lmp->input->one("region box cone x 1.0 1.0 0.5 2.1 0.0 2.0");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 region box");
lmp->input->one("write_dump all atom init.lammpstrj");
command("lattice fcc 2.5 origin 0.5 0.5 0.5");
command("region box cone x 1.0 1.0 0.5 2.1 0.0 2.0");
command("create_box 1 box");
command("create_atoms 1 region box");
command("write_dump all atom init.lammpstrj");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->domain->triclinic, 0);
ASSERT_EQ(lmp->atom->natoms, 42);
@ -585,10 +584,10 @@ TEST_F(LatticeRegionTest, region_cone)
TEST_F(LatticeRegionTest, region_cylinder)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("lattice fcc 2.5 origin 0.5 0.5 0.5");
lmp->input->one("region box cylinder z 1.0 1.0 2.1 0.0 2.0 ");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 region box");
command("lattice fcc 2.5 origin 0.5 0.5 0.5");
command("region box cylinder z 1.0 1.0 2.1 0.0 2.0 ");
command("create_box 1 box");
command("create_atoms 1 region box");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->domain->triclinic, 0);
ASSERT_EQ(lmp->atom->natoms, 114);
@ -597,10 +596,10 @@ TEST_F(LatticeRegionTest, region_cylinder)
TEST_F(LatticeRegionTest, region_prism)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("lattice bcc 2.5 origin 0.75 0.75 0.75");
lmp->input->one("region box prism 0 2 0 2 0 2 0.5 0.0 0.0");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 box");
command("lattice bcc 2.5 origin 0.75 0.75 0.75");
command("region box prism 0 2 0 2 0 2 0.5 0.0 0.0");
command("create_box 1 box");
command("create_atoms 1 box");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->domain->triclinic, 1);
ASSERT_EQ(lmp->atom->natoms, 16);
@ -609,10 +608,10 @@ TEST_F(LatticeRegionTest, region_prism)
TEST_F(LatticeRegionTest, region_sphere)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("lattice fcc 2.5 origin 0.5 0.5 0.5");
lmp->input->one("region box sphere 1.0 1.0 1.0 1.1");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 region box");
command("lattice fcc 2.5 origin 0.5 0.5 0.5");
command("region box sphere 1.0 1.0 1.0 1.1");
command("create_box 1 box");
command("create_atoms 1 region box");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->domain->triclinic, 0);
ASSERT_EQ(lmp->atom->natoms, 14);
@ -621,12 +620,12 @@ TEST_F(LatticeRegionTest, region_sphere)
TEST_F(LatticeRegionTest, region_union)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("lattice fcc 2.5 origin 0.5 0.5 0.5");
lmp->input->one("region part1 sphere 2.0 1.0 1.0 1.1");
lmp->input->one("region part2 block 0.0 2.0 0.0 2.0 0.0 2.0");
lmp->input->one("region box union 2 part1 part2");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 region box");
command("lattice fcc 2.5 origin 0.5 0.5 0.5");
command("region part1 sphere 2.0 1.0 1.0 1.1");
command("region part2 block 0.0 2.0 0.0 2.0 0.0 2.0");
command("region box union 2 part1 part2");
command("create_box 1 box");
command("create_atoms 1 region box");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->domain->triclinic, 0);
ASSERT_EQ(lmp->atom->natoms, 67);
@ -635,12 +634,12 @@ TEST_F(LatticeRegionTest, region_union)
TEST_F(LatticeRegionTest, region_intersect)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("lattice fcc 2.5 origin 0.5 0.5 0.5");
lmp->input->one("region part1 sphere 2.0 1.0 1.0 1.8");
lmp->input->one("region part2 block 0.0 2.0 0.0 2.0 0.0 2.0");
lmp->input->one("region box intersect 2 part1 part2");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 region box");
command("lattice fcc 2.5 origin 0.5 0.5 0.5");
command("region part1 sphere 2.0 1.0 1.0 1.8");
command("region part2 block 0.0 2.0 0.0 2.0 0.0 2.0");
command("region box intersect 2 part1 part2");
command("create_box 1 box");
command("create_atoms 1 region box");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->domain->triclinic, 0);
ASSERT_EQ(lmp->atom->natoms, 21);
@ -649,14 +648,14 @@ TEST_F(LatticeRegionTest, region_intersect)
TEST_F(LatticeRegionTest, region_plane)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("lattice fcc 2.5 origin 0.5 0.5 0.5");
lmp->input->one("region box block 0.0 2.0 0.0 2.0 0.0 2.0");
lmp->input->one("region part1 plane 0.5 1.0 0.0 0.75 0.0 0.0");
lmp->input->one("region part2 plane 1.5 1.0 0.0 0.75 0.0 0.0 side out");
lmp->input->one("region atoms intersect 2 part1 part2");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 region atoms");
lmp->input->one("write_dump all atom init.lammpstrj");
command("lattice fcc 2.5 origin 0.5 0.5 0.5");
command("region box block 0.0 2.0 0.0 2.0 0.0 2.0");
command("region part1 plane 0.5 1.0 0.0 0.75 0.0 0.0");
command("region part2 plane 1.5 1.0 0.0 0.75 0.0 0.0 side out");
command("region atoms intersect 2 part1 part2");
command("create_box 1 box");
command("create_atoms 1 region atoms");
command("write_dump all atom init.lammpstrj");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->domain->triclinic, 0);
ASSERT_EQ(lmp->atom->natoms, 16);

View File

@ -85,6 +85,8 @@ protected:
delete lmp;
if (!verbose) ::testing::internal::GetCapturedStdout();
}
void command(const std::string &cmd) { lmp->input->one(cmd); }
};
TEST_F(ResetIDsTest, MolIDAll)
@ -125,7 +127,7 @@ TEST_F(ResetIDsTest, MolIDAll)
// the original data file has two different molecule IDs
// for two residues of the same molecule/fragment.
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("reset_mol_ids all");
command("reset_mol_ids all");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(molid[GETIDX(1)], 1);
@ -167,10 +169,10 @@ TEST_F(ResetIDsTest, DeletePlusAtomID)
// delete two water molecules
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("group allwater molecule 3:6");
lmp->input->one("group twowater molecule 4:6:2");
lmp->input->one("delete_atoms group twowater compress no bond yes");
lmp->input->one("reset_mol_ids all");
command("group allwater molecule 3:6");
command("group twowater molecule 4:6:2");
command("delete_atoms group twowater compress no bond yes");
command("reset_mol_ids all");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->atom->natoms, 23);
ASSERT_EQ(lmp->atom->map_tag_max, 26);
@ -229,7 +231,7 @@ TEST_F(ResetIDsTest, DeletePlusAtomID)
ASSERT_GE(GETIDX(26), 0);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("reset_atom_ids");
command("reset_atom_ids");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->atom->map_tag_max, 23);
@ -245,9 +247,9 @@ TEST_F(ResetIDsTest, PartialOffset)
// delete two water molecules
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("group allwater molecule 3:6");
lmp->input->one("group nowater subtract all allwater");
lmp->input->one("reset_mol_ids allwater offset 4");
command("group allwater molecule 3:6");
command("group nowater subtract all allwater");
command("reset_mol_ids allwater offset 4");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->atom->natoms, 29);
ASSERT_EQ(lmp->atom->map_tag_max, 29);
@ -283,7 +285,7 @@ TEST_F(ResetIDsTest, PartialOffset)
ASSERT_EQ(molid[GETIDX(29)], 8);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("reset_mol_ids nowater offset 0");
command("reset_mol_ids nowater offset 0");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(molid[GETIDX(1)], 1);
@ -325,11 +327,11 @@ TEST_F(ResetIDsTest, DeleteAdd)
// delete two water molecules
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("group allwater molecule 3:6");
lmp->input->one("group twowater molecule 4:6:2");
lmp->input->one("group nowater subtract all allwater");
lmp->input->one("delete_atoms group twowater compress no bond yes mol yes");
lmp->input->one("reset_mol_ids allwater");
command("group allwater molecule 3:6");
command("group twowater molecule 4:6:2");
command("group nowater subtract all allwater");
command("delete_atoms group twowater compress no bond yes mol yes");
command("reset_mol_ids allwater");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->atom->natoms, 23);
ASSERT_EQ(lmp->atom->map_tag_max, 26);
@ -388,7 +390,7 @@ TEST_F(ResetIDsTest, DeleteAdd)
ASSERT_GE(GETIDX(26), 0);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("reset_atom_ids sort yes");
command("reset_atom_ids sort yes");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->atom->map_tag_max, 23);
@ -396,7 +398,7 @@ TEST_F(ResetIDsTest, DeleteAdd)
ASSERT_GE(GETIDX(i), 0);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("reset_mol_ids nowater offset 1");
command("reset_mol_ids nowater offset 1");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(molid[GETIDX(1)], 2);
@ -424,11 +426,11 @@ TEST_F(ResetIDsTest, DeleteAdd)
ASSERT_EQ(molid[GETIDX(23)], 4);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("create_atoms 1 single 0.0 0.0 0.0");
lmp->input->one("create_atoms 2 single 1.0 0.0 0.0");
lmp->input->one("create_atoms 3 single 2.0 0.0 0.0");
lmp->input->one("create_atoms 4 single 3.0 0.0 0.0");
lmp->input->one("reset_mol_ids all single yes");
command("create_atoms 1 single 0.0 0.0 0.0");
command("create_atoms 2 single 1.0 0.0 0.0");
command("create_atoms 3 single 2.0 0.0 0.0");
command("create_atoms 4 single 3.0 0.0 0.0");
command("reset_mol_ids all single yes");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->atom->natoms, 27);
ASSERT_EQ(lmp->atom->map_tag_max, 27);
@ -442,7 +444,7 @@ TEST_F(ResetIDsTest, DeleteAdd)
ASSERT_EQ(molid[GETIDX(27)], 7);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("reset_mol_ids all single no");
command("reset_mol_ids all single no");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(molid[GETIDX(21)], 3);
@ -454,7 +456,7 @@ TEST_F(ResetIDsTest, DeleteAdd)
ASSERT_EQ(molid[GETIDX(27)], 0);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("reset_mol_ids all compress no single yes");
command("reset_mol_ids all compress no single yes");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(molid[GETIDX(21)], 21);
@ -472,20 +474,20 @@ TEST_F(ResetIDsTest, TopologyData)
// delete two water molecules
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("group allwater molecule 3:6");
lmp->input->one("group twowater molecule 4:6:2");
lmp->input->one("group nowater subtract all allwater");
lmp->input->one("delete_atoms group twowater compress no bond yes mol yes");
command("group allwater molecule 3:6");
command("group twowater molecule 4:6:2");
command("group nowater subtract all allwater");
command("delete_atoms group twowater compress no bond yes mol yes");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->atom->natoms, 23);
ASSERT_EQ(lmp->atom->map_tag_max, 26);
auto num_bond = lmp->atom->num_bond;
auto num_angle = lmp->atom->num_angle;
auto bond_atom = lmp->atom->bond_atom;
auto angle_atom1 = lmp->atom->angle_atom1;
auto angle_atom2 = lmp->atom->angle_atom2;
auto angle_atom3 = lmp->atom->angle_atom3;
auto num_bond = lmp->atom->num_bond;
auto num_angle = lmp->atom->num_angle;
auto bond_atom = lmp->atom->bond_atom;
auto angle_atom1 = lmp->atom->angle_atom1;
auto angle_atom2 = lmp->atom->angle_atom2;
auto angle_atom3 = lmp->atom->angle_atom3;
ASSERT_EQ(num_bond[GETIDX(1)], 2);
ASSERT_EQ(bond_atom[GETIDX(1)][0], 2);
ASSERT_EQ(bond_atom[GETIDX(1)][1], 3);
@ -561,15 +563,15 @@ TEST_F(ResetIDsTest, TopologyData)
ASSERT_EQ(angle_atom3[GETIDX(24)][0], 26);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("reset_atom_ids sort yes");
command("reset_atom_ids sort yes");
if (!verbose) ::testing::internal::GetCapturedStdout();
num_bond = lmp->atom->num_bond;
num_angle = lmp->atom->num_angle;
bond_atom = lmp->atom->bond_atom;
angle_atom1 = lmp->atom->angle_atom1;
angle_atom2 = lmp->atom->angle_atom2;
angle_atom3 = lmp->atom->angle_atom3;
num_bond = lmp->atom->num_bond;
num_angle = lmp->atom->num_angle;
bond_atom = lmp->atom->bond_atom;
angle_atom1 = lmp->atom->angle_atom1;
angle_atom2 = lmp->atom->angle_atom2;
angle_atom3 = lmp->atom->angle_atom3;
ASSERT_EQ(num_bond[GETIDX(1)], 2);
ASSERT_EQ(bond_atom[GETIDX(1)][0], 3);
ASSERT_EQ(bond_atom[GETIDX(1)][1], 2);
@ -658,26 +660,23 @@ TEST_F(ResetIDsTest, DeathTests)
{
if (lmp->atom->natoms == 0) GTEST_SKIP();
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*", lmp->input->one("reset_mol_ids"););
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*", command("reset_mol_ids"););
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*",
lmp->input->one("reset_mol_ids all offset 1 1"););
command("reset_mol_ids all offset 1 1"););
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*",
lmp->input->one("reset_mol_ids all offset -2"););
command("reset_mol_ids all offset -2"););
TEST_FAILURE(".*ERROR on proc 0: Expected integer.*", command("reset_mol_ids all offset xxx"););
TEST_FAILURE(".*ERROR on proc 0: Expected integer.*",
lmp->input->one("reset_mol_ids all offset xxx"););
TEST_FAILURE(".*ERROR on proc 0: Expected integer.*",
lmp->input->one("reset_mol_ids all compress yes single no offset xxx"););
command("reset_mol_ids all compress yes single no offset xxx"););
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*", command("reset_mol_ids all offset"););
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*",
lmp->input->one("reset_mol_ids all offset"););
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*",
lmp->input->one("reset_mol_ids all compress"););
command("reset_mol_ids all compress"););
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*",
lmp->input->one("reset_mol_ids all compress xxx"););
command("reset_mol_ids all compress xxx"););
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*", command("reset_mol_ids all single"););
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*",
lmp->input->one("reset_mol_ids all single"););
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*",
lmp->input->one("reset_mol_ids all single xxx"););
command("reset_mol_ids all single xxx"););
}
TEST(ResetMolIds, CMDFail)
@ -693,20 +692,23 @@ TEST(ResetMolIds, CMDFail)
TEST_FAILURE(".*ERROR: Reset_mol_ids command before simulation box is.*",
lmp->input->one("reset_mol_ids all"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("atom_modify id no");
lmp->input->one("region box block 0 1 0 1 0 1");
lmp->input->one("create_box 1 box");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Cannot use reset_mol_ids unless.*",
lmp->input->one("reset_mol_ids all"););
auto command = [&](const std::string &line) {
lmp->input->one(line.c_str());
};
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("region box block 0 1 0 1 0 1");
lmp->input->one("create_box 1 box");
command("atom_modify id no");
command("region box block 0 1 0 1 0 1");
command("create_box 1 box");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Can only use reset_mol_ids.*", lmp->input->one("reset_mol_ids all"););
TEST_FAILURE(".*ERROR: Cannot use reset_mol_ids unless.*", command("reset_mol_ids all"););
if (!verbose) ::testing::internal::CaptureStdout();
command("clear");
command("region box block 0 1 0 1 0 1");
command("create_box 1 box");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Can only use reset_mol_ids.*", command("reset_mol_ids all"););
if (!verbose) ::testing::internal::CaptureStdout();
delete lmp;

View File

@ -82,11 +82,13 @@ protected:
delete lmp;
if (!verbose) ::testing::internal::GetCapturedStdout();
}
void command(const std::string &cmd) { lmp->input->one(cmd); }
};
TEST_F(SimpleCommandsTest, UnknownCommand)
{
TEST_FAILURE(".*ERROR: Unknown command.*", lmp->input->one("XXX one two"););
TEST_FAILURE(".*ERROR: Unknown command.*", command("XXX one two"););
}
TEST_F(SimpleCommandsTest, Echo)
@ -95,31 +97,31 @@ TEST_F(SimpleCommandsTest, Echo)
ASSERT_EQ(lmp->input->echo_log, 0);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("echo none");
command("echo none");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->input->echo_screen, 0);
ASSERT_EQ(lmp->input->echo_log, 0);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("echo both");
command("echo both");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->input->echo_screen, 1);
ASSERT_EQ(lmp->input->echo_log, 1);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("echo screen");
command("echo screen");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->input->echo_screen, 1);
ASSERT_EQ(lmp->input->echo_log, 0);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("echo log");
command("echo log");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->input->echo_screen, 0);
ASSERT_EQ(lmp->input->echo_log, 1);
TEST_FAILURE(".*ERROR: Illegal echo command.*", lmp->input->one("echo"););
TEST_FAILURE(".*ERROR: Illegal echo command.*", lmp->input->one("echo xxx"););
TEST_FAILURE(".*ERROR: Illegal echo command.*", command("echo"););
TEST_FAILURE(".*ERROR: Illegal echo command.*", command("echo xxx"););
}
TEST_F(SimpleCommandsTest, Log)
@ -127,13 +129,13 @@ TEST_F(SimpleCommandsTest, Log)
ASSERT_EQ(lmp->logfile, nullptr);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("log simple_command_test.log");
lmp->input->one("print 'test1'");
command("log simple_command_test.log");
command("print 'test1'");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_NE(lmp->logfile, nullptr);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("log none");
command("log none");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->logfile, nullptr);
@ -145,12 +147,12 @@ TEST_F(SimpleCommandsTest, Log)
ASSERT_THAT(text, StrEq("test1"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("log simple_command_test.log append");
lmp->input->one("print 'test2'");
command("log simple_command_test.log append");
command("print 'test2'");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_NE(lmp->logfile, nullptr);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("log none");
command("log none");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->logfile, nullptr);
@ -162,7 +164,7 @@ TEST_F(SimpleCommandsTest, Log)
in.close();
remove("simple_command_test.log");
TEST_FAILURE(".*ERROR: Illegal log command.*", lmp->input->one("log"););
TEST_FAILURE(".*ERROR: Illegal log command.*", command("log"););
}
TEST_F(SimpleCommandsTest, Newton)
@ -171,22 +173,22 @@ TEST_F(SimpleCommandsTest, Newton)
ASSERT_EQ(lmp->force->newton_pair, 1);
ASSERT_EQ(lmp->force->newton_bond, 1);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("newton off");
command("newton off");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->force->newton_pair, 0);
ASSERT_EQ(lmp->force->newton_bond, 0);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("newton on off");
command("newton on off");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->force->newton_pair, 1);
ASSERT_EQ(lmp->force->newton_bond, 0);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("newton off on");
command("newton off on");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->force->newton_pair, 0);
ASSERT_EQ(lmp->force->newton_bond, 1);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("newton on");
command("newton on");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->force->newton_pair, 1);
ASSERT_EQ(lmp->force->newton_bond, 1);
@ -195,21 +197,20 @@ TEST_F(SimpleCommandsTest, Newton)
TEST_F(SimpleCommandsTest, Partition)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("echo none");
command("echo none");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Illegal partition command .*",
lmp->input->one("partition xxx 1 echo none"););
TEST_FAILURE(".*ERROR: Illegal partition command .*", command("partition xxx 1 echo none"););
TEST_FAILURE(".*ERROR: Numeric index 2 is out of bounds.*",
lmp->input->one("partition yes 2 echo none"););
command("partition yes 2 echo none"););
::testing::internal::CaptureStdout();
lmp->input->one("partition yes 1 print 'test'");
command("partition yes 1 print 'test'");
auto text = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << text;
ASSERT_THAT(text, StrEq("test\n"));
::testing::internal::CaptureStdout();
lmp->input->one("partition no 1 print 'test'");
command("partition no 1 print 'test'");
text = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << text;
ASSERT_THAT(text, StrEq(""));
@ -218,14 +219,14 @@ TEST_F(SimpleCommandsTest, Partition)
TEST_F(SimpleCommandsTest, Quit)
{
::testing::internal::CaptureStdout();
lmp->input->one("echo none");
command("echo none");
::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR: Expected integer .*", lmp->input->one("quit xxx"););
TEST_FAILURE(".*ERROR: Expected integer .*", command("quit xxx"););
// the following tests must be skipped with OpenMPI due to using threads
if (have_openmpi) GTEST_SKIP();
ASSERT_EXIT(lmp->input->one("quit"), ExitedWithCode(0), "");
ASSERT_EXIT(lmp->input->one("quit 9"), ExitedWithCode(9), "");
ASSERT_EXIT(command("quit"), ExitedWithCode(0), "");
ASSERT_EXIT(command("quit 9"), ExitedWithCode(9), "");
}
TEST_F(SimpleCommandsTest, ResetTimestep)
@ -233,19 +234,19 @@ TEST_F(SimpleCommandsTest, ResetTimestep)
ASSERT_EQ(lmp->update->ntimestep, 0);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("reset_timestep 10");
command("reset_timestep 10");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->update->ntimestep, 10);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("reset_timestep 0");
command("reset_timestep 0");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->update->ntimestep, 0);
TEST_FAILURE(".*ERROR: Timestep must be >= 0.*", lmp->input->one("reset_timestep -10"););
TEST_FAILURE(".*ERROR: Illegal reset_timestep .*", lmp->input->one("reset_timestep"););
TEST_FAILURE(".*ERROR: Illegal reset_timestep .*", lmp->input->one("reset_timestep 10 10"););
TEST_FAILURE(".*ERROR: Expected integer .*", lmp->input->one("reset_timestep xxx"););
TEST_FAILURE(".*ERROR: Timestep must be >= 0.*", command("reset_timestep -10"););
TEST_FAILURE(".*ERROR: Illegal reset_timestep .*", command("reset_timestep"););
TEST_FAILURE(".*ERROR: Illegal reset_timestep .*", command("reset_timestep 10 10"););
TEST_FAILURE(".*ERROR: Expected integer .*", command("reset_timestep xxx"););
}
TEST_F(SimpleCommandsTest, Suffix)
@ -254,39 +255,38 @@ TEST_F(SimpleCommandsTest, Suffix)
ASSERT_EQ(lmp->suffix, nullptr);
ASSERT_EQ(lmp->suffix2, nullptr);
TEST_FAILURE(".*ERROR: May only enable suffixes after defining one.*",
lmp->input->one("suffix on"););
TEST_FAILURE(".*ERROR: May only enable suffixes after defining one.*", command("suffix on"););
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("suffix one");
command("suffix one");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_THAT(lmp->suffix, StrEq("one"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("suffix hybrid two three");
command("suffix hybrid two three");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_THAT(lmp->suffix, StrEq("two"));
ASSERT_THAT(lmp->suffix2, StrEq("three"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("suffix four");
command("suffix four");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_THAT(lmp->suffix, StrEq("four"));
ASSERT_EQ(lmp->suffix2, nullptr);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("suffix off");
command("suffix off");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->suffix_enable, 0);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("suffix on");
command("suffix on");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->suffix_enable, 1);
TEST_FAILURE(".*ERROR: Illegal suffix command.*", lmp->input->one("suffix"););
TEST_FAILURE(".*ERROR: Illegal suffix command.*", lmp->input->one("suffix hybrid"););
TEST_FAILURE(".*ERROR: Illegal suffix command.*", lmp->input->one("suffix hybrid one"););
TEST_FAILURE(".*ERROR: Illegal suffix command.*", command("suffix"););
TEST_FAILURE(".*ERROR: Illegal suffix command.*", command("suffix hybrid"););
TEST_FAILURE(".*ERROR: Illegal suffix command.*", command("suffix hybrid one"););
}
TEST_F(SimpleCommandsTest, Thermo)
@ -294,53 +294,53 @@ TEST_F(SimpleCommandsTest, Thermo)
ASSERT_EQ(lmp->output->thermo_every, 0);
ASSERT_EQ(lmp->output->var_thermo, nullptr);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("thermo 2");
command("thermo 2");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->output->thermo_every, 2);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("variable step equal logfreq(10,3,10)");
lmp->input->one("thermo v_step");
command("variable step equal logfreq(10,3,10)");
command("thermo v_step");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_THAT(lmp->output->var_thermo, StrEq("step"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("thermo 10");
command("thermo 10");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->output->thermo_every, 10);
ASSERT_EQ(lmp->output->var_thermo, nullptr);
TEST_FAILURE(".*ERROR: Illegal thermo command.*", lmp->input->one("thermo"););
TEST_FAILURE(".*ERROR: Illegal thermo command.*", lmp->input->one("thermo -1"););
TEST_FAILURE(".*ERROR: Expected integer.*", lmp->input->one("thermo xxx"););
TEST_FAILURE(".*ERROR: Illegal thermo command.*", command("thermo"););
TEST_FAILURE(".*ERROR: Illegal thermo command.*", command("thermo -1"););
TEST_FAILURE(".*ERROR: Expected integer.*", command("thermo xxx"););
}
TEST_F(SimpleCommandsTest, TimeStep)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("timestep 1");
command("timestep 1");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->update->dt, 1.0);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("timestep 0.1");
command("timestep 0.1");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->update->dt, 0.1);
// zero timestep is legal and works (atoms don't move)
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("timestep 0.0");
command("timestep 0.0");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->update->dt, 0.0);
// negative timestep also creates a viable MD.
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("timestep -0.1");
command("timestep -0.1");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->update->dt, -0.1);
TEST_FAILURE(".*ERROR: Illegal timestep command.*", lmp->input->one("timestep"););
TEST_FAILURE(".*ERROR: Expected floating point.*", lmp->input->one("timestep xxx"););
TEST_FAILURE(".*ERROR: Illegal timestep command.*", command("timestep"););
TEST_FAILURE(".*ERROR: Expected floating point.*", command("timestep xxx"););
}
TEST_F(SimpleCommandsTest, Units)
@ -353,24 +353,24 @@ TEST_F(SimpleCommandsTest, Units)
ASSERT_THAT(lmp->update->unit_style, StrEq("lj"));
for (std::size_t i = 0; i < num; ++i) {
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one(fmt::format("units {}", names[i]));
command(fmt::format("units {}", names[i]));
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_THAT(lmp->update->unit_style, StrEq(names[i]));
ASSERT_EQ(lmp->update->dt, dt[i]);
}
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
command("clear");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_THAT(lmp->update->unit_style, StrEq("lj"));
TEST_FAILURE(".*ERROR: Illegal units command.*", lmp->input->one("units unknown"););
TEST_FAILURE(".*ERROR: Illegal units command.*", command("units unknown"););
}
TEST_F(SimpleCommandsTest, Shell)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("shell putenv TEST_VARIABLE=simpletest");
command("shell putenv TEST_VARIABLE=simpletest");
if (!verbose) ::testing::internal::GetCapturedStdout();
char *test_var = getenv("TEST_VARIABLE");
@ -378,8 +378,8 @@ TEST_F(SimpleCommandsTest, Shell)
ASSERT_THAT(test_var, StrEq("simpletest"));
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("shell putenv TEST_VARIABLE=simpletest");
lmp->input->one("shell putenv TEST_VARIABLE2=simpletest2 OTHER_VARIABLE=2");
command("shell putenv TEST_VARIABLE=simpletest");
command("shell putenv TEST_VARIABLE2=simpletest2 OTHER_VARIABLE=2");
if (!verbose) ::testing::internal::GetCapturedStdout();
char *test_var2 = getenv("TEST_VARIABLE2");

View File

@ -298,31 +298,31 @@ TEST_F(VariableTest, IfCommand)
command("if 1>0 then 'print \".*bingo!\"'");
auto text = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << text;
ASSERT_THAT(text,MatchesRegex(".*bingo!.*"));
ASSERT_THAT(text, MatchesRegex(".*bingo!.*"));
::testing::internal::CaptureStdout();
command("if (1>=0) then 'print \"bingo!\"'");
text = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << text;
ASSERT_THAT(text,MatchesRegex(".*bingo!.*"));
ASSERT_THAT(text, MatchesRegex(".*bingo!.*"));
::testing::internal::CaptureStdout();
command("if (-1.0e-1<0.0E+0) then 'print \"bingo!\"'");
text = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << text;
ASSERT_THAT(text,MatchesRegex(".*bingo!.*"));
ASSERT_THAT(text, MatchesRegex(".*bingo!.*"));
::testing::internal::CaptureStdout();
command("if (${one}==1.0)&&(2>=1) then 'print \"bingo!\"'");
text = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << text;
ASSERT_THAT(text,MatchesRegex(".*bingo!.*"));
ASSERT_THAT(text, MatchesRegex(".*bingo!.*"));
::testing::internal::CaptureStdout();
command("if !((${one}!=1.0)||(2|^1)) then 'print \"missed\"' else 'print \"bingo!\"'");
text = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << text;
ASSERT_THAT(text,MatchesRegex(".*bingo!.*"));
ASSERT_THAT(text, MatchesRegex(".*bingo!.*"));
TEST_FAILURE(".*ERROR: Invalid Boolean syntax in if command.*",
command("if () then 'print \"bingo!\"'"););

View File

@ -307,7 +307,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
// init_forces
block.clear();
auto f = lmp->atom->f;
auto f = lmp->atom->f;
for (int i = 1; i <= natoms; ++i) {
const int j = lmp->atom->map(i);
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);
@ -327,7 +327,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
writer.emit_block("run_stress", block);
block.clear();
f = lmp->atom->f;
f = lmp->atom->f;
for (int i = 1; i <= natoms; ++i) {
const int j = lmp->atom->map(i);
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);

View File

@ -307,7 +307,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
// init_forces
block.clear();
auto f = lmp->atom->f;
auto f = lmp->atom->f;
for (int i = 1; i <= natoms; ++i) {
const int j = lmp->atom->map(i);
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);
@ -327,7 +327,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
writer.emit_block("run_stress", block);
block.clear();
f = lmp->atom->f;
f = lmp->atom->f;
for (int i = 1; i <= natoms; ++i) {
const int j = lmp->atom->map(i);
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);

View File

@ -53,17 +53,17 @@ TestConfigReader::TestConfigReader(TestConfig &config) : YamlReader(), config(co
consumers["global_scalar"] = &TestConfigReader::global_scalar;
consumers["global_vector"] = &TestConfigReader::global_vector;
consumers["bond_style"] = &TestConfigReader::bond_style;
consumers["bond_coeff"] = &TestConfigReader::bond_coeff;
consumers["angle_style"] = &TestConfigReader::angle_style;
consumers["angle_coeff"] = &TestConfigReader::angle_coeff;
consumers["bond_style"] = &TestConfigReader::bond_style;
consumers["bond_coeff"] = &TestConfigReader::bond_coeff;
consumers["angle_style"] = &TestConfigReader::angle_style;
consumers["angle_coeff"] = &TestConfigReader::angle_coeff;
consumers["dihedral_style"] = &TestConfigReader::dihedral_style;
consumers["dihedral_coeff"] = &TestConfigReader::dihedral_coeff;
consumers["improper_style"] = &TestConfigReader::improper_style;
consumers["improper_coeff"] = &TestConfigReader::improper_coeff;
consumers["init_energy"] = &TestConfigReader::init_energy;
consumers["run_energy"] = &TestConfigReader::run_energy;
consumers["equilibrium"] = &TestConfigReader::equilibrium;
consumers["init_energy"] = &TestConfigReader::init_energy;
consumers["run_energy"] = &TestConfigReader::run_energy;
consumers["equilibrium"] = &TestConfigReader::equilibrium;
}
void TestConfigReader::prerequisites(const yaml_event_t &event)

View File

@ -310,7 +310,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
// init_forces
block.clear();
auto f = lmp->atom->f;
auto f = lmp->atom->f;
for (int i = 1; i <= natoms; ++i) {
const int j = lmp->atom->map(i);
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);
@ -330,7 +330,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
writer.emit_block("run_stress", block);
block.clear();
f = lmp->atom->f;
f = lmp->atom->f;
for (int i = 1; i <= natoms; ++i) {
const int j = lmp->atom->map(i);
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);

View File

@ -301,7 +301,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
// init_forces
block.clear();
auto f = lmp->atom->f;
auto f = lmp->atom->f;
for (int i = 1; i <= natoms; ++i) {
const int j = lmp->atom->map(i);
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);
@ -321,7 +321,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
writer.emit_block("run_stress", block);
block.clear();
f = lmp->atom->f;
f = lmp->atom->f;
for (int i = 1; i <= natoms; ++i) {
const int j = lmp->atom->map(i);
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);

View File

@ -307,7 +307,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
// init_forces
block.clear();
auto f = lmp->atom->f;
auto f = lmp->atom->f;
for (int i = 1; i <= natoms; ++i) {
const int j = lmp->atom->map(i);
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);
@ -330,7 +330,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
writer.emit_block("run_stress", block);
block.clear();
f = lmp->atom->f;
f = lmp->atom->f;
for (int i = 1; i <= natoms; ++i) {
const int j = lmp->atom->map(i);
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);
@ -829,9 +829,8 @@ TEST(PairStyle, intel)
GTEST_SKIP();
}
if ((test_config.pair_style == "rebo")
|| utils::strmatch(test_config.pair_style, "^dpd")
|| utils::strmatch(test_config.pair_style, "^tersoff.* shift ")) {
if ((test_config.pair_style == "rebo") || utils::strmatch(test_config.pair_style, "^dpd") ||
utils::strmatch(test_config.pair_style, "^tersoff.* shift ")) {
std::cerr << "Skipping pair style " << lmp->force->pair_style << "\n";
if (!verbose) ::testing::internal::CaptureStdout();
cleanup_lammps(lmp, test_config);

View File

@ -102,9 +102,6 @@ class AtomStyleTest : public ::testing::Test {
protected:
LAMMPS *lmp;
// convenience...
void command(const std::string cmd) { lmp->input->one(cmd); }
void SetUp() override
{
const char *args[] = {"SimpleCommandsTest", "-log", "none", "-echo", "screen", "-nocite"};
@ -131,6 +128,8 @@ protected:
remove("input_atom_styles.data");
remove("test_atom_styles.restart");
}
void command(const std::string cmd) { lmp->input->one(cmd); }
};
// default class Atom state

View File

@ -84,6 +84,8 @@ protected:
if (!verbose) ::testing::internal::GetCapturedStdout();
remove("safe_file_read_test.txt");
}
void command(const std::string &cmd) { lmp->input->one(cmd); }
};
#define MAX_BUF_SIZE 128
@ -155,13 +157,13 @@ TEST_F(FileOperationsTest, logmesg)
{
char buf[8];
::testing::internal::CaptureStdout();
lmp->input->one("echo none");
command("echo none");
::testing::internal::GetCapturedStdout();
::testing::internal::CaptureStdout();
utils::logmesg(lmp, "one\n");
lmp->input->one("log test_logmesg.log");
command("log test_logmesg.log");
utils::logmesg(lmp, "two\n");
lmp->input->one("log none");
command("log none");
std::string out = ::testing::internal::GetCapturedStdout();
memset(buf, 0, 8);
FILE *fp = fopen("test_logmesg.log", "r");

View File

@ -28,7 +28,6 @@ using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
using ::testing::Eq;
class ImageFlagsTest : public ::testing::Test {
protected:
LAMMPS *lmp;
@ -43,18 +42,18 @@ protected:
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_NE(lmp, nullptr);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units real");
lmp->input->one("dimension 3");
lmp->input->one("region box block -2 2 -2 2 -2 2");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 single 0.0 0.0 0.0 units box");
lmp->input->one("create_atoms 1 single 1.9 -1.9 1.9999 units box");
lmp->input->one("pair_style zero 2.0");
lmp->input->one("pair_coeff * *");
lmp->input->one("mass * 1.0");
lmp->input->one("set atom 1 image -1 2 3");
lmp->input->one("set atom 2 image -2 1 -1");
lmp->input->one("write_data test_image_flags.data");
command("units real");
command("dimension 3");
command("region box block -2 2 -2 2 -2 2");
command("create_box 1 box");
command("create_atoms 1 single 0.0 0.0 0.0 units box");
command("create_atoms 1 single 1.9 -1.9 1.9999 units box");
command("pair_style zero 2.0");
command("pair_coeff * *");
command("mass * 1.0");
command("set atom 1 image -1 2 3");
command("set atom 2 image -2 1 -1");
command("write_data test_image_flags.data");
if (!verbose) ::testing::internal::GetCapturedStdout();
}
@ -65,196 +64,198 @@ protected:
if (!verbose) ::testing::internal::GetCapturedStdout();
remove("test_image_flags.data");
}
void command(const std::string &cmd) { lmp->input->one(cmd); }
};
TEST_F(ImageFlagsTest, change_box)
{
auto image = lmp->atom->image;
int imx = (image[0] & IMGMASK) - IMGMAX;
int imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
int imz = (image[0] >> IMG2BITS) - IMGMAX;
int imx = (image[0] & IMGMASK) - IMGMAX;
int imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
int imz = (image[0] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx, -1);
ASSERT_EQ(imy, 2);
ASSERT_EQ(imz, 3);
ASSERT_EQ(imx,-1);
ASSERT_EQ(imy,2);
ASSERT_EQ(imz,3);
imx = (image[1] & IMGMASK) - IMGMAX;
imy = (image[1] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[1] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,-2);
ASSERT_EQ(imy,1);
ASSERT_EQ(imz,-1);
ASSERT_EQ(imx, -2);
ASSERT_EQ(imy, 1);
ASSERT_EQ(imz, -1);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("change_box all boundary f p p");
command("change_box all boundary f p p");
if (!verbose) ::testing::internal::GetCapturedStdout();
image = lmp->atom->image;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,0);
ASSERT_EQ(imy,2);
ASSERT_EQ(imz,3);
ASSERT_EQ(imx, 0);
ASSERT_EQ(imy, 2);
ASSERT_EQ(imz, 3);
imx = (image[1] & IMGMASK) - IMGMAX;
imy = (image[1] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[1] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,0);
ASSERT_EQ(imy,1);
ASSERT_EQ(imz,-1);
ASSERT_EQ(imx, 0);
ASSERT_EQ(imy, 1);
ASSERT_EQ(imz, -1);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("change_box all boundary f s p");
command("change_box all boundary f s p");
if (!verbose) ::testing::internal::GetCapturedStdout();
image = lmp->atom->image;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,0);
ASSERT_EQ(imy,0);
ASSERT_EQ(imz,3);
ASSERT_EQ(imx, 0);
ASSERT_EQ(imy, 0);
ASSERT_EQ(imz, 3);
imx = (image[1] & IMGMASK) - IMGMAX;
imy = (image[1] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[1] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,0);
ASSERT_EQ(imy,0);
ASSERT_EQ(imz,-1);
ASSERT_EQ(imx, 0);
ASSERT_EQ(imy, 0);
ASSERT_EQ(imz, -1);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("change_box all boundary p p m");
command("change_box all boundary p p m");
if (!verbose) ::testing::internal::GetCapturedStdout();
image = lmp->atom->image;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,0);
ASSERT_EQ(imy,0);
ASSERT_EQ(imz,0);
ASSERT_EQ(imx, 0);
ASSERT_EQ(imy, 0);
ASSERT_EQ(imz, 0);
imx = (image[1] & IMGMASK) - IMGMAX;
imy = (image[1] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[1] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,0);
ASSERT_EQ(imy,0);
ASSERT_EQ(imz,0);
ASSERT_EQ(imx, 0);
ASSERT_EQ(imy, 0);
ASSERT_EQ(imz, 0);
}
TEST_F(ImageFlagsTest, read_data)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("dimension 3");
lmp->input->one("boundary p p p");
lmp->input->one("pair_style zero 2.0");
lmp->input->one("read_data test_image_flags.data");
command("clear");
command("units real");
command("dimension 3");
command("boundary p p p");
command("pair_style zero 2.0");
command("read_data test_image_flags.data");
if (!verbose) ::testing::internal::GetCapturedStdout();
auto image = lmp->atom->image;
int imx = (image[0] & IMGMASK) - IMGMAX;
int imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
int imz = (image[0] >> IMG2BITS) - IMGMAX;
int imx = (image[0] & IMGMASK) - IMGMAX;
int imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
int imz = (image[0] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx, -1);
ASSERT_EQ(imy, 2);
ASSERT_EQ(imz, 3);
ASSERT_EQ(imx,-1);
ASSERT_EQ(imy,2);
ASSERT_EQ(imz,3);
imx = (image[1] & IMGMASK) - IMGMAX;
imy = (image[1] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[1] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,-2);
ASSERT_EQ(imy,1);
ASSERT_EQ(imz,-1);
ASSERT_EQ(imx, -2);
ASSERT_EQ(imy, 1);
ASSERT_EQ(imz, -1);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("dimension 3");
lmp->input->one("boundary f p p");
lmp->input->one("pair_style zero 2.0");
lmp->input->one("read_data test_image_flags.data");
command("clear");
command("units real");
command("dimension 3");
command("boundary f p p");
command("pair_style zero 2.0");
command("read_data test_image_flags.data");
if (!verbose) ::testing::internal::GetCapturedStdout();
image = lmp->atom->image;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,0);
ASSERT_EQ(imy,2);
ASSERT_EQ(imz,3);
ASSERT_EQ(imx, 0);
ASSERT_EQ(imy, 2);
ASSERT_EQ(imz, 3);
imx = (image[1] & IMGMASK) - IMGMAX;
imy = (image[1] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[1] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,0);
ASSERT_EQ(imy,1);
ASSERT_EQ(imz,-1);
ASSERT_EQ(imx, 0);
ASSERT_EQ(imy, 1);
ASSERT_EQ(imz, -1);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("dimension 3");
lmp->input->one("boundary p s p");
lmp->input->one("pair_style zero 2.0");
lmp->input->one("read_data test_image_flags.data");
command("clear");
command("units real");
command("dimension 3");
command("boundary p s p");
command("pair_style zero 2.0");
command("read_data test_image_flags.data");
if (!verbose) ::testing::internal::GetCapturedStdout();
image = lmp->atom->image;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,-1);
ASSERT_EQ(imy,0);
ASSERT_EQ(imz,3);
ASSERT_EQ(imx, -1);
ASSERT_EQ(imy, 0);
ASSERT_EQ(imz, 3);
imx = (image[1] & IMGMASK) - IMGMAX;
imy = (image[1] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[1] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,-2);
ASSERT_EQ(imy,0);
ASSERT_EQ(imz,-1);
ASSERT_EQ(imx, -2);
ASSERT_EQ(imy, 0);
ASSERT_EQ(imz, -1);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("dimension 3");
lmp->input->one("boundary p p m");
lmp->input->one("pair_style zero 2.0");
lmp->input->one("read_data test_image_flags.data");
command("clear");
command("units real");
command("dimension 3");
command("boundary p p m");
command("pair_style zero 2.0");
command("read_data test_image_flags.data");
if (!verbose) ::testing::internal::GetCapturedStdout();
image = lmp->atom->image;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,-1);
ASSERT_EQ(imy,2);
ASSERT_EQ(imz,0);
ASSERT_EQ(imx, -1);
ASSERT_EQ(imy, 2);
ASSERT_EQ(imz, 0);
imx = (image[1] & IMGMASK) - IMGMAX;
imy = (image[1] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[1] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,-2);
ASSERT_EQ(imy,1);
ASSERT_EQ(imz,0);
ASSERT_EQ(imx, -2);
ASSERT_EQ(imy, 1);
ASSERT_EQ(imz, 0);
}
} // namespace LAMMPS_NS

View File

@ -131,19 +131,20 @@ protected:
lmp->input->one(fmt::format("molecule {} {} {}", name, file, args));
remove(file.c_str());
}
void command(const std::string &cmd) { lmp->input->one(cmd); }
};
TEST_F(MoleculeFileTest, nofile)
{
TEST_FAILURE(".*Cannot open molecule file nofile.mol.*",
lmp->input->one("molecule 1 nofile.mol"););
TEST_FAILURE(".*Cannot open molecule file nofile.mol.*", command("molecule 1 nofile.mol"););
}
TEST_F(MoleculeFileTest, badid)
{
TEST_FAILURE(".*Molecule template ID must have only "
"alphanumeric or underscore characters.*",
lmp->input->one("molecule @mol nofile.mol"););
command("molecule @mol nofile.mol"););
}
TEST_F(MoleculeFileTest, badargs)
@ -223,7 +224,7 @@ TEST_F(MoleculeFileTest, twomols)
TEST_F(MoleculeFileTest, twofiles)
{
::testing::internal::CaptureStdout();
lmp->input->one("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0");
command("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0");
auto output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
ASSERT_THAT(output, MatchesRegex(".*Read molecule template twomols:.*1 molecules.*3 atoms "
@ -237,10 +238,10 @@ TEST_F(MoleculeFileTest, twofiles)
TEST_F(MoleculeFileTest, bonds)
{
::testing::internal::CaptureStdout();
lmp->input->one("atom_style bond");
lmp->input->one("region box block 0 1 0 1 0 1");
lmp->input->one("create_box 2 box bond/types 2 extra/bond/per/atom 2 "
"extra/special/per/atom 4");
command("atom_style bond");
command("region box block 0 1 0 1 0 1");
command("create_box 2 box bond/types 2 extra/bond/per/atom 2 "
"extra/special/per/atom 4");
run_mol_cmd(test_name, "",
"Comment\n"
"4 atoms\n"
@ -264,8 +265,8 @@ TEST_F(MoleculeFileTest, bonds)
"2 bonds.*type.*2.*0 angles.*"));
::testing::internal::CaptureStdout();
lmp->input->one("mass * 2.0");
lmp->input->one("create_atoms 0 single 0.5 0.5 0.5 mol bonds 67235");
command("mass * 2.0");
command("create_atoms 0 single 0.5 0.5 0.5 mol bonds 67235");
output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
ASSERT_THAT(output, MatchesRegex(".*Created 4 atoms.*"));

View File

@ -59,19 +59,19 @@ protected:
ASSERT_NE(lmp, nullptr);
if (!verbose) ::testing::internal::CaptureStdout();
info = new Info(lmp);
lmp->input->one("units metal");
lmp->input->one("dimension 3");
lmp->input->one("region box block -4 4 -4 4 -4 4");
lmp->input->one("create_box 2 box");
lmp->input->one("create_atoms 1 single -1.1 1.2 0.0 units box");
lmp->input->one("create_atoms 1 single -1.2 -1.1 0.0 units box");
lmp->input->one("create_atoms 2 single 0.9 1.0 0.0 units box");
lmp->input->one("create_atoms 2 single 1.0 -0.9 0.0 units box");
lmp->input->one("pair_style zero 4.0");
lmp->input->one("pair_coeff * *");
lmp->input->one("mass * 1.0");
lmp->input->one("write_data test_pair_unit_convert.data nocoeff");
lmp->input->one("clear");
command("units metal");
command("dimension 3");
command("region box block -4 4 -4 4 -4 4");
command("create_box 2 box");
command("create_atoms 1 single -1.1 1.2 0.0 units box");
command("create_atoms 1 single -1.2 -1.1 0.0 units box");
command("create_atoms 2 single 0.9 1.0 0.0 units box");
command("create_atoms 2 single 1.0 -0.9 0.0 units box");
command("pair_style zero 4.0");
command("pair_coeff * *");
command("mass * 1.0");
command("write_data test_pair_unit_convert.data nocoeff");
command("clear");
if (!verbose) ::testing::internal::GetCapturedStdout();
}
@ -83,6 +83,8 @@ protected:
if (!verbose) ::testing::internal::GetCapturedStdout();
remove("test_pair_unit_convert.data");
}
void command(const std::string &cmd) { lmp->input->one(cmd); }
};
TEST_F(PairUnitConvertTest, zero)
@ -91,11 +93,11 @@ TEST_F(PairUnitConvertTest, zero)
if (!info->has_style("pair", "zero")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style zero 6.0");
lmp->input->one("pair_coeff * *");
lmp->input->one("run 0 post no");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style zero 6.0");
command("pair_coeff * *");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -108,12 +110,12 @@ TEST_F(PairUnitConvertTest, zero)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style zero 6.0");
lmp->input->one("pair_coeff * *");
lmp->input->one("run 0 post no");
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style zero 6.0");
command("pair_coeff * *");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -134,15 +136,15 @@ TEST_F(PairUnitConvertTest, lj_cut)
if (!info->has_style("pair", "lj/cut")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style lj/cut 6.0");
lmp->input->one("pair_coeff * * 0.01014286346782117 2.0");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style lj/cut 6.0");
command("pair_coeff * * 0.01014286346782117 2.0");
remove("test.table.metal");
lmp->input->one("pair_write 1 1 1000 r 0.1 6.0 test.table.metal lj_1_1");
lmp->input->one("pair_write 1 2 1000 r 0.1 6.0 test.table.metal lj_1_2");
lmp->input->one("pair_write 2 2 1000 r 0.1 6.0 test.table.metal lj_2_2");
lmp->input->one("run 0 post no");
command("pair_write 1 1 1000 r 0.1 6.0 test.table.metal lj_1_1");
command("pair_write 1 2 1000 r 0.1 6.0 test.table.metal lj_1_2");
command("pair_write 2 2 1000 r 0.1 6.0 test.table.metal lj_2_2");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -155,16 +157,16 @@ TEST_F(PairUnitConvertTest, lj_cut)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style lj/cut 6.0");
lmp->input->one("pair_coeff * * 0.2339 2.0");
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style lj/cut 6.0");
command("pair_coeff * * 0.2339 2.0");
remove("test.table.real");
lmp->input->one("pair_write 1 1 1000 r 0.1 6.0 test.table.real lj_1_1");
lmp->input->one("pair_write 1 2 1000 r 0.1 6.0 test.table.real lj_1_2");
lmp->input->one("pair_write 2 2 1000 r 0.1 6.0 test.table.real lj_2_2");
lmp->input->one("run 0 post no");
command("pair_write 1 1 1000 r 0.1 6.0 test.table.real lj_1_1");
command("pair_write 1 2 1000 r 0.1 6.0 test.table.real lj_1_2");
command("pair_write 2 2 1000 r 0.1 6.0 test.table.real lj_2_2");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -185,11 +187,11 @@ TEST_F(PairUnitConvertTest, eam)
if (!info->has_style("pair", "eam")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style eam");
lmp->input->one("pair_coeff * * Cu_u3.eam");
lmp->input->one("run 0 post no");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style eam");
command("pair_coeff * * Cu_u3.eam");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -202,12 +204,12 @@ TEST_F(PairUnitConvertTest, eam)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style eam");
lmp->input->one("pair_coeff * * Cu_u3.eam");
lmp->input->one("run 0 post no");
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style eam");
command("pair_coeff * * Cu_u3.eam");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -228,11 +230,11 @@ TEST_F(PairUnitConvertTest, eam_alloy)
if (!info->has_style("pair", "eam/alloy")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style eam/alloy");
lmp->input->one("pair_coeff * * AlCu.eam.alloy Al Cu");
lmp->input->one("run 0 post no");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style eam/alloy");
command("pair_coeff * * AlCu.eam.alloy Al Cu");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -245,12 +247,12 @@ TEST_F(PairUnitConvertTest, eam_alloy)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style eam/alloy");
lmp->input->one("pair_coeff * * AlCu.eam.alloy Al Cu");
lmp->input->one("run 0 post no");
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style eam/alloy");
command("pair_coeff * * AlCu.eam.alloy Al Cu");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -271,11 +273,11 @@ TEST_F(PairUnitConvertTest, eam_fs)
if (!info->has_style("pair", "eam/fs")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style eam/fs");
lmp->input->one("pair_coeff * * FeP_mm.eam.fs Fe P");
lmp->input->one("run 0 post no");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style eam/fs");
command("pair_coeff * * FeP_mm.eam.fs Fe P");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -288,12 +290,12 @@ TEST_F(PairUnitConvertTest, eam_fs)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style eam/fs");
lmp->input->one("pair_coeff * * FeP_mm.eam.fs Fe P");
lmp->input->one("run 0 post no");
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style eam/fs");
command("pair_coeff * * FeP_mm.eam.fs Fe P");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -314,11 +316,11 @@ TEST_F(PairUnitConvertTest, eam_cd)
if (!info->has_style("pair", "eam/cd")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style eam/cd");
lmp->input->one("pair_coeff * * FeCr.cdeam Cr Fe");
lmp->input->one("run 0 post no");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style eam/cd");
command("pair_coeff * * FeCr.cdeam Cr Fe");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -331,12 +333,12 @@ TEST_F(PairUnitConvertTest, eam_cd)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style eam/cd");
lmp->input->one("pair_coeff * * FeCr.cdeam Cr Fe");
lmp->input->one("run 0 post no");
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style eam/cd");
command("pair_coeff * * FeCr.cdeam Cr Fe");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -357,11 +359,11 @@ TEST_F(PairUnitConvertTest, eim)
if (!info->has_style("pair", "eim")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style eim");
lmp->input->one("pair_coeff * * Na Cl ffield.eim Na Cl");
lmp->input->one("run 0 post no");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style eim");
command("pair_coeff * * Na Cl ffield.eim Na Cl");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -374,12 +376,12 @@ TEST_F(PairUnitConvertTest, eim)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style eim");
lmp->input->one("pair_coeff * * Na Cl ffield.eim Na Cl");
lmp->input->one("run 0 post no");
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style eim");
command("pair_coeff * * Na Cl ffield.eim Na Cl");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -400,11 +402,11 @@ TEST_F(PairUnitConvertTest, gw)
if (!info->has_style("pair", "gw")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style gw");
lmp->input->one("pair_coeff * * SiC.gw Si C");
lmp->input->one("run 0 post no");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style gw");
command("pair_coeff * * SiC.gw Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -417,12 +419,12 @@ TEST_F(PairUnitConvertTest, gw)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style gw");
lmp->input->one("pair_coeff * * SiC.gw Si C");
lmp->input->one("run 0 post no");
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style gw");
command("pair_coeff * * SiC.gw Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -443,11 +445,11 @@ TEST_F(PairUnitConvertTest, gw_zbl)
if (!info->has_style("pair", "gw/zbl")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style gw/zbl");
lmp->input->one("pair_coeff * * SiC.gw.zbl Si C");
lmp->input->one("run 0 post no");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style gw/zbl");
command("pair_coeff * * SiC.gw.zbl Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -460,12 +462,12 @@ TEST_F(PairUnitConvertTest, gw_zbl)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style gw/zbl");
lmp->input->one("pair_coeff * * SiC.gw.zbl Si C");
lmp->input->one("run 0 post no");
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style gw/zbl");
command("pair_coeff * * SiC.gw.zbl Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -486,11 +488,11 @@ TEST_F(PairUnitConvertTest, nb3b_harmonic)
if (!info->has_style("pair", "nb3b/harmonic")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style nb3b/harmonic");
lmp->input->one("pair_coeff * * MOH.nb3b.harmonic M O");
lmp->input->one("run 0 post no");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style nb3b/harmonic");
command("pair_coeff * * MOH.nb3b.harmonic M O");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -503,12 +505,12 @@ TEST_F(PairUnitConvertTest, nb3b_harmonic)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style nb3b/harmonic");
lmp->input->one("pair_coeff * * MOH.nb3b.harmonic M O");
lmp->input->one("run 0 post no");
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style nb3b/harmonic");
command("pair_coeff * * MOH.nb3b.harmonic M O");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -529,11 +531,11 @@ TEST_F(PairUnitConvertTest, sw)
if (!info->has_style("pair", "sw")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style sw");
lmp->input->one("pair_coeff * * GaN.sw Ga N");
lmp->input->one("run 0 post no");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style sw");
command("pair_coeff * * GaN.sw Ga N");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -546,12 +548,12 @@ TEST_F(PairUnitConvertTest, sw)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style sw");
lmp->input->one("pair_coeff * * GaN.sw Ga N");
lmp->input->one("run 0 post no");
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style sw");
command("pair_coeff * * GaN.sw Ga N");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -572,13 +574,13 @@ TEST_F(PairUnitConvertTest, table_metal2real)
if (!info->has_style("pair", "table")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style table linear 1000");
lmp->input->one("pair_coeff 1 1 test.table.metal lj_1_1");
lmp->input->one("pair_coeff 1 2 test.table.metal lj_1_2");
lmp->input->one("pair_coeff 2 2 test.table.metal lj_2_2");
lmp->input->one("run 0 post no");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style table linear 1000");
command("pair_coeff 1 1 test.table.metal lj_1_1");
command("pair_coeff 1 2 test.table.metal lj_1_2");
command("pair_coeff 2 2 test.table.metal lj_2_2");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -591,14 +593,14 @@ TEST_F(PairUnitConvertTest, table_metal2real)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style table linear 1000");
lmp->input->one("pair_coeff 1 1 test.table.metal lj_1_1");
lmp->input->one("pair_coeff 1 2 test.table.metal lj_1_2");
lmp->input->one("pair_coeff 2 2 test.table.metal lj_2_2");
lmp->input->one("run 0 post no");
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style table linear 1000");
command("pair_coeff 1 1 test.table.metal lj_1_1");
command("pair_coeff 1 2 test.table.metal lj_1_2");
command("pair_coeff 2 2 test.table.metal lj_2_2");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -619,13 +621,13 @@ TEST_F(PairUnitConvertTest, table_real2metal)
if (!info->has_style("pair", "table")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style table linear 1000");
lmp->input->one("pair_coeff 1 1 test.table.real lj_1_1");
lmp->input->one("pair_coeff 1 2 test.table.real lj_1_2");
lmp->input->one("pair_coeff 2 2 test.table.real lj_2_2");
lmp->input->one("run 0 post no");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style table linear 1000");
command("pair_coeff 1 1 test.table.real lj_1_1");
command("pair_coeff 1 2 test.table.real lj_1_2");
command("pair_coeff 2 2 test.table.real lj_2_2");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -638,14 +640,14 @@ TEST_F(PairUnitConvertTest, table_real2metal)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style table linear 1000");
lmp->input->one("pair_coeff 1 1 test.table.real lj_1_1");
lmp->input->one("pair_coeff 1 2 test.table.real lj_1_2");
lmp->input->one("pair_coeff 2 2 test.table.real lj_2_2");
lmp->input->one("run 0 post no");
command("clear");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style table linear 1000");
command("pair_coeff 1 1 test.table.real lj_1_1");
command("pair_coeff 1 2 test.table.real lj_1_2");
command("pair_coeff 2 2 test.table.real lj_2_2");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -666,11 +668,11 @@ TEST_F(PairUnitConvertTest, tersoff)
if (!info->has_style("pair", "tersoff")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style tersoff");
lmp->input->one("pair_coeff * * SiC.tersoff Si C");
lmp->input->one("run 0 post no");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff");
command("pair_coeff * * SiC.tersoff Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -683,12 +685,12 @@ TEST_F(PairUnitConvertTest, tersoff)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style tersoff");
lmp->input->one("pair_coeff * * SiC.tersoff Si C");
lmp->input->one("run 0 post no");
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff");
command("pair_coeff * * SiC.tersoff Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -709,11 +711,11 @@ TEST_F(PairUnitConvertTest, tersoff_mod)
if (!info->has_style("pair", "tersoff/mod")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style tersoff/mod");
lmp->input->one("pair_coeff * * Si.tersoff.mod Si Si");
lmp->input->one("run 0 post no");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/mod");
command("pair_coeff * * Si.tersoff.mod Si Si");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -726,12 +728,12 @@ TEST_F(PairUnitConvertTest, tersoff_mod)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style tersoff/mod");
lmp->input->one("pair_coeff * * Si.tersoff.mod Si Si");
lmp->input->one("run 0 post no");
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/mod");
command("pair_coeff * * Si.tersoff.mod Si Si");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -752,11 +754,11 @@ TEST_F(PairUnitConvertTest, tersoff_mod_c)
if (!info->has_style("pair", "tersoff/mod/c")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style tersoff/mod/c");
lmp->input->one("pair_coeff * * Si.tersoff.modc Si Si");
lmp->input->one("run 0 post no");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/mod/c");
command("pair_coeff * * Si.tersoff.modc Si Si");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -769,12 +771,12 @@ TEST_F(PairUnitConvertTest, tersoff_mod_c)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style tersoff/mod/c");
lmp->input->one("pair_coeff * * Si.tersoff.modc Si Si");
lmp->input->one("run 0 post no");
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/mod/c");
command("pair_coeff * * Si.tersoff.modc Si Si");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -795,11 +797,11 @@ TEST_F(PairUnitConvertTest, tersoff_table)
if (!info->has_style("pair", "tersoff/table")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style tersoff/table");
lmp->input->one("pair_coeff * * SiC.tersoff Si C");
lmp->input->one("run 0 post no");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/table");
command("pair_coeff * * SiC.tersoff Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -812,12 +814,12 @@ TEST_F(PairUnitConvertTest, tersoff_table)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style tersoff/table");
lmp->input->one("pair_coeff * * SiC.tersoff Si C");
lmp->input->one("run 0 post no");
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/table");
command("pair_coeff * * SiC.tersoff Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -838,11 +840,11 @@ TEST_F(PairUnitConvertTest, tersoff_zbl)
if (!info->has_style("pair", "tersoff/zbl")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style tersoff/zbl");
lmp->input->one("pair_coeff * * SiC.tersoff.zbl Si C");
lmp->input->one("run 0 post no");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/zbl");
command("pair_coeff * * SiC.tersoff.zbl Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -855,12 +857,12 @@ TEST_F(PairUnitConvertTest, tersoff_zbl)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style tersoff/zbl");
lmp->input->one("pair_coeff * * SiC.tersoff.zbl Si C");
lmp->input->one("run 0 post no");
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/zbl");
command("pair_coeff * * SiC.tersoff.zbl Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -881,12 +883,12 @@ TEST_F(PairUnitConvertTest, tersoff_zbl_omp)
if (!info->has_style("pair", "tersoff/zbl/omp")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("package omp 4");
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style tersoff/zbl/omp");
lmp->input->one("pair_coeff * * SiC.tersoff.zbl Si C");
lmp->input->one("run 0 post no");
command("package omp 4");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/zbl/omp");
command("pair_coeff * * SiC.tersoff.zbl Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -899,13 +901,13 @@ TEST_F(PairUnitConvertTest, tersoff_zbl_omp)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("package omp 4");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style tersoff/zbl/omp");
lmp->input->one("pair_coeff * * SiC.tersoff.zbl Si C");
lmp->input->one("run 0 post no");
command("clear");
command("package omp 4");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/zbl/omp");
command("pair_coeff * * SiC.tersoff.zbl Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;
@ -926,11 +928,11 @@ TEST_F(PairUnitConvertTest, vashishta)
if (!info->has_style("pair", "vashishta")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style vashishta");
lmp->input->one("pair_coeff * * SiC.vashishta Si C");
lmp->input->one("run 0 post no");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style vashishta");
command("pair_coeff * * SiC.vashishta Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
// copy pressure, energy, and force from first step
@ -943,12 +945,12 @@ TEST_F(PairUnitConvertTest, vashishta)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("read_data test_pair_unit_convert.data");
lmp->input->one("pair_style vashishta");
lmp->input->one("pair_coeff * * SiC.vashishta Si C");
lmp->input->one("run 0 post no");
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style vashishta");
command("pair_coeff * * SiC.vashishta Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
double pnew;

View File

@ -96,13 +96,15 @@ protected:
delete lmp;
if (!verbose) ::testing::internal::GetCapturedStdout();
}
void command(const std::string &cmd) { lmp->input->one(cmd); }
};
// open for native units
TEST_F(PotentialFileReaderTest, Sw_native)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
command("units metal");
PotentialFileReader reader(lmp, "Si.sw", "Stillinger-Weber");
if (!verbose) ::testing::internal::GetCapturedStdout();
@ -114,7 +116,7 @@ TEST_F(PotentialFileReaderTest, Sw_native)
TEST_F(PotentialFileReaderTest, Sw_conv)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units real");
command("units real");
PotentialFileReader reader(lmp, "Si.sw", "Stillinger-Weber", utils::METAL2REAL);
if (!verbose) ::testing::internal::GetCapturedStdout();
@ -126,7 +128,7 @@ TEST_F(PotentialFileReaderTest, Sw_conv)
TEST_F(PotentialFileReaderTest, Sw_noconv)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units real");
command("units real");
if (!verbose) ::testing::internal::GetCapturedStdout();
TEST_FAILURE(".*ERROR on proc.*potential.*requires metal units but real.*",
@ -136,7 +138,7 @@ TEST_F(PotentialFileReaderTest, Sw_noconv)
TEST_F(PotentialFileReaderTest, Comb)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
command("units metal");
PotentialFileReader reader(lmp, "ffield.comb", "COMB");
if (!verbose) ::testing::internal::GetCapturedStdout();
@ -147,7 +149,7 @@ TEST_F(PotentialFileReaderTest, Comb)
TEST_F(PotentialFileReaderTest, Comb3)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
command("units metal");
PotentialFileReader reader(lmp, "ffield.comb3", "COMB3");
if (!verbose) ::testing::internal::GetCapturedStdout();
@ -158,7 +160,7 @@ TEST_F(PotentialFileReaderTest, Comb3)
TEST_F(PotentialFileReaderTest, Tersoff)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
command("units metal");
PotentialFileReader reader(lmp, "Si.tersoff", "Tersoff");
if (!verbose) ::testing::internal::GetCapturedStdout();
@ -169,7 +171,7 @@ TEST_F(PotentialFileReaderTest, Tersoff)
TEST_F(PotentialFileReaderTest, TersoffMod)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
command("units metal");
PotentialFileReader reader(lmp, "Si.tersoff.mod", "Tersoff/Mod");
if (!verbose) ::testing::internal::GetCapturedStdout();
@ -180,7 +182,7 @@ TEST_F(PotentialFileReaderTest, TersoffMod)
TEST_F(PotentialFileReaderTest, TersoffModC)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
command("units metal");
PotentialFileReader reader(lmp, "Si.tersoff.modc", "Tersoff/ModC");
if (!verbose) ::testing::internal::GetCapturedStdout();
@ -191,7 +193,7 @@ TEST_F(PotentialFileReaderTest, TersoffModC)
TEST_F(PotentialFileReaderTest, TersoffTable)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
command("units metal");
PotentialFileReader reader(lmp, "Si.tersoff", "TersoffTable");
if (!verbose) ::testing::internal::GetCapturedStdout();
@ -202,7 +204,7 @@ TEST_F(PotentialFileReaderTest, TersoffTable)
TEST_F(PotentialFileReaderTest, TersoffZBL)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
command("units metal");
PotentialFileReader reader(lmp, "SiC.tersoff.zbl", "Tersoff/ZBL");
if (!verbose) ::testing::internal::GetCapturedStdout();
@ -213,7 +215,7 @@ TEST_F(PotentialFileReaderTest, TersoffZBL)
TEST_F(PotentialFileReaderTest, GW)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
command("units metal");
PotentialFileReader reader(lmp, "SiC.gw", "GW");
if (!verbose) ::testing::internal::GetCapturedStdout();
@ -224,7 +226,7 @@ TEST_F(PotentialFileReaderTest, GW)
TEST_F(PotentialFileReaderTest, GWZBL)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
command("units metal");
PotentialFileReader reader(lmp, "SiC.gw.zbl", "GW/ZBL");
if (!verbose) ::testing::internal::GetCapturedStdout();
@ -235,7 +237,7 @@ TEST_F(PotentialFileReaderTest, GWZBL)
TEST_F(PotentialFileReaderTest, Nb3bHarmonic)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units real");
command("units real");
PotentialFileReader reader(lmp, "MOH.nb3b.harmonic", "NB3B Harmonic");
if (!verbose) ::testing::internal::GetCapturedStdout();
@ -246,7 +248,7 @@ TEST_F(PotentialFileReaderTest, Nb3bHarmonic)
TEST_F(PotentialFileReaderTest, Vashishta)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
command("units metal");
PotentialFileReader reader(lmp, "SiC.vashishta", "Vashishta");
if (!verbose) ::testing::internal::GetCapturedStdout();
@ -260,7 +262,7 @@ TEST_F(PotentialFileReaderTest, UnitConvert)
int unit_convert, flag;
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units metal");
command("units metal");
reader = new PotentialFileReader(lmp, "Si.sw", "Stillinger-Weber");
if (!verbose) ::testing::internal::GetCapturedStdout();
@ -288,7 +290,7 @@ TEST_F(PotentialFileReaderTest, UnitConvert)
if (!verbose) ::testing::internal::CaptureStdout();
flag = utils::get_supported_conversions(utils::ENERGY);
lmp->input->one("units real");
command("units real");
reader = new PotentialFileReader(lmp, "Si.sw", "Stillinger-Weber", flag);
if (!verbose) ::testing::internal::GetCapturedStdout();

View File

@ -112,7 +112,7 @@ TEST(Tokenizer, as_vector1)
TEST(Tokenizer, as_vector2)
{
auto list = Tokenizer("a\\b\\c","\\").as_vector();
auto list = Tokenizer("a\\b\\c", "\\").as_vector();
ASSERT_THAT(list[0], Eq("a"));
ASSERT_THAT(list[1], Eq("b"));
ASSERT_THAT(list[2], Eq("c"));
@ -121,14 +121,14 @@ TEST(Tokenizer, as_vector2)
TEST(Tokenizer, as_vector3)
{
auto list = Tokenizer ("a\\","\\").as_vector();
auto list = Tokenizer("a\\", "\\").as_vector();
ASSERT_THAT(list[0], Eq("a"));
ASSERT_EQ(list.size(), 1);
}
TEST(Tokenizer, as_vector4)
{
auto list = Tokenizer ("\\a","\\").as_vector();
auto list = Tokenizer("\\a", "\\").as_vector();
ASSERT_THAT(list[0], Eq("a"));
ASSERT_EQ(list.size(), 1);
}

View File

@ -533,10 +533,12 @@ TEST(Utils, strfind_dot)
TEST(Utils, strfind_kim)
{
ASSERT_THAT(utils::strfind("n3409jfse MO_004835508849_000 aslfjiaf",
"[MS][MO]_\\d\\d\\d+_\\d\\d\\d"), StrEq("MO_004835508849_000"));
ASSERT_THAT(
utils::strfind("n3409jfse MO_004835508849_000 aslfjiaf", "[MS][MO]_\\d\\d\\d+_\\d\\d\\d"),
StrEq("MO_004835508849_000"));
ASSERT_THAT(utils::strfind("VanDuinChakraborty_2003_CHNO__SM_107643900657_000",
"[MS][MO]_\\d\\d\\d+_\\d\\d\\d"), StrEq("SM_107643900657_000"));
"[MS][MO]_\\d\\d\\d+_\\d\\d\\d"),
StrEq("SM_107643900657_000"));
}
TEST(Utils, bounds_case1)