Clean up molecule files creation
This commit is contained in:
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
using LAMMPS_NS::utils::split_words;
|
using LAMMPS_NS::utils::split_words;
|
||||||
|
|
||||||
static void create_molecule_files()
|
static void create_molecule_files(const std::string & h2o_filename, const std::string & co2_filename)
|
||||||
{
|
{
|
||||||
// create molecule files
|
// create molecule files
|
||||||
const char h2o_file[] = "# Water molecule. SPC/E model.\n\n3 atoms\n2 bonds\n1 angles\n\n"
|
const char h2o_file[] = "# Water molecule. SPC/E model.\n\n3 atoms\n2 bonds\n1 angles\n\n"
|
||||||
@ -73,18 +73,16 @@ static void create_molecule_files()
|
|||||||
"Special Bond Counts\n\n1 2 0 0\n2 1 1 0\n3 1 1 0\n\n"
|
"Special Bond Counts\n\n1 2 0 0\n2 1 1 0\n3 1 1 0\n\n"
|
||||||
"Special Bonds\n\n1 2 3\n2 1 3\n3 1 2\n\n";
|
"Special Bonds\n\n1 2 3\n2 1 3\n3 1 2\n\n";
|
||||||
|
|
||||||
FILE *fp = fopen("tmp.h2o.mol", "w");
|
FILE *fp = fopen(h2o_filename.c_str(), "w");
|
||||||
if (fp) {
|
if (fp) {
|
||||||
fputs(h2o_file, fp);
|
fputs(h2o_file, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
rename("tmp.h2o.mol", "h2o.mol");
|
fp = fopen(co2_filename.c_str(), "w");
|
||||||
fp = fopen("tmp.co2.mol", "w");
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
fputs(co2_file, fp);
|
fputs(co2_file, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
rename("tmp.co2.mol", "co2.mol");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
|
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
|
||||||
@ -97,6 +95,15 @@ using ::testing::Eq;
|
|||||||
|
|
||||||
class AtomStyleTest : public LAMMPSTest {
|
class AtomStyleTest : public LAMMPSTest {
|
||||||
protected:
|
protected:
|
||||||
|
static void SetUpTestSuite() {
|
||||||
|
create_molecule_files("h2o.mol", "co2.mol");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TearDownTestSuite() {
|
||||||
|
remove("h2o.mol");
|
||||||
|
remove("co2.mol");
|
||||||
|
}
|
||||||
|
|
||||||
void SetUp() override
|
void SetUp() override
|
||||||
{
|
{
|
||||||
testbinary = "AtomStyleTest";
|
testbinary = "AtomStyleTest";
|
||||||
@ -2618,7 +2625,6 @@ TEST_F(AtomStyleTest, body_nparticle)
|
|||||||
TEST_F(AtomStyleTest, template)
|
TEST_F(AtomStyleTest, template)
|
||||||
{
|
{
|
||||||
if (!LAMMPS::is_installed_pkg("MOLECULE")) GTEST_SKIP();
|
if (!LAMMPS::is_installed_pkg("MOLECULE")) GTEST_SKIP();
|
||||||
create_molecule_files();
|
|
||||||
BEGIN_HIDE_OUTPUT();
|
BEGIN_HIDE_OUTPUT();
|
||||||
command("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");
|
||||||
command("atom_style template twomols");
|
command("atom_style template twomols");
|
||||||
@ -3014,7 +3020,6 @@ TEST_F(AtomStyleTest, template)
|
|||||||
TEST_F(AtomStyleTest, template_charge)
|
TEST_F(AtomStyleTest, template_charge)
|
||||||
{
|
{
|
||||||
if (!LAMMPS::is_installed_pkg("MOLECULE")) GTEST_SKIP();
|
if (!LAMMPS::is_installed_pkg("MOLECULE")) GTEST_SKIP();
|
||||||
create_molecule_files();
|
|
||||||
BEGIN_HIDE_OUTPUT();
|
BEGIN_HIDE_OUTPUT();
|
||||||
command("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");
|
||||||
command("atom_style hybrid template twomols charge");
|
command("atom_style hybrid template twomols charge");
|
||||||
|
|||||||
@ -35,7 +35,7 @@ using utils::split_words;
|
|||||||
#define test_name test_info_->name()
|
#define test_name test_info_->name()
|
||||||
|
|
||||||
|
|
||||||
static void create_molecule_files()
|
static void create_molecule_files(const std::string & h2o_filename, const std::string & co2_filename)
|
||||||
{
|
{
|
||||||
// create molecule files
|
// create molecule files
|
||||||
const char h2o_file[] = "# Water molecule. SPC/E model.\n\n3 atoms\n2 bonds\n1 angles\n\n"
|
const char h2o_file[] = "# Water molecule. SPC/E model.\n\n3 atoms\n2 bonds\n1 angles\n\n"
|
||||||
@ -60,18 +60,16 @@ static void create_molecule_files()
|
|||||||
"Special Bond Counts\n\n1 2 0 0\n2 1 1 0\n3 1 1 0\n\n"
|
"Special Bond Counts\n\n1 2 0 0\n2 1 1 0\n3 1 1 0\n\n"
|
||||||
"Special Bonds\n\n1 2 3\n2 1 3\n3 1 2\n\n";
|
"Special Bonds\n\n1 2 3\n2 1 3\n3 1 2\n\n";
|
||||||
|
|
||||||
FILE *fp = fopen("tmp.moltest.h2o.mol", "w");
|
FILE *fp = fopen(h2o_filename.c_str(), "w");
|
||||||
if (fp) {
|
if (fp) {
|
||||||
fputs(h2o_file, fp);
|
fputs(h2o_file, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
rename("tmp.moltest.h2o.mol", "moltest.h2o.mol");
|
fp = fopen(co2_filename.c_str(), "w");
|
||||||
fp = fopen("tmp.moltest.co2.mol", "w");
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
fputs(co2_file, fp);
|
fputs(co2_file, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
rename("tmp.moltest.co2.mol", "moltest.co2.mol");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
|
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
|
||||||
@ -79,21 +77,25 @@ bool verbose = false;
|
|||||||
|
|
||||||
class MoleculeFileTest : public LAMMPSTest {
|
class MoleculeFileTest : public LAMMPSTest {
|
||||||
protected:
|
protected:
|
||||||
|
static void SetUpTestSuite() {
|
||||||
|
create_molecule_files("moltest.h2o.mol", "moltest.co2.mol");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TearDownTestSuite() {
|
||||||
|
remove("moltest.h2o.mol");
|
||||||
|
remove("moltest.co2.mol");
|
||||||
|
}
|
||||||
|
|
||||||
void SetUp() override
|
void SetUp() override
|
||||||
{
|
{
|
||||||
testbinary = "MoleculeFileTest";
|
testbinary = "MoleculeFileTest";
|
||||||
LAMMPSTest::SetUp();
|
LAMMPSTest::SetUp();
|
||||||
ASSERT_NE(lmp, nullptr);
|
ASSERT_NE(lmp, nullptr);
|
||||||
BEGIN_HIDE_OUTPUT();
|
|
||||||
create_molecule_files();
|
|
||||||
END_HIDE_OUTPUT();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDown() override
|
void TearDown() override
|
||||||
{
|
{
|
||||||
LAMMPSTest::TearDown();
|
LAMMPSTest::TearDown();
|
||||||
remove("moltest.h2o.mol");
|
|
||||||
remove("moltest.co2.mol");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void run_mol_cmd(const std::string &name, const std::string &args, const std::string &content)
|
void run_mol_cmd(const std::string &name, const std::string &args, const std::string &content)
|
||||||
|
|||||||
Reference in New Issue
Block a user